]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/equals-masquerader.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / equals-masquerader.js
1 function equalsNull(o) {
2 return o == null;
3 }
4
5 noInline(equalsNull);
6
7 function notEqualsNull(o) {
8 return o != null;
9 }
10
11 noInline(notEqualsNull);
12
13 function strictEqualsNull(o) {
14 return o === null;
15 }
16
17 noInline(strictEqualsNull);
18
19 function strictNotEqualsNull(o) {
20 return o !== null;
21 }
22
23 noInline(strictNotEqualsNull);
24
25 function equalsUndefined(o) {
26 return o == void 0;
27 }
28
29 noInline(equalsUndefined);
30
31 function notEqualsUndefined(o) {
32 return o != void 0;
33 }
34
35 noInline(notEqualsUndefined);
36
37 function strictEqualsUndefined(o) {
38 return o === void 0;
39 }
40
41 noInline(strictEqualsUndefined);
42
43 function strictNotEqualsUndefined(o) {
44 return o !== void 0;
45 }
46
47 noInline(strictNotEqualsNull);
48
49 function isFalsey(o) {
50 return !o;
51 }
52
53 noInline(isFalsey);
54
55 function test(func, iteration, object, outcome) {
56 var result = func(object);
57 if (result != outcome)
58 throw new Error("Bad result: " + result + " on iteration " + iteration);
59 }
60
61 for (var i = 0; i < 10000; ++i) {
62 test(equalsNull, i, null, true);
63 test(equalsNull, i, undefined, true);
64 test(equalsNull, i, void 0, true);
65 test(equalsNull, i, {}, false);
66 test(equalsNull, i, makeMasquerader(), true);
67 }
68
69 for (var i = 0; i < 10000; ++i) {
70 test(notEqualsNull, i, null, false);
71 test(notEqualsNull, i, undefined, false);
72 test(notEqualsNull, i, void 0, false);
73 test(notEqualsNull, i, {}, true);
74 test(notEqualsNull, i, makeMasquerader(), false);
75 }
76
77 for (var i = 0; i < 10000; ++i) {
78 test(strictEqualsNull, i, null, true);
79 test(strictEqualsNull, i, undefined, false);
80 test(strictEqualsNull, i, void 0, false);
81 test(strictEqualsNull, i, {}, false);
82 test(strictEqualsNull, i, makeMasquerader(), false);
83 }
84
85 for (var i = 0; i < 10000; ++i) {
86 test(strictNotEqualsNull, i, null, false);
87 test(strictNotEqualsNull, i, undefined, true);
88 test(strictNotEqualsNull, i, void 0, true);
89 test(strictNotEqualsNull, i, {}, true);
90 test(strictNotEqualsNull, i, makeMasquerader(), true);
91 }
92
93 for (var i = 0; i < 10000; ++i) {
94 test(equalsUndefined, i, null, true);
95 test(equalsUndefined, i, undefined, true);
96 test(equalsUndefined, i, void 0, true);
97 test(equalsUndefined, i, {}, false);
98 test(equalsUndefined, i, makeMasquerader(), true);
99 }
100
101 for (var i = 0; i < 10000; ++i) {
102 test(notEqualsUndefined, i, null, false);
103 test(notEqualsUndefined, i, undefined, false);
104 test(notEqualsUndefined, i, void 0, false);
105 test(notEqualsUndefined, i, {}, true);
106 test(notEqualsUndefined, i, makeMasquerader(), false);
107 }
108
109 for (var i = 0; i < 10000; ++i) {
110 test(strictEqualsUndefined, i, null, false);
111 test(strictEqualsUndefined, i, undefined, true);
112 test(strictEqualsUndefined, i, void 0, true);
113 test(strictEqualsUndefined, i, {}, false);
114 test(strictEqualsUndefined, i, makeMasquerader(), false);
115 }
116
117 for (var i = 0; i < 10000; ++i) {
118 test(strictNotEqualsUndefined, i, null, true);
119 test(strictNotEqualsUndefined, i, undefined, false);
120 test(strictNotEqualsUndefined, i, void 0, false);
121 test(strictNotEqualsUndefined, i, {}, true);
122 test(strictNotEqualsUndefined, i, makeMasquerader(), true);
123 }
124
125 for (var i = 0; i < 10000; ++i) {
126 test(isFalsey, i, null, true);
127 test(isFalsey, i, undefined, true);
128 test(isFalsey, i, void 0, true);
129 test(isFalsey, i, {}, false);
130 test(isFalsey, i, makeMasquerader(), true);
131 }