]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/stress/dfg-to-primitive-pass-symbol.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / dfg-to-primitive-pass-symbol.js
CommitLineData
ed1e77d3
A
1var shouldThrow = false;
2
3// str concat generates op_to_primitive.
4function toPrimitiveTarget() {
5 if (shouldThrow) {
6 return Symbol('Cocoa');
7 }
8 return 'Cocoa';
9}
10noInline(toPrimitiveTarget);
11
12function doToPrimitive() {
13 var value = toPrimitiveTarget();
14 return value + "Cappuccino" + value;
15}
16noInline(doToPrimitive);
17
18for (var i = 0; i < 10000; ++i) {
19 var result = doToPrimitive();
20 if (result !== "CocoaCappuccinoCocoa")
21 throw "Error: bad result: " + result;
22}
23
24shouldThrow = true;
25
26var didThrow;
27try {
28 shouldThrow = true;
29 doToPrimitive();
30} catch (e) {
31 didThrow = e;
32}
33
34if (String(didThrow) !== "TypeError: Type error")
35 throw "Error: didn't throw or threw wrong exception: " + didThrow;