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 | 7 |
7 'use strong'; | 8 'use strong'; |
8 | 9 |
9 class C {} | 10 class C {} |
10 | 11 |
| 12 function assertTypeError(script) { assertThrows(script, TypeError) } |
| 13 function assertSyntaxError(script) { assertThrows(script, SyntaxError) } |
| 14 function assertReferenceError(script) { assertThrows(script, ReferenceError) } |
| 15 |
11 (function ImmutableClassBindings() { | 16 (function ImmutableClassBindings() { |
12 class D {} | 17 class D {} |
13 assertThrows(function(){ eval("C = 0") }, TypeError); | 18 assertTypeError(function(){ eval("C = 0") }); |
14 assertThrows(function(){ eval("D = 0") }, TypeError); | 19 assertTypeError(function(){ eval("D = 0") }); |
15 assertEquals('function', typeof C); | 20 assertEquals('function', typeof C); |
16 assertEquals('function', typeof D); | 21 assertEquals('function', typeof D); |
17 })(); | 22 })(); |
| 23 |
| 24 function constructor(body) { |
| 25 return "'use strong'; " + |
| 26 "(class extends Object { constructor() { " + body + " } })"; |
| 27 } |
| 28 |
| 29 (function NoMissingSuper() { |
| 30 assertReferenceError(constructor("")); |
| 31 assertReferenceError(constructor("1")); |
| 32 })(); |
| 33 |
| 34 (function NoNestedSuper() { |
| 35 assertSyntaxError(constructor("(super())")); |
| 36 assertSyntaxError(constructor("(() => super())(); } })")); |
| 37 assertSyntaxError(constructor("{ super();")); |
| 38 assertSyntaxError(constructor("if (1) super();")); |
| 39 })(); |
| 40 |
| 41 (function NoDuplicateSuper() { |
| 42 assertSyntaxError(constructor("super(), super();")); |
| 43 assertSyntaxError(constructor("super(); super();")); |
| 44 assertSyntaxError(constructor("super(); (super());")); |
| 45 assertSyntaxError(constructor("super(); { super() }")); |
| 46 })(); |
OLD | NEW |