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 |
11 (function ImmutableClassBindings() { | 12 (function ImmutableClassBindings() { |
12 class D {} | 13 class D {} |
13 assertThrows(function(){ eval("C = 0") }, TypeError); | 14 assertThrows(function(){ eval("C = 0") }, TypeError); |
14 assertThrows(function(){ eval("D = 0") }, TypeError); | 15 assertThrows(function(){ eval("D = 0") }, TypeError); |
15 assertEquals('function', typeof C); | 16 assertEquals('function', typeof C); |
16 assertEquals('function', typeof D); | 17 assertEquals('function', typeof D); |
17 })(); | 18 })(); |
19 | |
20 function constructor(body) { | |
21 return "'use strong'; " + | |
22 "(class extends Object { constructor() { " + body + " } })"; | |
23 } | |
24 | |
25 (function NoMissingSuper() { | |
26 let bodies = [ | |
27 "", | |
28 "1;" | |
29 ]; | |
30 for (let b of bodies) assertThrows(constructor(b), SyntaxError); | |
marja
2015/03/13 15:21:20
Nit: this style of writing tests will give less us
| |
31 })(); | |
32 | |
33 (function NoNestedSuper() { | |
34 let bodies = [ | |
35 "(super())", | |
36 "(() => super())(); } })", | |
37 "{ super();", | |
38 "if (1) super();", | |
39 ]; | |
40 for (let b of bodies) assertThrows(constructor(b), SyntaxError); | |
41 })(); | |
42 | |
43 (function NoDuplicateSuper() { | |
44 let bodies = [ | |
45 "super(), super();", | |
46 "super(); super();", | |
47 "super(); (super());", | |
48 "super(); { super() }", | |
49 ]; | |
50 for (let b of bodies) assertThrows(constructor(b), SyntaxError); | |
51 })(); | |
OLD | NEW |