]>
Commit | Line | Data |
---|---|---|
ed1e77d3 A |
1 | var shouldThrow = false; |
2 | ||
3 | // str concat generates op_to_primitive. | |
4 | function toPrimitiveTarget() { | |
5 | if (shouldThrow) { | |
6 | return Symbol('Cocoa'); | |
7 | } | |
8 | return 'Cocoa'; | |
9 | } | |
10 | noInline(toPrimitiveTarget); | |
11 | ||
12 | function doToPrimitive() { | |
13 | var value = toPrimitiveTarget(); | |
14 | return value + "Cappuccino" + value; | |
15 | } | |
16 | noInline(doToPrimitive); | |
17 | ||
18 | for (var i = 0; i < 10000; ++i) { | |
19 | var result = doToPrimitive(); | |
20 | if (result !== "CocoaCappuccinoCocoa") | |
21 | throw "Error: bad result: " + result; | |
22 | } | |
23 | ||
24 | shouldThrow = true; | |
25 | ||
26 | var didThrow; | |
27 | try { | |
28 | shouldThrow = true; | |
29 | doToPrimitive(); | |
30 | } catch (e) { | |
31 | didThrow = e; | |
32 | } | |
33 | ||
34 | if (String(didThrow) !== "TypeError: Type error") | |
35 | throw "Error: didn't throw or threw wrong exception: " + didThrow; |