]>
Commit | Line | Data |
---|---|---|
81345200 A |
1 | function foo(o, prototype) { |
2 | return o instanceof prototype; | |
3 | } | |
4 | ||
5 | noInline(foo); | |
6 | ||
7 | function test(o, prototype, expected) { | |
8 | var actual = foo(o, prototype); | |
9 | if (actual != expected) | |
10 | throw new Error("bad result: " + actual); | |
11 | } | |
12 | ||
13 | function Foo() { } | |
14 | ||
15 | function Bar() { } | |
16 | Bar.prototype = new Foo(); | |
17 | ||
18 | for (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 | } |