Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: test/mjsunit/undetectable-compare.js

Issue 1132303003: Add %GetUndetectable() test intrinsic and add tests for undetectables. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/undetectable.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Flags: --allow-natives-syntax
6
7 var undetectable = %GetUndetectable();
8
9 var tests = [
10 true, false,
11 false, false,
12 null, true,
13 void 0, true,
14 0, false,
15 0.0, false,
16 -0, false,
17 "", false,
18 -1, false,
19 -1.25, false,
20 1, false,
21 1.25, false,
22 -2147483648, false,
23 2147483648, false,
24 Infinity, false,
25 -Infinity, false,
26 NaN, false
27 ];
28
29 var func = (function eq(a) { return a == undetectable; });
30 var left_funcs = [
31 (function eq_L0() { return true == undetectable; }),
32 (function eq_L1() { return false == undetectable; }),
33 (function eq_L2() { return null == undetectable; }),
34 (function eq_L3() { return void 0 == undetectable; }),
35 (function eq_L4() { return 0 == undetectable; }),
36 (function eq_L5() { return 0.0 == undetectable; }),
37 (function eq_L6() { return -0 == undetectable; }),
38 (function eq_L7() { return "" == undetectable; }),
39 (function eq_L8() { return -1 == undetectable; }),
40 (function eq_L9() { return -1.25 == undetectable; }),
41 (function eq_L10() { return 1 == undetectable; }),
42 (function eq_L11() { return 1.25 == undetectable; }),
43 (function eq_L12() { return -2147483648 == undetectable; }),
44 (function eq_L13() { return 2147483648 == undetectable; }),
45 (function eq_L14() { return Infinity == undetectable; }),
46 (function eq_L15() { return -Infinity == undetectable; }),
47 (function eq_L16() { return NaN == undetectable; })
48 ];
49
50 var right_funcs = [
51 (function eq_R0() { return undetectable == true; }),
52 (function eq_R1() { return undetectable == false; }),
53 (function eq_R2() { return undetectable == null; }),
54 (function eq_R3() { return undetectable == void 0; }),
55 (function eq_R4() { return undetectable == 0; }),
56 (function eq_R5() { return undetectable == 0.0; }),
57 (function eq_R6() { return undetectable == -0; }),
58 (function eq_R7() { return undetectable == ""; }),
59 (function eq_R8() { return undetectable == -1; }),
60 (function eq_R9() { return undetectable == -1.25; }),
61 (function eq_R10() { return undetectable == 1; }),
62 (function eq_R11() { return undetectable == 1.25; }),
63 (function eq_R12() { return undetectable == -2147483648; }),
64 (function eq_R13() { return undetectable == 2147483648; }),
65 (function eq_R14() { return undetectable == Infinity; }),
66 (function eq_R15() { return undetectable == -Infinity; }),
67 (function eq_R16() { return undetectable == NaN; })
68 ];
69
70 function test() {
71 for (var i = 0; i < tests.length; i += 2) {
72 var val = tests[i];
73 var eq = tests[i + 1];
74
75 assertEquals(eq, val == undetectable);
76 assertEquals(eq, undetectable == val);
77
78 assertFalse(val === undetectable);
79 assertFalse(undetectable === val);
80
81 assertEquals(eq, left_funcs[i/2]());
82 assertEquals(eq, right_funcs[i/2]());
83 }
84
85 assertTrue(undetectable == undetectable);
86 assertTrue(undetectable === undetectable);
87
88 }
89
90 for (var i = 0; i < 5; i++) {
91 test();
92 }
93
94
95 assertFalse(undetectable == %GetUndetectable());
96 assertFalse(undetectable === %GetUndetectable());
OLDNEW
« no previous file with comments | « test/mjsunit/undetectable.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698