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

Unified 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 side-by-side diff with in-line comments
Download patch
« src/parser.cc ('K') | « test/es5conform/es5conform.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/strict-mode.js
diff --git a/test/mjsunit/strict-mode.js b/test/mjsunit/strict-mode.js
index 6b775fcb049409469a423e7ad58a1fd7582cb644..a4ee01dbe953dd4d5d364c2365622deb1ddb6809 100644
--- a/test/mjsunit/strict-mode.js
+++ b/test/mjsunit/strict-mode.js
@@ -264,6 +264,14 @@ CheckStrictMode("function strict() { print(--arguments); }", SyntaxError);
CheckStrictMode("function strict() { var x = --eval; }", SyntaxError);
CheckStrictMode("function strict() { var x = --arguments; }", SyntaxError);
+// 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.
+CheckStrictMode("delete unqualified;", SyntaxError);
+CheckStrictMode("function strict() { delete unqualified; }", SyntaxError);
+CheckStrictMode("function function_name() { delete function_name; }", SyntaxError);
Mads Ager (chromium) 2011/02/14 10:27:24 Make these 80 char lines?
Martin Maly 2011/02/14 21:46:51 Done.
+CheckStrictMode("function strict(parameter) { delete parameter; }", SyntaxError);
+CheckStrictMode("function strict() { var variable; delete variable; }", SyntaxError);
+CheckStrictMode("var variable; delete variable;", SyntaxError);
+
// Prefix unary operators other than delete, ++, -- are valid in strict mode
(function StrictModeUnaryOperators() {
"use strict";
@@ -374,3 +382,33 @@ delete possibly_undefined_variable_for_strict_mode_test;
repeat(10, function() { testAssignToUndefined(true); });
possibly_undefined_variable_for_strict_mode_test = undefined;
repeat(10, function() { testAssignToUndefined(false); });
+
+(function testDeleteNonConfigurable() {
+ function delete_property(o) {
+ "use strict";
+ delete o.property;
+ }
+ function delete_element(o, i) {
+ "use strict";
+ delete o[i];
+ }
+
+ var object = {};
+
+ Object.defineProperty(object, "property", { value: "property_value" });
+ Object.defineProperty(object, "1", { value: "one" });
+ Object.defineProperty(object, 7, { value: "seven" });
+ Object.defineProperty(object, 3.14, { value: "pi" });
+
+ assertThrows(function() { delete_property(object); }, TypeError);
+ assertEquals(object.property, "property_value");
+ assertThrows(function() { delete_element(object, "1"); }, TypeError);
+ assertThrows(function() { delete_element(object, 1); }, TypeError);
+ assertEquals(object[1], "one");
+ assertThrows(function() { delete_element(object, "7"); }, TypeError);
+ assertThrows(function() { delete_element(object, 7); }, TypeError);
+ assertEquals(object[7], "seven");
+ assertThrows(function() { delete_element(object, "3.14"); }, TypeError);
+ assertThrows(function() { delete_element(object, 3.14); }, TypeError);
+ assertEquals(object[3.14], "pi");
+})();
« 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