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