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

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

Issue 873823003: Move object literal checking into checker classes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix assert Created 5 years, 10 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
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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 var y = "\0"; 162 var y = "\0";
163 })(); 163 })();
164 164
165 // Octal before "use strict" 165 // Octal before "use strict"
166 assertThrows('\ 166 assertThrows('\
167 function strict() {\ 167 function strict() {\
168 "octal\\032directive";\ 168 "octal\\032directive";\
169 "use strict";\ 169 "use strict";\
170 }', SyntaxError); 170 }', SyntaxError);
171 171
172 // Duplicate data properties.
173 CheckStrictMode("var x = { dupe : 1, nondupe: 3, dupe : 2 };", SyntaxError);
174 CheckStrictMode("var x = { '1234' : 1, '2345' : 2, '1234' : 3 };", SyntaxError);
175 CheckStrictMode("var x = { '1234' : 1, '2345' : 2, 1234 : 3 };", SyntaxError);
176 CheckStrictMode("var x = { 3.14 : 1, 2.71 : 2, 3.14 : 3 };", SyntaxError);
177 CheckStrictMode("var x = { 3.14 : 1, '3.14' : 2 };", SyntaxError);
178 CheckStrictMode("var x = { \
179 123: 1, \
180 123.00000000000000000000000000000000000000000000000000000000000000000001: 2 \
181 }", SyntaxError);
182
183 // Non-conflicting data properties.
184 (function StrictModeNonDuplicate() { 172 (function StrictModeNonDuplicate() {
185 "use strict"; 173 "use strict";
186 var x = { 123 : 1, "0123" : 2 }; 174 var x = { 123 : 1, "0123" : 2 };
187 var x = { 175 var x = {
188 123: 1, 176 123: 1,
189 '123.00000000000000000000000000000000000000000000000000000000000000000001': 177 '123.00000000000000000000000000000000000000000000000000000000000000000001':
190 2 178 2
191 }; 179 };
192 })(); 180 })();
193 181
194 // Two getters (non-strict) 182 // Duplicate data properties are allowed in ES6
195 assertThrows("var x = { get foo() { }, get foo() { } };", SyntaxError); 183 (function StrictModeDuplicateES6() {
196 assertThrows("var x = { get foo(){}, get 'foo'(){}};", SyntaxError); 184 'use strict';
197 assertThrows("var x = { get 12(){}, get '12'(){}};", SyntaxError); 185 var x = {
186 123: 1,
187 123.00000000000000000000000000000000000000000000000000000000000000000001: 2
188 };
189 var x = { dupe : 1, nondupe: 3, dupe : 2 };
190 var x = { '1234' : 1, '2345' : 2, '1234' : 3 };
191 var x = { '1234' : 1, '2345' : 2, 1234 : 3 };
192 var x = { 3.14 : 1, 2.71 : 2, 3.14 : 3 };
193 var x = { 3.14 : 1, '3.14' : 2 };
198 194
199 // Two setters (non-strict) 195 var x = { get foo() { }, get foo() { } };
200 assertThrows("var x = { set foo(v) { }, set foo(v) { } };", SyntaxError); 196 var x = { get foo(){}, get 'foo'(){}};
201 assertThrows("var x = { set foo(v) { }, set 'foo'(v) { } };", SyntaxError); 197 var x = { get 12(){}, get '12'(){}};
202 assertThrows("var x = { set 13(v) { }, set '13'(v) { } };", SyntaxError);
203 198
204 // Setter and data (non-strict) 199 // Two setters
205 assertThrows("var x = { foo: 'data', set foo(v) { } };", SyntaxError); 200 var x = { set foo(v) { }, set foo(v) { } };
206 assertThrows("var x = { set foo(v) { }, foo: 'data' };", SyntaxError); 201 var x = { set foo(v) { }, set 'foo'(v) { } };
207 assertThrows("var x = { foo: 'data', set 'foo'(v) { } };", SyntaxError); 202 var x = { set 13(v) { }, set '13'(v) { } };
208 assertThrows("var x = { set foo(v) { }, 'foo': 'data' };", SyntaxError);
209 assertThrows("var x = { 'foo': 'data', set foo(v) { } };", SyntaxError);
210 assertThrows("var x = { set 'foo'(v) { }, foo: 'data' };", SyntaxError);
211 assertThrows("var x = { 'foo': 'data', set 'foo'(v) { } };", SyntaxError);
212 assertThrows("var x = { set 'foo'(v) { }, 'foo': 'data' };", SyntaxError);
213 assertThrows("var x = { 12: 1, set '12'(v){}};", SyntaxError);
214 assertThrows("var x = { 12: 1, set 12(v){}};", SyntaxError);
215 assertThrows("var x = { '12': 1, set '12'(v){}};", SyntaxError);
216 assertThrows("var x = { '12': 1, set 12(v){}};", SyntaxError);
217 203
218 // Getter and data (non-strict) 204 // Setter and data
219 assertThrows("var x = { foo: 'data', get foo() { } };", SyntaxError); 205 var x = { foo: 'data', set foo(v) { } };
220 assertThrows("var x = { get foo() { }, foo: 'data' };", SyntaxError); 206 var x = { set foo(v) { }, foo: 'data' };
221 assertThrows("var x = { 'foo': 'data', get foo() { } };", SyntaxError); 207 var x = { foo: 'data', set 'foo'(v) { } };
222 assertThrows("var x = { get 'foo'() { }, 'foo': 'data' };", SyntaxError); 208 var x = { set foo(v) { }, 'foo': 'data' };
223 assertThrows("var x = { '12': 1, get '12'(){}};", SyntaxError); 209 var x = { 'foo': 'data', set foo(v) { } };
224 assertThrows("var x = { '12': 1, get 12(){}};", SyntaxError); 210 var x = { set 'foo'(v) { }, foo: 'data' };
211 var x = { 'foo': 'data', set 'foo'(v) { } };
212 var x = { set 'foo'(v) { }, 'foo': 'data' };
213 var x = { 12: 1, set '12'(v){}};
214 var x = { 12: 1, set 12(v){}};
215 var x = { '12': 1, set '12'(v){}};
216 var x = { '12': 1, set 12(v){}};
217
218 // Getter and data
219 var x = { foo: 'data', get foo() { } };
220 var x = { get foo() { }, foo: 'data' };
221 var x = { 'foo': 'data', get foo() { } };
222 var x = { get 'foo'() { }, 'foo': 'data' };
223 var x = { '12': 1, get '12'(){}};
224 var x = { '12': 1, get 12(){}};
225 })();
225 226
226 // Assignment to eval or arguments 227 // Assignment to eval or arguments
227 CheckStrictMode("function strict() { eval = undefined; }", SyntaxError); 228 CheckStrictMode("function strict() { eval = undefined; }", SyntaxError);
228 CheckStrictMode("function strict() { arguments = undefined; }", SyntaxError); 229 CheckStrictMode("function strict() { arguments = undefined; }", SyntaxError);
229 CheckStrictMode("function strict() { print(eval = undefined); }", SyntaxError); 230 CheckStrictMode("function strict() { print(eval = undefined); }", SyntaxError);
230 CheckStrictMode("function strict() { print(arguments = undefined); }", 231 CheckStrictMode("function strict() { print(arguments = undefined); }",
231 SyntaxError); 232 SyntaxError);
232 CheckStrictMode("function strict() { var x = eval = undefined; }", SyntaxError); 233 CheckStrictMode("function strict() { var x = eval = undefined; }", SyntaxError);
233 CheckStrictMode("function strict() { var x = arguments = undefined; }", 234 CheckStrictMode("function strict() { var x = arguments = undefined; }",
234 SyntaxError); 235 SyntaxError);
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 assertSame(null, test(i)); 1212 assertSame(null, test(i));
1212 } 1213 }
1213 })(); 1214 })();
1214 1215
1215 1216
1216 (function TestStrictModeEval() { 1217 (function TestStrictModeEval() {
1217 "use strict"; 1218 "use strict";
1218 eval("var eval_local = 10;"); 1219 eval("var eval_local = 10;");
1219 assertThrows(function() { return eval_local; }, ReferenceError); 1220 assertThrows(function() { return eval_local; }, ReferenceError);
1220 })(); 1221 })();
OLDNEW
« no previous file with comments | « test/mjsunit/object-literal-multiple-proto-fields.js ('k') | test/test262-es6/test262-es6.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698