]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/poly-chain-then-getter.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / poly-chain-then-getter.js
1 function Cons1() {
2 }
3 Cons1.prototype.f = 42;
4
5 function Cons2() {
6 }
7 Cons2.prototype.__defineGetter__("f", function() {
8 counter++;
9 return 84;
10 });
11
12 function foo(o) {
13 return o.f;
14 }
15
16 noInline(foo);
17
18 var counter = 0;
19
20 function test(o, expected, expectedCount) {
21 var result = foo(o);
22 if (result != expected)
23 throw new Error("Bad result: " + result);
24 if (counter != expectedCount)
25 throw new Error("Bad counter value: " + counter);
26 }
27
28 for (var i = 0; i < 100000; ++i) {
29 test(new Cons1(), 42, counter);
30 test(new Cons2(), 84, counter + 1);
31 }