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