| Index: test/mjsunit/strict-mode.js
|
| diff --git a/test/mjsunit/strict-mode.js b/test/mjsunit/strict-mode.js
|
| index 3cb6d329237b9aa01ff7fda137b4f3725460574c..ddddfabee42f91c943b1e588d292bc434ae0cfcb 100644
|
| --- a/test/mjsunit/strict-mode.js
|
| +++ b/test/mjsunit/strict-mode.js
|
| @@ -271,3 +271,68 @@ CheckStrictMode("function strict() { var x = --arguments; }", SyntaxError);
|
| var y = [void arguments, typeof arguments,
|
| +arguments, -arguments, ~arguments, !arguments];
|
| })();
|
| +
|
| +// 7.6.1.2 Future Reserved Words
|
| +var future_reserved_words = [
|
| + "class",
|
| + "enum",
|
| + "export",
|
| + "extends",
|
| + "import",
|
| + "super",
|
| + "implements",
|
| + "interface",
|
| + "let",
|
| + "package",
|
| + "private",
|
| + "protected",
|
| + "public",
|
| + "static",
|
| + "yield" ];
|
| +
|
| +function testFutureReservedWord(word) {
|
| + // Simple use of each reserved word
|
| + CheckStrictMode("var " + word + " = 1;", SyntaxError);
|
| +
|
| + // object literal properties
|
| + eval("var x = { " + word + " : 42 };");
|
| + eval("var x = { get " + word + " () {} };");
|
| + eval("var x = { set " + word + " (value) {} };");
|
| +
|
| + // object literal with string literal property names
|
| + 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'; } };");
|
| +
|
| + // Function names and arguments, strict and non-strict contexts
|
| + CheckStrictMode("function " + word + " () {}", SyntaxError);
|
| + CheckStrictMode("function foo (" + word + ") {}", SyntaxError);
|
| + CheckStrictMode("function foo (" + word + ", " + word + ") {}", SyntaxError);
|
| + CheckStrictMode("function foo (a, " + word + ") {}", SyntaxError);
|
| + CheckStrictMode("function foo (" + word + ", a) {}", SyntaxError);
|
| + CheckStrictMode("function foo (a, " + word + ", b) {}", SyntaxError);
|
| + CheckStrictMode("var foo = function (" + word + ") {}", SyntaxError);
|
| +
|
| + // 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);
|
| + assertThrows("function foo (" + word + ", a) { 'use strict'; }", SyntaxError);
|
| + assertThrows("function foo (a, " + word + ", b) { 'use strict'; }", SyntaxError);
|
| + assertThrows("var foo = function (" + word + ") { 'use strict'; }", SyntaxError);
|
| +
|
| + // get/set when the body is strict
|
| + eval("var x = { get " + word + " () { 'use strict'; } };");
|
| + eval("var x = { set " + word + " (value) { 'use strict'; } };");
|
| + 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]);
|
| +}
|
| +
|
| +
|
|
|