]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/stress/instanceof-not-cell.js
JavaScriptCore-7600.1.4.15.12.tar.gz
[apple/javascriptcore.git] / tests / stress / instanceof-not-cell.js
CommitLineData
81345200
A
1function foo(o, prototype) {
2 return o instanceof prototype;
3}
4
5noInline(foo);
6
7function test(o, prototype, expected) {
8 var actual = foo(o, prototype);
9 if (actual != expected)
10 throw new Error("bad result: " + actual);
11}
12
13function Foo() { }
14
15function Bar() { }
16Bar.prototype = new Foo();
17
18for (var i = 0; i < 10000; ++i) {
19 test(42, Object, false);
20 test(42, Array, false);
21 test(42, String, false);
22 test(42, Foo, false);
23 test(42, Bar, false);
24 test({}, Object, true);
25 test({}, Array, false);
26 test({}, String, false);
27 test({}, Foo, false);
28 test({}, Bar, false);
29 test([], Object, true);
30 test([], Array, true);
31 test([], String, false);
32 test([], Foo, false);
33 test([], Bar, false);
34 test(new Foo(), Object, true);
35 test(new Foo(), Array, false);
36 test(new Foo(), String, false);
37 test(new Foo(), Foo, true);
38 test(new Foo(), Bar, false);
39 test(new Bar(), Object, true);
40 test(new Bar(), Array, false);
41 test(new Bar(), String, false);
42 test(new Bar(), Foo, true);
43 test(new Bar(), Bar, true);
44}