OLD | NEW |
| (Empty) |
1 // Copyright 2013 the V8 project authors. All rights reserved. | |
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | |
3 // | |
4 // Redistribution and use in source and binary forms, with or without | |
5 // modification, are permitted provided that the following conditions | |
6 // are met: | |
7 // 1. Redistributions of source code must retain the above copyright | |
8 // notice, this list of conditions and the following disclaimer. | |
9 // 2. Redistributions in binary form must reproduce the above copyright | |
10 // notice, this list of conditions and the following disclaimer in the | |
11 // documentation and/or other materials provided with the distribution. | |
12 // | |
13 // THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y | |
14 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
15 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
16 // DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y | |
17 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
18 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
19 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N | |
20 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
21 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
22 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
23 | |
24 description("KDE JS Test"); | |
25 function nonSpeculativeNotInner(argument, o1, o2) | |
26 { | |
27 // The + operator on objects is a reliable way to avoid the speculative JIT
path for now at least. | |
28 o1 + o2; | |
29 return !argument; | |
30 } | |
31 function nonSpeculativeNot(argument) | |
32 { | |
33 return nonSpeculativeNotInner(argument, {}, {}); | |
34 } | |
35 | |
36 function nonSpeculativeLessInner(a, b, o1, o2) | |
37 { | |
38 // The + operator on objects is a reliable way to avoid the speculative JIT
path for now at least. | |
39 o1 + o2; | |
40 return a < b; | |
41 } | |
42 function nonSpeculativeLess(a, b) | |
43 { | |
44 return nonSpeculativeLessInner(a, b, {}, {}); | |
45 } | |
46 | |
47 function nonSpeculativeLessEqInner(a, b, o1, o2) | |
48 { | |
49 // The + operator on objects is a reliable way to avoid the speculative JIT
path for now at least. | |
50 o1 + o2; | |
51 return a <= b; | |
52 } | |
53 function nonSpeculativeLessEq(a, b) | |
54 { | |
55 return nonSpeculativeLessEqInner(a, b, {}, {}); | |
56 } | |
57 | |
58 function nonSpeculativeGreaterInner(a, b, o1, o2) | |
59 { | |
60 // The + operator on objects is a reliable way to avoid the speculative JIT
path for now at least. | |
61 o1 + o2; | |
62 return a > b; | |
63 } | |
64 function nonSpeculativeGreater(a, b) | |
65 { | |
66 return nonSpeculativeGreaterInner(a, b, {}, {}); | |
67 } | |
68 | |
69 function nonSpeculativeGreaterEqInner(a, b, o1, o2) | |
70 { | |
71 // The + operator on objects is a reliable way to avoid the speculative JIT
path for now at least. | |
72 o1 + o2; | |
73 return a >= b; | |
74 } | |
75 function nonSpeculativeGreaterEq(a, b) | |
76 { | |
77 return nonSpeculativeGreaterEqInner(a, b, {}, {}); | |
78 } | |
79 | |
80 function nonSpeculativeEqualInner(a, b, o1, o2) | |
81 { | |
82 // The + operator on objects is a reliable way to avoid the speculative JIT
path for now at least. | |
83 o1 + o2; | |
84 return a == b; | |
85 } | |
86 function nonSpeculativeEqual(a, b) | |
87 { | |
88 return nonSpeculativeEqualInner(a, b, {}, {}); | |
89 } | |
90 | |
91 function nonSpeculativeNotEqualInner(a, b, o1, o2) | |
92 { | |
93 // The + operator on objects is a reliable way to avoid the speculative JIT
path for now at least. | |
94 o1 + o2; | |
95 return a != b; | |
96 } | |
97 function nonSpeculativeNotEqual(a, b) | |
98 { | |
99 return nonSpeculativeNotEqualInner(a, b, {}, {}); | |
100 } | |
101 | |
102 function nonSpeculativeStrictEqualInner(a, b, o1, o2) | |
103 { | |
104 // The + operator on objects is a reliable way to avoid the speculative JIT
path for now at least. | |
105 o1 + o2; | |
106 return a === b; | |
107 } | |
108 function nonSpeculativeStrictEqual(a, b) | |
109 { | |
110 return nonSpeculativeStrictEqualInner(a, b, {}, {}); | |
111 } | |
112 | |
113 function nonSpeculativeStrictNotEqualInner(a, b, o1, o2) | |
114 { | |
115 // The + operator on objects is a reliable way to avoid the speculative JIT
path for now at least. | |
116 o1 + o2; | |
117 return a !== b; | |
118 } | |
119 function nonSpeculativeStrictNotEqual(a, b) | |
120 { | |
121 return nonSpeculativeStrictNotEqualInner(a, b, {}, {}); | |
122 } | |
123 | |
124 // operator ! | |
125 shouldBeTrue("!undefined"); | |
126 shouldBeTrue("!null"); | |
127 shouldBeTrue("!!true"); | |
128 shouldBeTrue("!false"); | |
129 shouldBeTrue("!!1"); | |
130 shouldBeTrue("!0"); | |
131 shouldBeTrue("!!'a'"); | |
132 shouldBeTrue("!''"); | |
133 | |
134 shouldBeTrue("nonSpeculativeNot(undefined)"); | |
135 shouldBeTrue("nonSpeculativeNot(null)"); | |
136 shouldBeTrue("nonSpeculativeNot(!true)"); | |
137 shouldBeTrue("nonSpeculativeNot(false)"); | |
138 shouldBeTrue("nonSpeculativeNot(!1)"); | |
139 shouldBeTrue("nonSpeculativeNot(0)"); | |
140 shouldBeTrue("nonSpeculativeNot(!'a')"); | |
141 shouldBeTrue("nonSpeculativeNot('')"); | |
142 | |
143 // unary plus | |
144 shouldBe("+9", "9"); | |
145 shouldBe("var i = 10; +i", "10"); | |
146 | |
147 // negation | |
148 shouldBe("-11", "-11"); | |
149 shouldBe("var i = 12; -i", "-12"); | |
150 | |
151 // increment | |
152 shouldBe("var i = 0; ++i;", "1"); | |
153 shouldBe("var i = 0; ++i; i", "1"); | |
154 shouldBe("var i = 0; i++;", "0"); | |
155 shouldBe("var i = 0; i++; i", "1"); | |
156 shouldBe("var i = true; i++", "1"); | |
157 shouldBe("var i = true; i++; i", "2"); | |
158 | |
159 // decrement | |
160 shouldBe("var i = 0; --i;", "-1"); | |
161 shouldBe("var i = 0; --i; i", "-1"); | |
162 shouldBe("var i = 0; i--;", "0"); | |
163 shouldBe("var i = 0; i--; i", "-1"); | |
164 shouldBe("var i = true; i--", "1"); | |
165 shouldBe("var i = true; i--; i", "0"); | |
166 | |
167 // bitwise operators | |
168 shouldBe("~0", "-1"); | |
169 shouldBe("~1", "-2"); | |
170 shouldBe("~NaN", "-1"); | |
171 shouldBe("~Infinity", "-1"); | |
172 shouldBe("~Math.pow(2, 33)", "-1"); // 32 bit overflow | |
173 shouldBe("~(Math.pow(2, 32) + Math.pow(2, 31) + 2)", | |
174 "2147483645"); // a signedness issue | |
175 shouldBe("~null", "-1"); | |
176 shouldBe("3 & 1", "1"); | |
177 shouldBe("2 | true", "3"); | |
178 shouldBe("'3' ^ 1", "2"); | |
179 shouldBe("3^4&5", "7"); | |
180 shouldBe("2|4^5", "3"); | |
181 | |
182 shouldBe("1 << 2", "4"); | |
183 shouldBe("8 >> 1", "4"); | |
184 shouldBe("1 >> 2", "0"); | |
185 shouldBe("-8 >> 24", "-1"); | |
186 shouldBe("8 >>> 2", "2"); | |
187 shouldBe("-8 >>> 24", "255"); | |
188 shouldBe("(-2200000000 >> 1) << 1", "2094967296"); | |
189 shouldBe("Infinity >> 1", "0"); | |
190 shouldBe("Infinity << 1", "0"); | |
191 shouldBe("Infinity >>> 1", "0"); | |
192 shouldBe("NaN >> 1", "0"); | |
193 shouldBe("NaN << 1", "0"); | |
194 shouldBe("NaN >>> 1", "0"); | |
195 shouldBe("8.1 >> 1", "4"); | |
196 shouldBe("8.1 << 1", "16"); | |
197 shouldBe("8.1 >>> 1", "4"); | |
198 shouldBe("8.9 >> 1", "4"); | |
199 shouldBe("8.9 << 1", "16"); | |
200 shouldBe("8.9 >>> 1", "4"); | |
201 shouldBe("Math.pow(2, 32) >> 1", "0"); | |
202 shouldBe("Math.pow(2, 32) << 1", "0"); | |
203 shouldBe("Math.pow(2, 32) >>> 1", "0"); | |
204 | |
205 // Try shifting by variables, to test non-constant-folded cases. | |
206 var one = 1; | |
207 var two = 2; | |
208 var twentyFour = 24; | |
209 | |
210 shouldBe("1 << two", "4"); | |
211 shouldBe("8 >> one", "4"); | |
212 shouldBe("1 >> two", "0"); | |
213 shouldBe("-8 >> twentyFour", "-1"); | |
214 shouldBe("8 >>> two", "2"); | |
215 shouldBe("-8 >>> twentyFour", "255"); | |
216 shouldBe("(-2200000000 >> one) << one", "2094967296"); | |
217 shouldBe("Infinity >> one", "0"); | |
218 shouldBe("Infinity << one", "0"); | |
219 shouldBe("Infinity >>> one", "0"); | |
220 shouldBe("NaN >> one", "0"); | |
221 shouldBe("NaN << one", "0"); | |
222 shouldBe("NaN >>> one", "0"); | |
223 shouldBe("888.1 >> one", "444"); | |
224 shouldBe("888.1 << one", "1776"); | |
225 shouldBe("888.1 >>> one", "444"); | |
226 shouldBe("888.9 >> one", "444"); | |
227 shouldBe("888.9 << one", "1776"); | |
228 shouldBe("888.9 >>> one", "444"); | |
229 shouldBe("Math.pow(2, 32) >> one", "0"); | |
230 shouldBe("Math.pow(2, 32) << one", "0"); | |
231 shouldBe("Math.pow(2, 32) >>> one", "0"); | |
232 | |
233 // addition | |
234 shouldBe("1+2", "3"); | |
235 shouldBe("'a'+'b'", "'ab'"); | |
236 shouldBe("'a'+2", "'a2'"); | |
237 shouldBe("'2'+'-1'", "'2-1'"); | |
238 shouldBe("true+'a'", "'truea'"); | |
239 shouldBe("'a' + null", "'anull'"); | |
240 shouldBe("true+1", "2"); | |
241 shouldBe("false+null", "0"); | |
242 | |
243 // substraction | |
244 shouldBe("1-3", "-2"); | |
245 shouldBe("isNaN('a'-3)", "true"); | |
246 shouldBe("'3'-'-1'", "4"); | |
247 shouldBe("'4'-2", "2"); | |
248 shouldBe("true-false", "1"); | |
249 shouldBe("false-1", "-1"); | |
250 shouldBe("null-true", "-1"); | |
251 | |
252 // multiplication | |
253 shouldBe("2 * 3", "6"); | |
254 shouldBe("true * 3", "3"); | |
255 shouldBe("2 * '3'", "6"); | |
256 | |
257 // division | |
258 shouldBe("6 / 4", "1.5"); | |
259 //shouldBe("true / false", "Inf"); | |
260 shouldBe("'6' / '2'", "3"); | |
261 shouldBeTrue("isNaN('x' / 1)"); | |
262 shouldBeTrue("isNaN(1 / NaN)"); | |
263 shouldBeTrue("isNaN(Infinity / Infinity)"); | |
264 shouldBe("Infinity / 0", "Infinity"); | |
265 shouldBe("-Infinity / 0", "-Infinity"); | |
266 shouldBe("Infinity / 1", "Infinity"); | |
267 shouldBe("-Infinity / 1", "-Infinity"); | |
268 shouldBeTrue("1 / Infinity == +0"); | |
269 shouldBeTrue("1 / -Infinity == -0"); // how to check ? | |
270 shouldBeTrue("isNaN(0/0)"); | |
271 shouldBeTrue("0 / 1 === 0"); | |
272 shouldBeTrue("0 / -1 === -0"); // how to check ? | |
273 shouldBe("1 / 0", "Infinity"); | |
274 shouldBe("-1 / 0", "-Infinity"); | |
275 | |
276 // modulo | |
277 shouldBe("6 % 4", "2"); | |
278 shouldBe("'-6' % 4", "-2"); | |
279 | |
280 shouldBe("2==2", "true"); | |
281 shouldBe("1==2", "false"); | |
282 | |
283 shouldBe("nonSpeculativeEqual(2,2)", "true"); | |
284 shouldBe("nonSpeculativeEqual(1,2)", "false"); | |
285 | |
286 shouldBe("1<2", "true"); | |
287 shouldBe("1<=2", "true"); | |
288 shouldBe("2<1", "false"); | |
289 shouldBe("2<=1", "false"); | |
290 | |
291 shouldBe("nonSpeculativeLess(1,2)", "true"); | |
292 shouldBe("nonSpeculativeLessEq(1,2)", "true"); | |
293 shouldBe("nonSpeculativeLess(2,1)", "false"); | |
294 shouldBe("nonSpeculativeLessEq(2,1)", "false"); | |
295 | |
296 shouldBe("2>1", "true"); | |
297 shouldBe("2>=1", "true"); | |
298 shouldBe("1>=2", "false"); | |
299 shouldBe("1>2", "false"); | |
300 | |
301 shouldBe("nonSpeculativeGreater(2,1)", "true"); | |
302 shouldBe("nonSpeculativeGreaterEq(2,1)", "true"); | |
303 shouldBe("nonSpeculativeGreaterEq(1,2)", "false"); | |
304 shouldBe("nonSpeculativeGreater(1,2)", "false"); | |
305 | |
306 shouldBeTrue("'abc' == 'abc'"); | |
307 shouldBeTrue("'abc' != 'xyz'"); | |
308 shouldBeTrue("true == true"); | |
309 shouldBeTrue("false == false"); | |
310 shouldBeTrue("true != false"); | |
311 shouldBeTrue("'a' != null"); | |
312 shouldBeTrue("'a' != undefined"); | |
313 shouldBeTrue("null == null"); | |
314 shouldBeTrue("null == undefined"); | |
315 shouldBeTrue("undefined == undefined"); | |
316 shouldBeTrue("NaN != NaN"); | |
317 shouldBeTrue("true != undefined"); | |
318 shouldBeTrue("true != null"); | |
319 shouldBeTrue("false != undefined"); | |
320 shouldBeTrue("false != null"); | |
321 shouldBeTrue("'0' == 0"); | |
322 shouldBeTrue("1 == '1'"); | |
323 shouldBeTrue("NaN != NaN"); | |
324 shouldBeTrue("NaN != 0"); | |
325 shouldBeTrue("NaN != undefined"); | |
326 shouldBeTrue("true == 1"); | |
327 shouldBeTrue("true != 2"); | |
328 shouldBeTrue("1 == true"); | |
329 shouldBeTrue("false == 0"); | |
330 shouldBeTrue("0 == false"); | |
331 | |
332 shouldBeTrue("nonSpeculativeEqual('abc', 'abc')"); | |
333 shouldBeTrue("nonSpeculativeNotEqual('abc', 'xyz')"); | |
334 shouldBeTrue("nonSpeculativeEqual(true, true)"); | |
335 shouldBeTrue("nonSpeculativeEqual(false, false)"); | |
336 shouldBeTrue("nonSpeculativeNotEqual(true, false)"); | |
337 shouldBeTrue("nonSpeculativeNotEqual('a', null)"); | |
338 shouldBeTrue("nonSpeculativeNotEqual('a', undefined)"); | |
339 shouldBeTrue("nonSpeculativeEqual(null, null)"); | |
340 shouldBeTrue("nonSpeculativeEqual(null, undefined)"); | |
341 shouldBeTrue("nonSpeculativeEqual(undefined, undefined)"); | |
342 shouldBeTrue("nonSpeculativeNotEqual(NaN, NaN)"); | |
343 shouldBeTrue("nonSpeculativeNotEqual(true, undefined)"); | |
344 shouldBeTrue("nonSpeculativeNotEqual(true, null)"); | |
345 shouldBeTrue("nonSpeculativeNotEqual(false, undefined)"); | |
346 shouldBeTrue("nonSpeculativeNotEqual(false, null)"); | |
347 shouldBeTrue("nonSpeculativeEqual('0', 0)"); | |
348 shouldBeTrue("nonSpeculativeEqual(1, '1')"); | |
349 shouldBeTrue("nonSpeculativeNotEqual(NaN, NaN)"); | |
350 shouldBeTrue("nonSpeculativeNotEqual(NaN, 0)"); | |
351 shouldBeTrue("nonSpeculativeNotEqual(NaN, undefined)"); | |
352 shouldBeTrue("nonSpeculativeEqual(true, 1)"); | |
353 shouldBeTrue("nonSpeculativeNotEqual(true, 2)"); | |
354 shouldBeTrue("nonSpeculativeEqual(1, true)"); | |
355 shouldBeTrue("nonSpeculativeEqual(false, 0)"); | |
356 shouldBeTrue("nonSpeculativeEqual(0, false)"); | |
357 | |
358 shouldBe("'abc' < 'abx'", "true"); | |
359 shouldBe("'abc' < 'abcd'", "true"); | |
360 shouldBe("'abc' < 'abc'", "false"); | |
361 shouldBe("'abcd' < 'abcd'", "false"); | |
362 shouldBe("'abx' < 'abc'", "false"); | |
363 | |
364 shouldBe("nonSpeculativeLess('abc', 'abx')", "true"); | |
365 shouldBe("nonSpeculativeLess('abc', 'abcd')", "true"); | |
366 shouldBe("nonSpeculativeLess('abc', 'abc')", "false"); | |
367 shouldBe("nonSpeculativeLess('abcd', 'abcd')", "false"); | |
368 shouldBe("nonSpeculativeLess('abx', 'abc')", "false"); | |
369 | |
370 shouldBe("'abc' <= 'abc'", "true"); | |
371 shouldBe("'abc' <= 'abx'", "true"); | |
372 shouldBe("'abx' <= 'abc'", "false"); | |
373 shouldBe("'abcd' <= 'abc'", "false"); | |
374 shouldBe("'abc' <= 'abcd'", "true"); | |
375 | |
376 shouldBe("nonSpeculativeLessEq('abc', 'abc')", "true"); | |
377 shouldBe("nonSpeculativeLessEq('abc', 'abx')", "true"); | |
378 shouldBe("nonSpeculativeLessEq('abx', 'abc')", "false"); | |
379 shouldBe("nonSpeculativeLessEq('abcd', 'abc')", "false"); | |
380 shouldBe("nonSpeculativeLessEq('abc', 'abcd')", "true"); | |
381 | |
382 shouldBe("'abc' > 'abx'", "false"); | |
383 shouldBe("'abc' > 'abc'", "false"); | |
384 shouldBe("'abcd' > 'abc'", "true"); | |
385 shouldBe("'abx' > 'abc'", "true"); | |
386 shouldBe("'abc' > 'abcd'", "false"); | |
387 | |
388 shouldBe("nonSpeculativeGreater('abc', 'abx')", "false"); | |
389 shouldBe("nonSpeculativeGreater('abc', 'abc')", "false"); | |
390 shouldBe("nonSpeculativeGreater('abcd', 'abc')", "true"); | |
391 shouldBe("nonSpeculativeGreater('abx', 'abc')", "true"); | |
392 shouldBe("nonSpeculativeGreater('abc', 'abcd')", "false"); | |
393 | |
394 shouldBe("'abc' >= 'abc'", "true"); | |
395 shouldBe("'abcd' >= 'abc'", "true"); | |
396 shouldBe("'abx' >= 'abc'", "true"); | |
397 shouldBe("'abc' >= 'abx'", "false"); | |
398 shouldBe("'abc' >= 'abx'", "false"); | |
399 shouldBe("'abc' >= 'abcd'", "false"); | |
400 | |
401 shouldBe("nonSpeculativeGreaterEq('abc', 'abc')", "true"); | |
402 shouldBe("nonSpeculativeGreaterEq('abcd', 'abc')", "true"); | |
403 shouldBe("nonSpeculativeGreaterEq('abx', 'abc')", "true"); | |
404 shouldBe("nonSpeculativeGreaterEq('abc', 'abx')", "false"); | |
405 shouldBe("nonSpeculativeGreaterEq('abc', 'abx')", "false"); | |
406 shouldBe("nonSpeculativeGreaterEq('abc', 'abcd')", "false"); | |
407 | |
408 // mixed strings and numbers - results validated in NS+moz+IE5 | |
409 shouldBeFalse("'abc' <= 0"); // #35246 | |
410 shouldBeTrue("'' <= 0"); | |
411 shouldBeTrue("' ' <= 0"); | |
412 shouldBeTrue("null <= 0"); | |
413 shouldBeFalse("0 <= 'abc'"); | |
414 shouldBeTrue("0 <= ''"); | |
415 shouldBeTrue("0 <= null"); | |
416 shouldBeTrue("null <= null"); | |
417 shouldBeTrue("6 < '52'"); | |
418 shouldBeTrue("6 < '72'"); // #36087 | |
419 shouldBeFalse("NaN < 0"); | |
420 shouldBeFalse("NaN <= 0"); | |
421 shouldBeFalse("NaN > 0"); | |
422 shouldBeFalse("NaN >= 0"); | |
423 | |
424 shouldBeFalse("nonSpeculativeLessEq('abc', 0)"); // #35246 | |
425 shouldBeTrue("nonSpeculativeLessEq('', 0)"); | |
426 shouldBeTrue("nonSpeculativeLessEq(' ', 0)"); | |
427 shouldBeTrue("nonSpeculativeLessEq(null, 0)"); | |
428 shouldBeFalse("nonSpeculativeLessEq(0, 'abc')"); | |
429 shouldBeTrue("nonSpeculativeLessEq(0, '')"); | |
430 shouldBeTrue("nonSpeculativeLessEq(0, null)"); | |
431 shouldBeTrue("nonSpeculativeLessEq(null, null)"); | |
432 shouldBeTrue("nonSpeculativeLess(6, '52')"); | |
433 shouldBeTrue("nonSpeculativeLess(6, '72')"); // #36087 | |
434 shouldBeFalse("nonSpeculativeLess(NaN, 0)"); | |
435 shouldBeFalse("nonSpeculativeLessEq(NaN, 0)"); | |
436 shouldBeFalse("nonSpeculativeGreater(NaN, 0)"); | |
437 shouldBeFalse("nonSpeculativeGreaterEq(NaN, 0)"); | |
438 | |
439 // strict comparison === | |
440 shouldBeFalse("0 === false"); | |
441 //shouldBe("undefined === undefined", "true"); // aborts in IE5 (undefined is no
t defined ;) | |
442 shouldBeTrue("null === null"); | |
443 shouldBeFalse("NaN === NaN"); | |
444 shouldBeTrue("0.0 === 0"); | |
445 shouldBeTrue("'abc' === 'abc'"); | |
446 shouldBeFalse("'a' === 'x'"); | |
447 shouldBeFalse("1 === '1'"); | |
448 shouldBeFalse("'1' === 1"); | |
449 shouldBeTrue("true === true"); | |
450 shouldBeTrue("false === false"); | |
451 shouldBeFalse("true === false"); | |
452 shouldBeTrue("Math === Math"); | |
453 shouldBeFalse("Math === Boolean"); | |
454 shouldBeTrue("Infinity === Infinity"); | |
455 | |
456 // strict comparison === | |
457 shouldBeFalse("nonSpeculativeStrictEqual(0, false)"); | |
458 //shouldBe("undefined === undefined", "true"); // aborts in IE5 (undefined is no
t defined ;) | |
459 shouldBeTrue("nonSpeculativeStrictEqual(null, null)"); | |
460 shouldBeFalse("nonSpeculativeStrictEqual(NaN, NaN)"); | |
461 shouldBeTrue("nonSpeculativeStrictEqual(0.0, 0)"); | |
462 shouldBeTrue("nonSpeculativeStrictEqual('abc', 'abc')"); | |
463 shouldBeFalse("nonSpeculativeStrictEqual('a', 'x')"); | |
464 shouldBeFalse("nonSpeculativeStrictEqual(1, '1')"); | |
465 shouldBeFalse("nonSpeculativeStrictEqual('1', 1)"); | |
466 shouldBeTrue("nonSpeculativeStrictEqual(true, true)"); | |
467 shouldBeTrue("nonSpeculativeStrictEqual(false, false)"); | |
468 shouldBeFalse("nonSpeculativeStrictEqual(true, false)"); | |
469 shouldBeTrue("nonSpeculativeStrictEqual(Math, Math)"); | |
470 shouldBeFalse("nonSpeculativeStrictEqual(Math, Boolean)"); | |
471 shouldBeTrue("nonSpeculativeStrictEqual(Infinity, Infinity)"); | |
472 | |
473 // !== | |
474 shouldBe("0 !== 0", "false"); | |
475 shouldBe("0 !== 1", "true"); | |
476 | |
477 // !== | |
478 shouldBe("nonSpeculativeStrictNotEqual(0, 0)", "false"); | |
479 shouldBe("nonSpeculativeStrictNotEqual(0, 1)", "true"); | |
480 | |
481 shouldBe("typeof undefined", "'undefined'"); | |
482 shouldBe("typeof null", "'object'"); | |
483 shouldBe("typeof true", "'boolean'"); | |
484 shouldBe("typeof false", "'boolean'"); | |
485 shouldBe("typeof 1", "'number'"); | |
486 shouldBe("typeof 'a'", "'string'"); | |
487 shouldBe("typeof shouldBe", "'function'"); | |
488 shouldBe("typeof Number.NaN", "'number'"); | |
489 | |
490 shouldBe("11 && 22", "22"); | |
491 shouldBe("null && true", "null"); | |
492 shouldBe("11 || 22", "11"); | |
493 shouldBe("null || 'a'", "'a'"); | |
494 | |
495 shouldBeUndefined("void 1"); | |
496 | |
497 shouldBeTrue("1 in [1, 2]"); | |
498 shouldBeFalse("3 in [1, 2]"); | |
499 shouldBeTrue("'a' in { a:1, b:2 }"); | |
500 | |
501 // instanceof | |
502 // Those 2 lines don't parse in Netscape... | |
503 shouldBe("(new Boolean()) instanceof Boolean", "true"); | |
504 shouldBe("(new Boolean()) instanceof Number", "false"); | |
OLD | NEW |