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