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

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

Issue 6515005: Strict mode delete. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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 | Annotate | Revision Log
« src/parser.cc ('K') | « test/es5conform/es5conform.status ('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 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 CheckStrictMode("function strict() { var x = ++arguments; }", SyntaxError); 257 CheckStrictMode("function strict() { var x = ++arguments; }", SyntaxError);
258 258
259 // Prefix decrement with eval or arguments 259 // Prefix decrement with eval or arguments
260 CheckStrictMode("function strict() { --eval; }", SyntaxError); 260 CheckStrictMode("function strict() { --eval; }", SyntaxError);
261 CheckStrictMode("function strict() { --arguments; }", SyntaxError); 261 CheckStrictMode("function strict() { --arguments; }", SyntaxError);
262 CheckStrictMode("function strict() { print(--eval); }", SyntaxError); 262 CheckStrictMode("function strict() { print(--eval); }", SyntaxError);
263 CheckStrictMode("function strict() { print(--arguments); }", SyntaxError); 263 CheckStrictMode("function strict() { print(--arguments); }", SyntaxError);
264 CheckStrictMode("function strict() { var x = --eval; }", SyntaxError); 264 CheckStrictMode("function strict() { var x = --eval; }", SyntaxError);
265 CheckStrictMode("function strict() { var x = --arguments; }", SyntaxError); 265 CheckStrictMode("function strict() { var x = --arguments; }", SyntaxError);
266 266
267 // Delete of an unqialified identifier
Mads Ager (chromium) 2011/02/14 10:27:24 unqialified -> unqualified
Martin Maly 2011/02/14 21:46:51 Done.
268 CheckStrictMode("delete unqualified;", SyntaxError);
269 CheckStrictMode("function strict() { delete unqualified; }", SyntaxError);
270 CheckStrictMode("function function_name() { delete function_name; }", SyntaxErro r);
Mads Ager (chromium) 2011/02/14 10:27:24 Make these 80 char lines?
Martin Maly 2011/02/14 21:46:51 Done.
271 CheckStrictMode("function strict(parameter) { delete parameter; }", SyntaxError) ;
272 CheckStrictMode("function strict() { var variable; delete variable; }", SyntaxEr ror);
273 CheckStrictMode("var variable; delete variable;", SyntaxError);
274
267 // Prefix unary operators other than delete, ++, -- are valid in strict mode 275 // Prefix unary operators other than delete, ++, -- are valid in strict mode
268 (function StrictModeUnaryOperators() { 276 (function StrictModeUnaryOperators() {
269 "use strict"; 277 "use strict";
270 var x = [void eval, typeof eval, +eval, -eval, ~eval, !eval]; 278 var x = [void eval, typeof eval, +eval, -eval, ~eval, !eval];
271 var y = [void arguments, typeof arguments, 279 var y = [void arguments, typeof arguments,
272 +arguments, -arguments, ~arguments, !arguments]; 280 +arguments, -arguments, ~arguments, !arguments];
273 })(); 281 })();
274 282
275 // 7.6.1.2 Future Reserved Words 283 // 7.6.1.2 Future Reserved Words
276 var future_reserved_words = [ 284 var future_reserved_words = [
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 for (var i = 0; i < n; i ++) { f(); } 375 for (var i = 0; i < n; i ++) { f(); }
368 } 376 }
369 377
370 repeat(10, function() { testAssignToUndefined(true); }); 378 repeat(10, function() { testAssignToUndefined(true); });
371 possibly_undefined_variable_for_strict_mode_test = "value"; 379 possibly_undefined_variable_for_strict_mode_test = "value";
372 repeat(10, function() { testAssignToUndefined(false); }); 380 repeat(10, function() { testAssignToUndefined(false); });
373 delete possibly_undefined_variable_for_strict_mode_test; 381 delete possibly_undefined_variable_for_strict_mode_test;
374 repeat(10, function() { testAssignToUndefined(true); }); 382 repeat(10, function() { testAssignToUndefined(true); });
375 possibly_undefined_variable_for_strict_mode_test = undefined; 383 possibly_undefined_variable_for_strict_mode_test = undefined;
376 repeat(10, function() { testAssignToUndefined(false); }); 384 repeat(10, function() { testAssignToUndefined(false); });
385
386 (function testDeleteNonConfigurable() {
387 function delete_property(o) {
388 "use strict";
389 delete o.property;
390 }
391 function delete_element(o, i) {
392 "use strict";
393 delete o[i];
394 }
395
396 var object = {};
397
398 Object.defineProperty(object, "property", { value: "property_value" });
399 Object.defineProperty(object, "1", { value: "one" });
400 Object.defineProperty(object, 7, { value: "seven" });
401 Object.defineProperty(object, 3.14, { value: "pi" });
402
403 assertThrows(function() { delete_property(object); }, TypeError);
404 assertEquals(object.property, "property_value");
405 assertThrows(function() { delete_element(object, "1"); }, TypeError);
406 assertThrows(function() { delete_element(object, 1); }, TypeError);
407 assertEquals(object[1], "one");
408 assertThrows(function() { delete_element(object, "7"); }, TypeError);
409 assertThrows(function() { delete_element(object, 7); }, TypeError);
410 assertEquals(object[7], "seven");
411 assertThrows(function() { delete_element(object, "3.14"); }, TypeError);
412 assertThrows(function() { delete_element(object, 3.14); }, TypeError);
413 assertEquals(object[3.14], "pi");
414 })();
OLDNEW
« src/parser.cc ('K') | « test/es5conform/es5conform.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698