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

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

Issue 1773653002: [strong] Remove all remainders of strong mode (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Oversight Created 4 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
« no previous file with comments | « test/mjsunit/strong/class-object-frozen.js ('k') | test/mjsunit/strong/delete.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Flags: --strong-mode
6
7 'use strong';
8
9 class C {}
10
11 let indirect_eval = eval;
12
13 function assertTypeError(script) { assertThrows(script, TypeError) }
14 function assertSyntaxError(script) { assertThrows(script, SyntaxError) }
15 function assertReferenceError(script) { assertThrows(script, ReferenceError) }
16
17 (function ImmutableClassBindings() {
18 class D {}
19 assertTypeError(function(){ indirect_eval("C = 0") });
20 assertEquals('function', typeof C);
21 assertEquals('function', typeof D);
22 assertTypeError("'use strong'; (function f() {class E {}; E = 0})()");
23 })();
24
25 function constructor(body) {
26 return "'use strong'; " +
27 "(class extends Object { constructor() { " + body + " } })";
28 }
29
30 (function NoSuperExceptCall() {
31 assertSyntaxError(constructor("super.a;"));
32 assertSyntaxError(constructor("super['a'];"));
33 assertSyntaxError(constructor("super.f();"));
34 assertSyntaxError(constructor("super.a;"));
35 assertSyntaxError(constructor("{ super.a }"));
36 assertSyntaxError(constructor("if (0) super.a;"));
37 // TODO(rossberg): arrow functions do not handle 'super' yet.
38 // assertSyntaxError(constructor("() => super.a;"));
39 // assertSyntaxError(constructor("() => () => super.a;"));
40 // assertSyntaxError(constructor("() => { () => if (0) { super.a; } }"));
41 })();
42
43 (function NoMissingSuper() {
44 assertReferenceError(constructor(""));
45 assertReferenceError(constructor("1"));
46 })();
47
48 (function NoNestedSuper() {
49 assertSyntaxError(constructor("super(), 0;"));
50 assertSyntaxError(constructor("(super());"));
51 assertSyntaxError(constructor("super().a;"));
52 assertSyntaxError(constructor("(() => super())();"));
53 assertSyntaxError(constructor("{ super(); }"));
54 assertSyntaxError(constructor("if (1) super();"));
55 assertSyntaxError(constructor("label: super();"));
56 })();
57
58 (function NoDuplicateSuper() {
59 assertSyntaxError(constructor("super(), super();"));
60 assertSyntaxError(constructor("super(); super();"));
61 assertSyntaxError(constructor("super(); (super());"));
62 assertSyntaxError(constructor("super(); { super() }"));
63 assertSyntaxError(constructor("super(); (() => super())();"));
64 })();
65
66 (function NoSuperAfterThis() {
67 assertSyntaxError(constructor("this.a = 0, super();"));
68 assertSyntaxError(constructor("this.a = 0; super();"));
69 assertSyntaxError(constructor("this.a = 0; super(); this.b = 0;"));
70 assertSyntaxError(constructor("this.a = 0; (super());"));
71 assertSyntaxError(constructor("super(this.a = 0);"));
72 })();
73
74 (function NoReturnValue() {
75 assertSyntaxError(constructor("return {};"));
76 assertSyntaxError(constructor("return undefined;"));
77 assertSyntaxError(constructor("return this;"));
78 assertSyntaxError(constructor("return this.a = 0;"));
79 assertSyntaxError(constructor("{ return {}; }"));
80 assertSyntaxError(constructor("if (1) return {};"));
81 })();
82
83 (function NoReturnBeforeSuper() {
84 assertSyntaxError(constructor("return; super();"));
85 assertSyntaxError(constructor("if (0) return; super();"));
86 assertSyntaxError(constructor("{ return; } super();"));
87 })();
88
89 (function NoReturnBeforeThis() {
90 assertSyntaxError(constructor("return; this.a = 0;"));
91 assertSyntaxError(constructor("if (0) return; this.a = 0;"));
92 assertSyntaxError(constructor("{ return; } this.a = 0;"));
93 })();
94
95 (function NoThisExceptInitialization() {
96 assertSyntaxError(constructor("this;"));
97 assertSyntaxError(constructor("this.a;"));
98 assertSyntaxError(constructor("this['a'];"));
99 assertSyntaxError(constructor("this();"));
100 assertSyntaxError(constructor("this.a();"));
101 assertSyntaxError(constructor("this.a.b = 0;"));
102 assertSyntaxError(constructor("{ this }"));
103 assertSyntaxError(constructor("if (0) this;"));
104 // TODO(rossberg): this does not handle arrow functions yet.
105 // assertSyntaxError(constructor("() => this;"));
106 // assertSyntaxError(constructor("() => () => this;"));
107 // assertSyntaxError(constructor("() => { () => if (0) { this; } }"));
108 })();
109
110 (function NoNestedThis() {
111 assertSyntaxError(constructor("(this.a = 0);"));
112 assertSyntaxError(constructor("{ this.a = 0; }"));
113 assertSyntaxError(constructor("if (0) this.a = 0;"));
114 // TODO(rossberg): this does not handle arrow functions yet.
115 // assertSyntaxError(constructor("() => this.a = 0;"));
116 // assertSyntaxError(constructor("() => { this.a = 0; }"));
117 assertSyntaxError(constructor("label: this.a = 0;"));
118 })();
OLDNEW
« no previous file with comments | « test/mjsunit/strong/class-object-frozen.js ('k') | test/mjsunit/strong/delete.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698