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

Unified Diff: test/mjsunit/strict-mode.js

Issue 7207007: Proper handling of future reserved words in strict and normal mode. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/keywords-and-reserved_words.js ('k') | test/preparser/strict-identifiers.pyt » ('j') | 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 fcfe264e988471becfb6804ff10037d5201ea2ff..726996714c2c60281987564c753a0ea9c90aa224 100644
--- a/test/mjsunit/strict-mode.js
+++ b/test/mjsunit/strict-mode.js
@@ -67,6 +67,9 @@ function CheckFunctionConstructorStrictMode() {
with ({}) {};
})();
+// Incorrectly place 'use strict' directive.
+assertThrows("function foo (x) 'use strict'; {}", SyntaxError);
+
// 'use strict' in non-directive position.
(function UseStrictNonDirective() {
void(0);
@@ -319,14 +322,8 @@ CheckStrictMode("var variable; delete variable;", SyntaxError);
+arguments, -arguments, ~arguments, !arguments];
})();
-// 7.6.1.2 Future Reserved Words
-var future_reserved_words = [
- "class",
- "enum",
- "export",
- "extends",
- "import",
- "super",
+// 7.6.1.2 Future Reserved Words in strict mode
+var future_strict_reserved_words = [
"implements",
"interface",
"let",
@@ -337,14 +334,17 @@ var future_reserved_words = [
"static",
"yield" ];
-function testFutureReservedWord(word) {
+function testFutureStrictReservedWord(word) {
// Simple use of each reserved word
CheckStrictMode("var " + word + " = 1;", SyntaxError);
+ CheckStrictMode("typeof (" + word + ");", SyntaxError);
// object literal properties
eval("var x = { " + word + " : 42 };");
eval("var x = { get " + word + " () {} };");
eval("var x = { set " + word + " (value) {} };");
+ eval("var x = { get " + word + " () { 'use strict'; } };");
+ eval("var x = { set " + word + " (value) { 'use strict'; } };");
// object literal with string literal property names
eval("var x = { '" + word + "' : 42 };");
@@ -364,7 +364,6 @@ function testFutureReservedWord(word) {
// Function names and arguments when the body is strict
assertThrows("function " + word + " () { 'use strict'; }", SyntaxError);
- assertThrows("function foo (" + word + ") 'use strict'; {}", SyntaxError);
assertThrows("function foo (" + word + ", " + word + ") { 'use strict'; }",
SyntaxError);
assertThrows("function foo (a, " + word + ") { 'use strict'; }", SyntaxError);
@@ -375,16 +374,16 @@ function testFutureReservedWord(word) {
SyntaxError);
// get/set when the body is strict
- eval("var x = { get " + word + " () { 'use strict'; } };");
- eval("var x = { set " + word + " (value) { 'use strict'; } };");
+ // Getters don't have formal parameters, so particularly future reserved
+ // keywords are disallowed.
assertThrows("var x = { get foo(" + word + ") { 'use strict'; } };",
SyntaxError);
assertThrows("var x = { set foo(" + word + ") { 'use strict'; } };",
SyntaxError);
}
-for (var i = 0; i < future_reserved_words.length; i++) {
- testFutureReservedWord(future_reserved_words[i]);
+for (var i = 0; i < future_strict_reserved_words.length; i++) {
+ testFutureStrictReservedWord(future_strict_reserved_words[i]);
}
function testAssignToUndefined(test, should_throw) {
« no previous file with comments | « test/mjsunit/keywords-and-reserved_words.js ('k') | test/preparser/strict-identifiers.pyt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698