]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/is-undefined-exit-on-masquerader.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / is-undefined-exit-on-masquerader.js
1 var doMasquerading = false;
2
3 function bar(o) {
4 if (doMasquerading)
5 return makeMasquerader();
6 return o;
7 }
8
9 noInline(bar);
10
11 function foo(o) {
12 o = bar(o);
13 return typeof o === "undefined";
14 }
15
16 noInline(foo);
17
18 function test(o, expected) {
19 var result = foo(o);
20 if (result != expected)
21 throw new Error("bad result: " + result);
22 }
23
24 for (var i = 0; i < 10000; ++i) {
25 test(void 0, true);
26 test(null, false);
27 test(42, false);
28 test({}, false);
29 test("undefined", false);
30 }
31
32 doMasquerading = true;
33 test({}, true);