OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2012 the V8 project authors. All rights reserved. | |
2 // Redistribution and use in source and binary forms, with or without | |
3 // modification, are permitted provided that the following conditions are | |
4 // met: | |
5 // | |
6 // * Redistributions of source code must retain the above copyright | |
7 // notice, this list of conditions and the following disclaimer. | |
8 // * Redistributions in binary form must reproduce the above | |
9 // copyright notice, this list of conditions and the following | |
10 // disclaimer in the documentation and/or other materials provided | |
11 // with the distribution. | |
12 // * Neither the name of Google Inc. nor the names of its | |
13 // contributors may be used to endorse or promote products derived | |
14 // from this software without specific prior written permission. | |
15 // | |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
27 | |
28 // Flags: --allow-natives-syntax | |
29 | |
30 function less_1(a, b) { | |
31 return a < b; | |
32 } | |
33 | |
34 assertFalse(less_1(.5, .5)); | |
35 assertFalse(less_1(.5, undefined)); | |
36 assertFalse(less_1(undefined, .5)); | |
37 assertFalse(less_1(undefined, undefined)); | |
38 | |
39 function less_2(a, b) { | |
40 return a < b; | |
41 } | |
42 assertFalse(less_2(.5, .5)); | |
43 %OptimizeFunctionOnNextCall(less_2); | |
44 assertFalse(less_2(.5, .5)); | |
fschneider
2012/03/02 12:39:15
You could compress this into a helper
function te
danno
2012/03/02 13:28:45
Done.
| |
45 assertFalse(less_2(.5, undefined)); | |
46 assertFalse(less_2(undefined, .5)); | |
47 assertFalse(less_2(undefined, undefined)); | |
48 | |
49 function less_equal_1(a, b) { | |
50 return a <= b; | |
51 } | |
52 | |
53 assertTrue(less_equal_1(.5, .5)); | |
54 assertFalse(less_equal_1(.5, undefined)); | |
55 assertFalse(less_equal_1(undefined, .5)); | |
56 assertFalse(less_equal_1(undefined, undefined)); | |
57 | |
58 function less_equal_2(a, b) { | |
59 return a <= b; | |
60 } | |
61 assertTrue(less_equal_2(.5, .5)); | |
62 %OptimizeFunctionOnNextCall(less_equal_2); | |
63 assertTrue(less_equal_2(.5, .5)); | |
64 assertFalse(less_equal_2(.5, undefined)); | |
65 assertFalse(less_equal_2(undefined, .5)); | |
66 assertFalse(less_equal_2(undefined, undefined)); | |
67 | |
68 function greater_1(a, b) { | |
69 return a > b; | |
70 } | |
71 | |
72 assertFalse(greater_1(.5, .5)); | |
73 assertFalse(greater_1(.5, undefined)); | |
74 assertFalse(greater_1(undefined, .5)); | |
75 assertFalse(greater_1(undefined, undefined)); | |
76 | |
77 function greater_2(a, b) { | |
78 return a > b; | |
79 } | |
80 assertFalse(greater_2(.5, .5)); | |
81 %OptimizeFunctionOnNextCall(greater_2); | |
82 assertFalse(greater_2(.5, .5)); | |
83 assertFalse(greater_2(.5, undefined)); | |
84 assertFalse(greater_2(undefined, .5)); | |
85 assertFalse(greater_2(undefined, undefined)); | |
86 | |
87 function greater_equal_1(a, b) { | |
88 return a >= b; | |
89 } | |
90 | |
91 assertTrue(greater_equal_1(.5, .5)); | |
92 assertFalse(greater_equal_1(.5, undefined)); | |
93 assertFalse(greater_equal_1(undefined, .5)); | |
94 assertFalse(greater_equal_1(undefined, undefined)); | |
95 | |
96 function greater_equal_2(a, b) { | |
97 return a >= b; | |
98 } | |
99 assertTrue(greater_equal_2(.5, .5)); | |
100 %OptimizeFunctionOnNextCall(greater_equal_2); | |
101 assertTrue(greater_equal_2(.5, .5)); | |
102 assertFalse(greater_equal_2(.5, undefined)); | |
103 assertFalse(greater_equal_2(undefined, .5)); | |
104 assertFalse(greater_equal_2(undefined, undefined)); | |
105 | |
106 function equal_1(a, b) { | |
107 return a == b; | |
108 } | |
109 | |
110 assertTrue(equal_1(.5, .5)); | |
111 assertFalse(equal_1(.5, undefined)); | |
112 assertFalse(equal_1(undefined, .5)); | |
113 assertTrue(equal_1(undefined, undefined)); | |
114 | |
115 function equal_2(a, b) { | |
116 return a == b; | |
117 } | |
118 assertTrue(equal_2(.5, .5)); | |
119 %OptimizeFunctionOnNextCall(equal_2); | |
120 assertTrue(equal_2(.5, .5)); | |
121 assertFalse(equal_2(.5, undefined)); | |
122 assertFalse(equal_2(undefined, .5)); | |
123 assertTrue(equal_2(undefined, undefined)); | |
124 | |
125 function strict_equal_1(a, b) { | |
126 return a === b; | |
127 } | |
128 | |
129 assertTrue(strict_equal_1(.5, .5)); | |
130 assertFalse(strict_equal_1(.5, undefined)); | |
131 assertFalse(strict_equal_1(undefined, .5)); | |
132 assertTrue(strict_equal_1(undefined, undefined)); | |
133 | |
134 function strict_equal_2(a, b) { | |
135 return a === b; | |
136 } | |
137 assertTrue(strict_equal_2(.5, .5)); | |
138 %OptimizeFunctionOnNextCall(strict_equal_2); | |
139 assertTrue(strict_equal_2(.5, .5)); | |
140 assertFalse(strict_equal_2(.5, undefined)); | |
141 assertFalse(strict_equal_2(undefined, .5)); | |
142 assertTrue(strict_equal_2(undefined, undefined)); | |
143 | |
144 function not_equal_1(a, b) { | |
145 return a != b; | |
146 } | |
147 | |
148 assertFalse(not_equal_1(.5, .5)); | |
149 assertTrue(not_equal_1(.5, undefined)); | |
150 assertTrue(not_equal_1(undefined, .5)); | |
151 assertFalse(not_equal_1(undefined, undefined)); | |
152 | |
153 function not_equal_2(a, b) { | |
154 return a != b; | |
155 } | |
156 assertFalse(not_equal_1(.5, .5)); | |
157 %OptimizeFunctionOnNextCall(not_equal_2); | |
158 assertFalse(not_equal_1(.5, .5)); | |
159 assertTrue(not_equal_1(.5, undefined)); | |
160 assertTrue(not_equal_1(undefined, .5)); | |
161 assertFalse(not_equal_1(undefined, undefined)); | |
OLD | NEW |