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

Side by Side Diff: test/mjsunit/strict-mode.js

Issue 352173004: Relax object literal checking to follow ES6 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-parsing.cc ('k') | test/preparser/duplicate-property.pyt » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 })(); 160 })();
161 161
162 // Octal before "use strict" 162 // Octal before "use strict"
163 assertThrows('\ 163 assertThrows('\
164 function strict() {\ 164 function strict() {\
165 "octal\\032directive";\ 165 "octal\\032directive";\
166 "use strict";\ 166 "use strict";\
167 }', SyntaxError); 167 }', SyntaxError);
168 168
169 // Duplicate data properties. 169 // Duplicate data properties.
170 CheckStrictMode("var x = { dupe : 1, nondupe: 3, dupe : 2 };", SyntaxError); 170 (function DuplicatePropertiesPermittedAsOfES6() {
171 CheckStrictMode("var x = { '1234' : 1, '2345' : 2, '1234' : 3 };", SyntaxError); 171 "use strict";
172 CheckStrictMode("var x = { '1234' : 1, '2345' : 2, 1234 : 3 };", SyntaxError); 172 var x = { dupe : 1, nondupe: 3, dupe : 2 };
173 CheckStrictMode("var x = { 3.14 : 1, 2.71 : 2, 3.14 : 3 };", SyntaxError); 173 var x = { '1234' : 1, '2345' : 2, '1234' : 3 };
174 CheckStrictMode("var x = { 3.14 : 1, '3.14' : 2 };", SyntaxError); 174 var x = { '1234' : 1, '2345' : 2, 1234 : 3 };
175 CheckStrictMode("var x = { \ 175 var x = { 3.14 : 1, 2.71 : 2, 3.14 : 3 };
176 123: 1, \ 176 var x = { 3.14 : 1, '3.14' : 2 };
177 123.00000000000000000000000000000000000000000000000000000000000000000001: 2 \ 177 var x = { 123: 1,
178 }", SyntaxError); 178 123.00000000000000000000000000000000000000000000000000000000000000000001: 2
179 };
179 180
180 // Non-conflicting data properties. 181 // Non-conflicting data properties.
181 (function StrictModeNonDuplicate() {
182 "use strict";
183 var x = { 123 : 1, "0123" : 2 }; 182 var x = { 123 : 1, "0123" : 2 };
184 var x = { 183 var x = {
185 123: 1, 184 123: 1,
186 '123.00000000000000000000000000000000000000000000000000000000000000000001': 185 '123.00000000000000000000000000000000000000000000000000000000000000000001':
187 2 186 2
188 }; 187 };
188
189 // Two getters
190 var x = { get foo() { }, get foo() { } };
191 var x = { get foo(){}, get 'foo'(){}};
192 var x = { get 12(){}, get '12'(){}};
193
194 // Two setters
195 var x = { set foo(v) { }, set foo(v) { } };
196 var x = { set foo(v) { }, set 'foo'(v) { } };
197 var x = { set 13(v) { }, set '13'(v) { } };
198
199 // Setter and data
200 var x = { foo: 'data', set foo(v) { } };
201 var x = { set foo(v) { }, foo: 'data' };
202 var x = { foo: 'data', set 'foo'(v) { } };
203 var x = { set foo(v) { }, 'foo': 'data' };
204 var x = { 'foo': 'data', set foo(v) { } };
205 var x = { set 'foo'(v) { }, foo: 'data' };
206 var x = { 'foo': 'data', set 'foo'(v) { } };
207 var x = { set 'foo'(v) { }, 'foo': 'data' };
208 var x = { 12: 1, set '12'(v){}};
209 var x = { 12: 1, set 12(v){}};
210 var x = { '12': 1, set '12'(v){}};
211 var x = { '12': 1, set 12(v){}};
212
213 // Getter and data
214 var x = { foo: 'data', get foo() { } };
215 var x = { get foo() { }, foo: 'data' };
216 var x = { 'foo': 'data', get foo() { } };
217 var x = { get 'foo'() { }, 'foo': 'data' };
218 var x = { '12': 1, get '12'(){}};
219 var x = { '12': 1, get 12(){}};
189 })(); 220 })();
190 221
191 // Two getters (non-strict)
192 assertThrows("var x = { get foo() { }, get foo() { } };", SyntaxError);
193 assertThrows("var x = { get foo(){}, get 'foo'(){}};", SyntaxError);
194 assertThrows("var x = { get 12(){}, get '12'(){}};", SyntaxError);
195
196 // Two setters (non-strict)
197 assertThrows("var x = { set foo(v) { }, set foo(v) { } };", SyntaxError);
198 assertThrows("var x = { set foo(v) { }, set 'foo'(v) { } };", SyntaxError);
199 assertThrows("var x = { set 13(v) { }, set '13'(v) { } };", SyntaxError);
200
201 // Setter and data (non-strict)
202 assertThrows("var x = { foo: 'data', set foo(v) { } };", SyntaxError);
203 assertThrows("var x = { set foo(v) { }, foo: 'data' };", SyntaxError);
204 assertThrows("var x = { foo: 'data', set 'foo'(v) { } };", SyntaxError);
205 assertThrows("var x = { set foo(v) { }, 'foo': 'data' };", SyntaxError);
206 assertThrows("var x = { 'foo': 'data', set foo(v) { } };", SyntaxError);
207 assertThrows("var x = { set 'foo'(v) { }, foo: 'data' };", SyntaxError);
208 assertThrows("var x = { 'foo': 'data', set 'foo'(v) { } };", SyntaxError);
209 assertThrows("var x = { set 'foo'(v) { }, 'foo': 'data' };", SyntaxError);
210 assertThrows("var x = { 12: 1, set '12'(v){}};", SyntaxError);
211 assertThrows("var x = { 12: 1, set 12(v){}};", SyntaxError);
212 assertThrows("var x = { '12': 1, set '12'(v){}};", SyntaxError);
213 assertThrows("var x = { '12': 1, set 12(v){}};", SyntaxError);
214
215 // Getter and data (non-strict)
216 assertThrows("var x = { foo: 'data', get foo() { } };", SyntaxError);
217 assertThrows("var x = { get foo() { }, foo: 'data' };", SyntaxError);
218 assertThrows("var x = { 'foo': 'data', get foo() { } };", SyntaxError);
219 assertThrows("var x = { get 'foo'() { }, 'foo': 'data' };", SyntaxError);
220 assertThrows("var x = { '12': 1, get '12'(){}};", SyntaxError);
221 assertThrows("var x = { '12': 1, get 12(){}};", SyntaxError);
222
223 // Assignment to eval or arguments 222 // Assignment to eval or arguments
224 CheckStrictMode("function strict() { eval = undefined; }", SyntaxError); 223 CheckStrictMode("function strict() { eval = undefined; }", SyntaxError);
225 CheckStrictMode("function strict() { arguments = undefined; }", SyntaxError); 224 CheckStrictMode("function strict() { arguments = undefined; }", SyntaxError);
226 CheckStrictMode("function strict() { print(eval = undefined); }", SyntaxError); 225 CheckStrictMode("function strict() { print(eval = undefined); }", SyntaxError);
227 CheckStrictMode("function strict() { print(arguments = undefined); }", 226 CheckStrictMode("function strict() { print(arguments = undefined); }",
228 SyntaxError); 227 SyntaxError);
229 CheckStrictMode("function strict() { var x = eval = undefined; }", SyntaxError); 228 CheckStrictMode("function strict() { var x = eval = undefined; }", SyntaxError);
230 CheckStrictMode("function strict() { var x = arguments = undefined; }", 229 CheckStrictMode("function strict() { var x = arguments = undefined; }",
231 SyntaxError); 230 SyntaxError);
232 231
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 assertSame(null, test(i)); 1207 assertSame(null, test(i));
1209 } 1208 }
1210 })(); 1209 })();
1211 1210
1212 1211
1213 (function TestStrictModeEval() { 1212 (function TestStrictModeEval() {
1214 "use strict"; 1213 "use strict";
1215 eval("var eval_local = 10;"); 1214 eval("var eval_local = 10;");
1216 assertThrows(function() { return eval_local; }, ReferenceError); 1215 assertThrows(function() { return eval_local; }, ReferenceError);
1217 })(); 1216 })();
OLDNEW
« no previous file with comments | « test/cctest/test-parsing.cc ('k') | test/preparser/duplicate-property.pyt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698