]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/stress/poly-chain-then-setter.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / poly-chain-then-setter.js
CommitLineData
ed1e77d3
A
1function Cons1() {
2}
3Cons1.prototype.f = 42;
4
5function Cons2() {
6}
7Cons2.prototype.__defineSetter__("f", function(value) {
8 counter++;
9 this._f = value;
10});
11Cons2.prototype.__defineGetter__("f", function() { return this._f; });
12
13function foo(o, value) {
14 o.f = value;
15 return o.f;
16}
17
18noInline(foo);
19
20var counter = 0;
21
22function 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
30for (var i = 0; i < 100000; ++i) {
31 test(new Cons1(), i, counter);
32 test(new Cons2(), i, counter + 1);
33}