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