]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/weird-setter-counter.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / weird-setter-counter.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 o.__defineSetter__("f", function(value) {
21 counter++;
22 this._f = value;
23 });
24 o.__defineGetter__("f", function() { return this._f; });
25 test(o, i, counter + 1);
26 }