We should not keep the JavaScript tests inside the Source/JavaScriptCore/ directory.
[WebKit-https.git] / JSTests / stress / get-by-id-throw-from-unexpected-getter-through-optimized-code.js
1 function foo(o) {
2     return o.f + 1;
3 }
4
5 noInline(foo);
6
7 function makeWithGetter() {
8     var o = {};
9     o.__defineGetter__("f", function() {
10         throw "hello";
11     });
12     return o;
13 }
14
15 for (var i = 0; i < 100000; ++i) {
16     var result = foo({f:23});
17     if (result != 24)
18         throw "Error: bad result: " + result;
19     result = foo({g:12, f:13});
20     if (result != 14)
21         throw "Error: bad result: " + result;
22     result = foo({g:12, h:13, f:14});
23     if (result != 15)
24         throw "Error: bad result: " + result;
25 }
26
27 var didThrow;
28 try {
29     foo(makeWithGetter());
30 } catch (e) {
31     didThrow = e;
32 }
33
34 if (didThrow != "hello")
35     throw "Error: didn't throw or threw wrong exception: " + didThrow;