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