]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/capture-escape-and-throw.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / capture-escape-and-throw.js
1 var f;
2
3 function foo(s) {
4 var x = 1;
5 f = function() { return x; };
6 x = 2;
7 new Array(s);
8 x = 3;
9 }
10
11 noInline(foo);
12
13 for (var i = 0; i < 10000; ++i)
14 foo(1);
15
16 var didThrow = false;
17 try {
18 foo(-1);
19 } catch (e) {
20 didThrow = e;
21 }
22
23 if (("" + didThrow).indexOf("RangeError") != 0)
24 throw "Error: did not throw right exception: " + didThrow;
25
26 var result = f();
27 if (result != 2)
28 throw "Error: bad result from f(): " + result;