]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/weird-getter-counter.js
ff9433447b453dd8371ca0feb8625b86dda4a0e2
[apple/javascriptcore.git] / tests / stress / weird-getter-counter.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 for (var i = 0; i < 100000; ++i) {
18 var o = {};
19 o.__defineGetter__("f", function() {
20 counter++;
21 return 84;
22 });
23 test(o, 84, counter + 1);
24 }