]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/ic-throw-through-optimized-code.js
96404264a403690fb599f1609b09be9b53b3405a
[apple/javascriptcore.git] / tests / stress / ic-throw-through-optimized-code.js
1 function foo(o) {
2 return o.f + 1;
3 }
4
5 Number.prototype.f = 42;
6
7 noInline(foo);
8
9 for (var i = 0; i < 100000; ++i) {
10 var result = foo(23);
11 if (result != 43)
12 throw "Error: bad result: " + result;
13 result = foo({f:25});
14 if (result != 26)
15 throw "Error: bad result: " + result;
16 result = foo({g:12, f:13});
17 if (result != 14)
18 throw "Error: bad result: " + result;
19 }
20
21 var didThrow;
22 try {
23 foo(void 0);
24 } catch (e) {
25 didThrow = e;
26 }
27
28 if (!didThrow || didThrow.toString().indexOf("TypeError:") != 0)
29 throw "Error: didn't throw or threw wrong exception: " + didThrow;