]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/runtime-throw-through-optimized-code.js
1d9df1ddfbc527f707ac72fb0d53608dd6b6f198
[apple/javascriptcore.git] / tests / stress / runtime-throw-through-optimized-code.js
1 function foo(a, s) {
2 return a[s] + 1;
3 }
4
5 var shouldThrow = false;
6 function bar() {
7 if (shouldThrow)
8 throw "hello";
9 return 42;
10 }
11
12 var a = {};
13 a.__defineGetter__("bar", bar);
14
15 noInline(foo);
16 noInline(bar);
17
18 for (var i = 0; i < 100000; ++i) {
19 var result = foo(a, "bar");
20 if (result != 43)
21 throw "Error: bad result: " + result;
22 }
23
24 var didThrow;
25 try {
26 shouldThrow = true;
27 foo(a, "bar");
28 } catch (e) {
29 didThrow = e;
30 }
31
32 if (didThrow != "hello")
33 throw "Error: didn't throw or threw wrong exception: " + didThrow;