Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(554)

Side by Side Diff: test/mjsunit/strong/classes.js

Issue 1002253002: [strong] Check super constructor calls (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Typo Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« src/messages.js ('K') | « test/cctest/test-parsing.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 })();
OLDNEW
« src/messages.js ('K') | « test/cctest/test-parsing.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698