| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Flags: --strong-mode | 5 // Flags: --strong-mode |
| 6 // Flags: --harmony-classes --harmony-arrow-functions | 6 // Flags: --harmony-classes --harmony-arrow-functions |
| 7 | 7 |
| 8 'use strong'; | 8 'use strong'; |
| 9 | 9 |
| 10 class C {} | 10 class C {} |
| 11 | 11 |
| 12 let indirect_eval = eval; |
| 13 |
| 12 function assertTypeError(script) { assertThrows(script, TypeError) } | 14 function assertTypeError(script) { assertThrows(script, TypeError) } |
| 13 function assertSyntaxError(script) { assertThrows(script, SyntaxError) } | 15 function assertSyntaxError(script) { assertThrows(script, SyntaxError) } |
| 14 function assertReferenceError(script) { assertThrows(script, ReferenceError) } | 16 function assertReferenceError(script) { assertThrows(script, ReferenceError) } |
| 15 | 17 |
| 16 (function ImmutableClassBindings() { | 18 (function ImmutableClassBindings() { |
| 17 class D {} | 19 class D {} |
| 18 assertTypeError(function(){ eval("C = 0") }); | 20 assertTypeError(function(){ indirect_eval("C = 0") }); |
| 19 assertTypeError(function(){ eval("D = 0") }); | |
| 20 assertEquals('function', typeof C); | 21 assertEquals('function', typeof C); |
| 21 assertEquals('function', typeof D); | 22 assertEquals('function', typeof D); |
| 23 assertTypeError("'use strong'; (function f() {class E {}; E = 0})()"); |
| 22 })(); | 24 })(); |
| 23 | 25 |
| 24 function constructor(body) { | 26 function constructor(body) { |
| 25 return "'use strong'; " + | 27 return "'use strong'; " + |
| 26 "(class extends Object { constructor() { " + body + " } })"; | 28 "(class extends Object { constructor() { " + body + " } })"; |
| 27 } | 29 } |
| 28 | 30 |
| 29 (function NoMissingSuper() { | 31 (function NoMissingSuper() { |
| 30 assertReferenceError(constructor("")); | 32 assertReferenceError(constructor("")); |
| 31 assertReferenceError(constructor("1")); | 33 assertReferenceError(constructor("1")); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 51 assertSyntaxError(constructor("return undefined;")); | 53 assertSyntaxError(constructor("return undefined;")); |
| 52 assertSyntaxError(constructor("{ return {}; }")); | 54 assertSyntaxError(constructor("{ return {}; }")); |
| 53 assertSyntaxError(constructor("if (1) return {};")); | 55 assertSyntaxError(constructor("if (1) return {};")); |
| 54 })(); | 56 })(); |
| 55 | 57 |
| 56 (function NoReturnBeforeSuper() { | 58 (function NoReturnBeforeSuper() { |
| 57 assertSyntaxError(constructor("return; super();")); | 59 assertSyntaxError(constructor("return; super();")); |
| 58 assertSyntaxError(constructor("if (0) return; super();")); | 60 assertSyntaxError(constructor("if (0) return; super();")); |
| 59 assertSyntaxError(constructor("{ return; } super();")); | 61 assertSyntaxError(constructor("{ return; } super();")); |
| 60 })(); | 62 })(); |
| OLD | NEW |