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

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

Issue 1059273004: [strong] Implement static restrictions on direct eval (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: new parser synch tests Created 5 years, 8 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/cctest/test-parsing.cc ('k') | test/mjsunit/strong/declaration-after-use.js » ('j') | 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 // 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 ind_eval = eval;
rossberg 2015/04/13 16:32:26 Nit: indirect_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(){ ind_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);
22 })(); 23 })();
23 24
25 assertTypeError("'use strong'; (function f() {class E {}; E = 0})()");
rossberg 2015/04/13 16:32:26 Nit: move that inside the test function
26
24 function constructor(body) { 27 function constructor(body) {
25 return "'use strong'; " + 28 return "'use strong'; " +
26 "(class extends Object { constructor() { " + body + " } })"; 29 "(class extends Object { constructor() { " + body + " } })";
27 } 30 }
28 31
29 (function NoMissingSuper() { 32 (function NoMissingSuper() {
30 assertReferenceError(constructor("")); 33 assertReferenceError(constructor(""));
31 assertReferenceError(constructor("1")); 34 assertReferenceError(constructor("1"));
32 })(); 35 })();
33 36
(...skipping 17 matching lines...) Expand all
51 assertSyntaxError(constructor("return undefined;")); 54 assertSyntaxError(constructor("return undefined;"));
52 assertSyntaxError(constructor("{ return {}; }")); 55 assertSyntaxError(constructor("{ return {}; }"));
53 assertSyntaxError(constructor("if (1) return {};")); 56 assertSyntaxError(constructor("if (1) return {};"));
54 })(); 57 })();
55 58
56 (function NoReturnBeforeSuper() { 59 (function NoReturnBeforeSuper() {
57 assertSyntaxError(constructor("return; super();")); 60 assertSyntaxError(constructor("return; super();"));
58 assertSyntaxError(constructor("if (0) return; super();")); 61 assertSyntaxError(constructor("if (0) return; super();"));
59 assertSyntaxError(constructor("{ return; } super();")); 62 assertSyntaxError(constructor("{ return; } super();"));
60 })(); 63 })();
OLDNEW
« no previous file with comments | « test/cctest/test-parsing.cc ('k') | test/mjsunit/strong/declaration-after-use.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698