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

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

Issue 1060883004: [strong] Implement static restrictions on binding 'undefined' in arrow functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: linebreak 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') | 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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 --harmony-sloppy --harmony-arrow-functions 5 // Flags: --strong-mode --harmony-sloppy --harmony-arrow-functions
6 6
7 // Repurposing the strict mode 'eval' and 'arguments' tests to test for correct 7 // Repurposing the strict mode 'eval' and 'arguments' tests to test for correct
8 // behaviour of 'undefined' as an identifier in strong mode. 8 // behaviour of 'undefined' as an identifier in strong mode.
9 "use strict"; 9 "use strict";
10 10
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 SyntaxError); 100 SyntaxError);
101 101
102 //Object literal method 102 //Object literal method
103 CheckStrongMode("({ foo(a, b, undefined, c, d) {} });"); 103 CheckStrongMode("({ foo(a, b, undefined, c, d) {} });");
104 assertThrows("({ foo(a, b, undefined, c, d) {'use strong';} });", SyntaxError); 104 assertThrows("({ foo(a, b, undefined, c, d) {'use strong';} });", SyntaxError);
105 105
106 //Object literal generator method 106 //Object literal generator method
107 CheckStrongMode("({ *foo(a, b, undefined, c, d) {} });"); 107 CheckStrongMode("({ *foo(a, b, undefined, c, d) {} });");
108 assertThrows("({ *foo(a, b, undefined, c, d) {'use strong';} });", SyntaxError); 108 assertThrows("({ *foo(a, b, undefined, c, d) {'use strong';} });", SyntaxError);
109 109
110 // Arrow function expression with 'undefined' param
111 // TODO(conradw): Checking arrow function heads is hard to modify just now
112 // CheckStrongMode("(undefined => {})");
113 // assertThrows("(undefined => {'use strong';})");
114
115 // Class declaration named 'undefined' 110 // Class declaration named 'undefined'
116 CheckStrongMode("class undefined {}"); 111 CheckStrongMode("class undefined {}");
117 assertThrows("class undefined {'use strong'}", SyntaxError); 112 assertThrows("class undefined {'use strong'}", SyntaxError);
118 113
119 // Class expression named 'undefined' 114 // Class expression named 'undefined'
120 CheckStrongMode("(class undefined {});"); 115 CheckStrongMode("(class undefined {});");
121 assertThrows("(class undefined {'use strong'});", SyntaxError); 116 assertThrows("(class undefined {'use strong'});", SyntaxError);
122 117
123 // Binding/assigning to 'undefined' in for 118 // Binding/assigning to 'undefined' in for
124 CheckStrongMode("for(undefined = 0;false;);"); 119 CheckStrongMode("for(undefined = 0;false;);");
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 CheckStrongMode("print(--undefined);"); 178 CheckStrongMode("print(--undefined);");
184 CheckStrongMode("let x = --undefined;"); 179 CheckStrongMode("let x = --undefined;");
185 180
186 // Function constructor: 'undefined' parameter name 181 // Function constructor: 'undefined' parameter name
187 assertDoesNotThrow(function() { 182 assertDoesNotThrow(function() {
188 Function("undefined", ""); 183 Function("undefined", "");
189 }); 184 });
190 assertThrows(function() { 185 assertThrows(function() {
191 Function("undefined", "'use strong';"); 186 Function("undefined", "'use strong';");
192 }, SyntaxError); 187 }, SyntaxError);
188
189 // Arrow functions with undefined parameters
190 CheckStrongMode("(undefined => {return});");
191 assertThrows("(undefined => {'use strong';});");
192
193 CheckStrongMode("((undefined, b, c) => {return});");
194 assertThrows("((undefined, b, c) => {'use strong';});");
195
196 CheckStrongMode("((a, undefined, c) => {return});");
197 assertThrows("((a, undefined, c) => {'use strong';});");
198
199 CheckStrongMode("((a, b, undefined) => {return});");
200 assertThrows("((a, b, undefined) => {'use strong';});");
OLDNEW
« no previous file with comments | « test/cctest/test-parsing.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698