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