]>
Commit | Line | Data |
---|---|---|
ed1e77d3 A |
1 | function Cons() { |
2 | } | |
3 | Cons.prototype.__defineSetter__("f", function(value) { | |
4 | counter++; | |
5 | this._f = value; | |
6 | }); | |
7 | Cons.prototype.__defineGetter__("f", function() { return this._f; }); | |
8 | ||
9 | function foo(o, v) { | |
10 | o.f = v; | |
11 | return o.f; | |
12 | } | |
13 | ||
14 | noInline(foo); | |
15 | ||
16 | var counter = 0; | |
17 | ||
18 | function 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 | ||
26 | for (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 | } |