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