utatane.tea@gmail.com | 94099c3 | 2016-04-30 20:05:13 +0000 | [diff] [blame] | 1 | function testSyntaxError(script, message) { |
| 2 | var error = null; |
| 3 | try { |
| 4 | eval(script); |
| 5 | } catch (e) { |
| 6 | error = e; |
| 7 | } |
| 8 | if (!error) |
| 9 | throw new Error("Expected syntax error not thrown"); |
| 10 | |
| 11 | if (String(error) !== message) |
| 12 | throw new Error("Bad error: " + String(error)); |
| 13 | } |
| 14 | |
| 15 | |
| 16 | testSyntaxError(` |
| 17 | function f() |
| 18 | { |
| 19 | ({v = (typeof new.target)} = {}) |
| 20 | } |
| 21 | `, `SyntaxError: Unexpected token '='. Expected a ':' following the property name 'v'.`); |