diff options
Diffstat (limited to 'js/src/tests/test262/language/reserved-words')
29 files changed, 1205 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/reserved-words/await-module.js b/js/src/tests/test262/language/reserved-words/await-module.js new file mode 100644 index 0000000000..bd41278a1f --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/await-module.js @@ -0,0 +1,16 @@ +// |reftest| error:SyntaxError module +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-reserved-words +es6id: 11.6.2 +description: The `await` token is not permitted as an identifier in module code +flags: [module] +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +var await; diff --git a/js/src/tests/test262/language/reserved-words/await-script.js b/js/src/tests/test262/language/reserved-words/await-script.js new file mode 100644 index 0000000000..193b060c87 --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/await-script.js @@ -0,0 +1,11 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-reserved-words +es6id: 11.6.2 +description: The `await` token is permitted as an identifier in script code +---*/ + +var await; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/reserved-words/browser.js b/js/src/tests/test262/language/reserved-words/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/browser.js diff --git a/js/src/tests/test262/language/reserved-words/ident-name-global-property-accessor.js b/js/src/tests/test262/language/reserved-words/ident-name-global-property-accessor.js new file mode 100644 index 0000000000..170166af24 --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/ident-name-global-property-accessor.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 7.6.1-4-16 +description: > + Allow global constant properties as property names by accessor function within an object. +---*/ + +var test; + +var tokenCodes = { + set undefined(value) { test = 'undefined'; }, + get undefined() { return 'undefined'; }, + set NaN(value) { test = 'NaN'; }, + get NaN() { return 'NaN'; }, + set Infinity(value) { test = 'Infinity'; }, + get Infinity() { return 'Infinity'; }, +}; + +var arr = [ + 'undefined', + 'NaN', + 'Infinity', +]; + +for (var i = 0; i < arr.length; ++i) { + var propertyName = arr[i]; + + assert(tokenCodes.hasOwnProperty(propertyName), + 'Property "' + propertyName + '" found'); + + assert.sameValue(tokenCodes[propertyName], propertyName, + 'Property "' + propertyName + '" has correct value'); + + tokenCodes[propertyName] = 0; + assert.sameValue(test, propertyName, + 'Property "' + propertyName + '" sets correct value'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/reserved-words/ident-name-global-property-memberexpr-str.js b/js/src/tests/test262/language/reserved-words/ident-name-global-property-memberexpr-str.js new file mode 100644 index 0000000000..b3aa5404df --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/ident-name-global-property-memberexpr-str.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 7.6.1-3-16 +description: > + Allow global constant properties as property names by index assignment. +---*/ + +var tokenCodes = {}; + +tokenCodes['undefined'] = 'undefined'; +tokenCodes['NaN'] = 'NaN'; +tokenCodes['Infinity'] = 'Infinity'; + +var arr = [ + 'undefined', + 'NaN', + 'Infinity', +]; + +for (var i = 0; i < arr.length; ++i) { + var propertyName = arr[i]; + + assert(tokenCodes.hasOwnProperty(propertyName), + 'Property "' + propertyName + '" found'); + + assert.sameValue(tokenCodes[propertyName], propertyName, + 'Property "' + propertyName + '" has correct value'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/reserved-words/ident-name-global-property-memberexpr.js b/js/src/tests/test262/language/reserved-words/ident-name-global-property-memberexpr.js new file mode 100644 index 0000000000..43b17272dc --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/ident-name-global-property-memberexpr.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 7.6.1-2-16 +description: > + Allow global constant properties as property names by dot operator assignment +---*/ + +var tokenCodes = {}; + +tokenCodes.undefined = 'undefined'; +tokenCodes.NaN = 'NaN'; +tokenCodes.Infinity = 'Infinity'; + +var arr = [ + 'undefined', + 'NaN', + 'Infinity', +]; + +for (var i = 0; i < arr.length; ++i) { + var propertyName = arr[i]; + + assert(tokenCodes.hasOwnProperty(propertyName), + 'Property "' + propertyName + '" found'); + + assert.sameValue(tokenCodes[propertyName], propertyName, + 'Property "' + propertyName + '" has correct value'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/reserved-words/ident-name-global-property-prop-name.js b/js/src/tests/test262/language/reserved-words/ident-name-global-property-prop-name.js new file mode 100644 index 0000000000..4a71fbb152 --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/ident-name-global-property-prop-name.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 7.6.1-1-16 +description: > + Allow global constant properties as property names at object initialization. +---*/ + +var tokenCodes = { + undefined: 'undefined', + NaN: 'NaN', + Infinity: 'Infinity', +}; + +var arr = [ + 'undefined', + 'NaN', + 'Infinity' +]; + +for (var i = 0; i < arr.length; ++i) { + var propertyName = arr[i]; + + assert(tokenCodes.hasOwnProperty(propertyName), + 'Property "' + propertyName + '" found'); + + assert.sameValue(tokenCodes[propertyName], propertyName, + 'Property "' + propertyName + '" has correct value'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/reserved-words/ident-name-keyword-accessor.js b/js/src/tests/test262/language/reserved-words/ident-name-keyword-accessor.js new file mode 100644 index 0000000000..0b3564a8c4 --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/ident-name-keyword-accessor.js @@ -0,0 +1,167 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 7.6.1-4-2 +description: > + Allow reserved words as property names by accessor functions within an object. +---*/ + +var test; + +var tokenCodes = { + set await(value) { test = "await"; }, + get await() { return "await"; }, + set break(value) { test = "break"; }, + get break() { return "break"; }, + set case(value) { test = "case"; }, + get case() { return "case"; }, + set catch(value) { test = "catch"; }, + get catch() { return "catch"; }, + set class(value) { test = "class"; }, + get class() { return "class"; }, + set const(value) { test = "const"; }, + get const() { return "const"; }, + set continue(value) { test = "continue"; }, + get continue() { return "continue"; }, + set debugger(value) { test = "debugger"; }, + get debugger() { return "debugger"; }, + set default(value) { test = "default"; }, + get default() { return "default"; }, + set delete(value) { test = "delete"; }, + get delete() { return "delete"; }, + set do(value) { test = "do"; }, + get do() { return "do"; }, + set else(value) { test = "else"; }, + get else() { return "else"; }, + set export(value) { test = "export"; }, + get export() { return "export"; }, + set extends(value) { test = "extends"; }, + get extends() { return "extends"; }, + set finally(value) { test = "finally"; }, + get finally() { return "finally"; }, + set for(value) { test = "for"; }, + get for() { return "for"; }, + set function(value) { test = "function"; }, + get function() { return "function"; }, + set if(value) { test = "if"; }, + get if() { return "if"; }, + set import(value) { test = "import"; }, + get import() { return "import"; }, + set in(value) { test = "in"; }, + get in() { return "in"; }, + set instanceof(value) { test = "instanceof"; }, + get instanceof() { return "instanceof"; }, + set new(value) { test = "new"; }, + get new() { return "new"; }, + set return(value) { test = "return"; }, + get return() { return "return"; }, + set super(value) { test = "super"; }, + get super() { return "super"; }, + set switch(value) { test = "switch"; }, + get switch() { return "switch"; }, + set this(value) { test = "this"; }, + get this() { return "this"; }, + set throw(value) { test = "throw"; }, + get throw() { return "throw"; }, + set try(value) { test = "try"; }, + get try() { return "try"; }, + set typeof(value) { test = "typeof"; }, + get typeof() { return "typeof"; }, + set var(value) { test = "var"; }, + get var() { return "var"; }, + set void(value) { test = "void"; }, + get void() { return "void"; }, + set while(value) { test = "while"; }, + get while() { return "while"; }, + set with(value) { test = "with"; }, + get with() { return "with"; }, + set yield(value) { test = "yield"; }, + get yield() { return "yield"; }, + + set enum(value) { test = "enum"; }, + get enum() { return "enum"; }, + + set implements(value) { test = "implements"; }, + get implements() { return "implements"; }, + set interface(value) { test = "interface"; }, + get interface() { return "interface"; }, + set package(value) { test = "package"; }, + get package() { return "package"; }, + set private(value) { test = "private"; }, + get private() { return "private"; }, + set protected(value) { test = "protected"; }, + get protected() { return "protected"; }, + set public(value) { test = "public"; }, + get public() { return "public"; }, + + set let(value) { test = "let"; }, + get let() { return "let"; }, + set static(value) { test = "static"; }, + get static() { return "static"; }, +}; + +var arr = [ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'import', + 'in', + 'instanceof', + 'new', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield', + + 'enum', + + 'implements', + 'interface', + 'package', + 'protected', + 'private', + 'public', + + 'let', + 'static', +]; + +for (var i = 0; i < arr.length; ++i) { + var propertyName = arr[i]; + + assert(tokenCodes.hasOwnProperty(propertyName), + 'Property "' + propertyName + '" found'); + + assert.sameValue(tokenCodes[propertyName], propertyName, + 'Property "' + propertyName + '" has correct value'); + + tokenCodes[propertyName] = 0; + assert.sameValue(test, propertyName, + 'Property "' + propertyName + '" sets correct value'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/reserved-words/ident-name-keyword-memberexpr-str.js b/js/src/tests/test262/language/reserved-words/ident-name-keyword-memberexpr-str.js new file mode 100644 index 0000000000..f0001dd2cd --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/ident-name-keyword-memberexpr-str.js @@ -0,0 +1,119 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 7.6.1-3-2 +description: > + Allow reserved words as property names by index assignment. +---*/ + +var tokenCodes = {}; + +tokenCodes['await'] = 'await'; +tokenCodes['break'] = 'break'; +tokenCodes['case'] = 'case'; +tokenCodes['catch'] = 'catch'; +tokenCodes['class'] = 'class'; +tokenCodes['const'] = 'const'; +tokenCodes['continue'] = 'continue'; +tokenCodes['debugger'] = 'debugger'; +tokenCodes['default'] = 'default'; +tokenCodes['delete'] = 'delete'; +tokenCodes['do'] = 'do'; +tokenCodes['else'] = 'else'; +tokenCodes['export'] = 'export'; +tokenCodes['extends'] = 'extends'; +tokenCodes['finally'] = 'finally'; +tokenCodes['for'] = 'for'; +tokenCodes['function'] = 'function'; +tokenCodes['if'] = 'if'; +tokenCodes['import'] = 'import'; +tokenCodes['in'] = 'in'; +tokenCodes['instanceof'] = 'instanceof'; +tokenCodes['new'] = 'new'; +tokenCodes['return'] = 'return'; +tokenCodes['super'] = 'super'; +tokenCodes['switch'] = 'switch'; +tokenCodes['this'] = 'this'; +tokenCodes['throw'] = 'throw'; +tokenCodes['try'] = 'try'; +tokenCodes['typeof'] = 'typeof'; +tokenCodes['var'] = 'var'; +tokenCodes['void'] = 'void'; +tokenCodes['while'] = 'while'; +tokenCodes['with'] = 'with'; +tokenCodes['yield'] = 'yield'; + +tokenCodes['enum'] = 'enum'; + +tokenCodes['implements'] = 'implements'; +tokenCodes['interface'] = 'interface'; +tokenCodes['package'] = 'package'; +tokenCodes['protected'] = 'protected'; +tokenCodes['private'] = 'private'; +tokenCodes['public'] = 'public'; + +tokenCodes['let'] = 'let'; +tokenCodes['static'] = 'static'; + + +var arr = [ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'import', + 'in', + 'instanceof', + 'new', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield', + + 'enum', + + 'implements', + 'interface', + 'package', + 'protected', + 'private', + 'public', + + 'let', + 'static', +]; + +for (var i = 0; i < arr.length; ++i) { + var propertyName = arr[i]; + + assert(tokenCodes.hasOwnProperty(propertyName), + 'Property "' + propertyName + '" found'); + + assert.sameValue(tokenCodes[propertyName], propertyName, + 'Property "' + propertyName + '" has correct value'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/reserved-words/ident-name-keyword-memberexpr.js b/js/src/tests/test262/language/reserved-words/ident-name-keyword-memberexpr.js new file mode 100644 index 0000000000..2de5232118 --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/ident-name-keyword-memberexpr.js @@ -0,0 +1,118 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 7.6.1-2-2 +description: > + Allow reserved words as property names by dot operator assignment. +---*/ + +var tokenCodes = {}; + +tokenCodes.await = 'await'; +tokenCodes.break = 'break'; +tokenCodes.case = 'case'; +tokenCodes.catch = 'catch'; +tokenCodes.class = 'class'; +tokenCodes.const = 'const'; +tokenCodes.continue = 'continue'; +tokenCodes.debugger = 'debugger'; +tokenCodes.default = 'default'; +tokenCodes.delete = 'delete'; +tokenCodes.do = 'do'; +tokenCodes.else = 'else'; +tokenCodes.export = 'export'; +tokenCodes.extends = 'extends'; +tokenCodes.finally = 'finally'; +tokenCodes.for = 'for'; +tokenCodes.function = 'function'; +tokenCodes.if = 'if'; +tokenCodes.import = 'import'; +tokenCodes.in = 'in'; +tokenCodes.instanceof = 'instanceof'; +tokenCodes.new = 'new'; +tokenCodes.return = 'return'; +tokenCodes.super = 'super'; +tokenCodes.switch = 'switch'; +tokenCodes.this = 'this'; +tokenCodes.throw = 'throw'; +tokenCodes.try = 'try'; +tokenCodes.typeof = 'typeof'; +tokenCodes.var = 'var'; +tokenCodes.void = 'void'; +tokenCodes.while = 'while'; +tokenCodes.with = 'with'; +tokenCodes.yield = 'yield'; + +tokenCodes.enum = 'enum'; + +tokenCodes.implements = 'implements'; +tokenCodes.interface = 'interface'; +tokenCodes.package = 'package'; +tokenCodes.protected = 'protected'; +tokenCodes.private = 'private'; +tokenCodes.public = 'public'; + +tokenCodes.let = 'let'; +tokenCodes.static = 'static'; + +var arr = [ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'import', + 'in', + 'instanceof', + 'new', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield', + + 'enum', + + 'implements', + 'interface', + 'package', + 'protected', + 'private', + 'public', + + 'let', + 'static', +]; + +for (var i = 0; i < arr.length; ++i) { + var propertyName = arr[i]; + + assert(tokenCodes.hasOwnProperty(propertyName), + 'Property "' + propertyName + '" found'); + + assert.sameValue(tokenCodes[propertyName], propertyName, + 'Property "' + propertyName + '" has correct value'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/reserved-words/ident-name-keyword-prop-name.js b/js/src/tests/test262/language/reserved-words/ident-name-keyword-prop-name.js new file mode 100644 index 0000000000..d4a4487340 --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/ident-name-keyword-prop-name.js @@ -0,0 +1,118 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 7.6.1-1-2 +description: > + Allow reserved words as property names at object initialization. +---*/ + +var tokenCodes = { + await: 'await', + break: 'break', + case: 'case', + catch: 'catch', + class: 'class', + const: 'const', + continue: 'continue', + debugger: 'debugger', + default: 'default', + delete: 'delete', + do: 'do', + else: 'else', + export: 'export', + extends: 'extends', + finally: 'finally', + for: 'for', + function: 'function', + if: 'if', + import: 'import', + in: 'in', + instanceof: 'instanceof', + new: 'new', + return: 'return', + super: 'super', + switch: 'switch', + this: 'this', + throw: 'throw', + try: 'try', + typeof: 'typeof', + var: 'var', + void: 'void', + while: 'while', + with: 'with', + yield: 'yield', + + enum: 'enum', + + implements: 'implements', + interface: 'interface', + package: 'package', + protected: 'protected', + private: 'private', + public: 'public', + + let: 'let', + static: 'static', +}; + +var arr = [ + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'export', + 'extends', + 'finally', + 'for', + 'function', + 'if', + 'import', + 'in', + 'instanceof', + 'new', + 'return', + 'super', + 'switch', + 'this', + 'throw', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield', + + 'enum', + + 'implements', + 'interface', + 'package', + 'protected', + 'private', + 'public', + + 'let', + 'static', +]; + +for (var i = 0; i < arr.length; ++i) { + var propertyName = arr[i]; + + assert(tokenCodes.hasOwnProperty(propertyName), + 'Property "' + propertyName + '" found'); + + assert.sameValue(tokenCodes[propertyName], propertyName, + 'Property "' + propertyName + '" has correct value'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/reserved-words/ident-name-reserved-word-literal-accessor.js b/js/src/tests/test262/language/reserved-words/ident-name-reserved-word-literal-accessor.js new file mode 100644 index 0000000000..56dd373294 --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/ident-name-reserved-word-literal-accessor.js @@ -0,0 +1,41 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 7.6.1-4-1 +description: > + Allow reserved words as property names by accessor function within an object. +---*/ + +var test; + +var tokenCodes = { + set null(value) { test = 'null'; }, + get null() { return 'null'; }, + set true(value) { test = 'true'; }, + get true() { return 'true'; }, + set false(value) { test = 'false'; }, + get false() { return 'false'; }, +}; + +var arr = [ + 'null', + 'true', + 'false', +]; + +for (var i = 0; i < arr.length; ++i) { + var propertyName = arr[i]; + + assert(tokenCodes.hasOwnProperty(propertyName), + 'Property "' + propertyName + '" found'); + + assert.sameValue(tokenCodes[propertyName], propertyName, + 'Property "' + propertyName + '" has correct value'); + + tokenCodes[propertyName] = 0; + assert.sameValue(test, propertyName, + 'Property "' + propertyName + '" sets correct value'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/reserved-words/ident-name-reserved-word-literal-memberexpr-str.js b/js/src/tests/test262/language/reserved-words/ident-name-reserved-word-literal-memberexpr-str.js new file mode 100644 index 0000000000..521b3a59be --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/ident-name-reserved-word-literal-memberexpr-str.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 7.6.1-3-1 +description: > + Allow reserved words as property names by index assignment. +---*/ + +var tokenCodes = {}; + +tokenCodes['null'] = 'null'; +tokenCodes['true'] = 'true'; +tokenCodes['false'] = 'false'; + +var arr = [ + 'null', + 'true', + 'false', +]; + +for (var i = 0; i < arr.length; ++i) { + var propertyName = arr[i]; + + assert(tokenCodes.hasOwnProperty(propertyName), + 'Property "' + propertyName + '" found'); + + assert.sameValue(tokenCodes[propertyName], propertyName, + 'Property "' + propertyName + '" has correct value'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/reserved-words/ident-name-reserved-word-literal-memberexpr.js b/js/src/tests/test262/language/reserved-words/ident-name-reserved-word-literal-memberexpr.js new file mode 100644 index 0000000000..ff4e647fa4 --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/ident-name-reserved-word-literal-memberexpr.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 7.6.1-2-1 +description: > + Allow reserved words as property names by dot operator assignment. +---*/ + +var tokenCodes = {}; + +tokenCodes.null = 'null'; +tokenCodes.true = 'true'; +tokenCodes.false = 'false'; + +var arr = [ + 'null', + 'true', + 'false', +]; + +for (var i = 0; i < arr.length; ++i) { + var propertyName = arr[i]; + + assert(tokenCodes.hasOwnProperty(propertyName), + 'Property "' + propertyName + '" found'); + + assert.sameValue(tokenCodes[propertyName], propertyName, + 'Property "' + propertyName + '" has correct value'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/reserved-words/ident-name-reserved-word-literal-prop-name.js b/js/src/tests/test262/language/reserved-words/ident-name-reserved-word-literal-prop-name.js new file mode 100644 index 0000000000..f013c6c2f3 --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/ident-name-reserved-word-literal-prop-name.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 7.6.1-1-1 +description: > + Allow reserved words as property names at object initialization. +---*/ + +var tokenCodes = { + null: 'null', + true: 'true', + false: 'false', +}; + +var arr = [ + 'null', + 'true', + 'false', +]; + +for (var i = 0; i < arr.length; ++i) { + var propertyName = arr[i]; + + assert(tokenCodes.hasOwnProperty(propertyName), + 'Property "' + propertyName + '" found'); + + assert.sameValue(tokenCodes[propertyName], propertyName, + 'Property "' + propertyName + '" has correct value'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/reserved-words/ident-reference-false-escaped.js b/js/src/tests/test262/language/reserved-words/ident-reference-false-escaped.js new file mode 100644 index 0000000000..1c2486c83e --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/ident-reference-false-escaped.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-identifiers-static-semantics-early-errors +description: > + `false` is a reserved word and cannot be used as an identifier reference. +info: | + Identifier : IdentifierName but not ReservedWord + + It is a Syntax Error if StringValue of IdentifierName is the same String + value as the StringValue of any ReservedWord except for yield. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +f\u0061lse = 0; diff --git a/js/src/tests/test262/language/reserved-words/ident-reference-false.js b/js/src/tests/test262/language/reserved-words/ident-reference-false.js new file mode 100644 index 0000000000..bb6b849707 --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/ident-reference-false.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-identifiers-static-semantics-early-errors +description: > + `false` is a reserved word and cannot be used as an identifier reference. +info: | + Identifier : IdentifierName but not ReservedWord + + It is a Syntax Error if StringValue of IdentifierName is the same String + value as the StringValue of any ReservedWord except for yield. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +// It's tempting to write `false = 0`, but that'd be a test to validate `false` +// is not a valid simple assignment target, cf. tests in language/expressions/assignment. +// Also see: sec-semantics-static-semantics-isvalidsimpleassignmenttarget +({false}); diff --git a/js/src/tests/test262/language/reserved-words/ident-reference-null-escaped.js b/js/src/tests/test262/language/reserved-words/ident-reference-null-escaped.js new file mode 100644 index 0000000000..e23d0a9918 --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/ident-reference-null-escaped.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-identifiers-static-semantics-early-errors +description: > + `false` is a reserved word and cannot be used as an identifier reference. +info: | + Identifier : IdentifierName but not ReservedWord + + It is a Syntax Error if StringValue of IdentifierName is the same String + value as the StringValue of any ReservedWord except for yield. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +nul\u006c = 0; diff --git a/js/src/tests/test262/language/reserved-words/ident-reference-null.js b/js/src/tests/test262/language/reserved-words/ident-reference-null.js new file mode 100644 index 0000000000..aff83506db --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/ident-reference-null.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-identifiers-static-semantics-early-errors +description: > + `false` is a reserved word and cannot be used as an identifier reference. +info: | + Identifier : IdentifierName but not ReservedWord + + It is a Syntax Error if StringValue of IdentifierName is the same String + value as the StringValue of any ReservedWord except for yield. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +// It's tempting to write `null = 0`, but that'd be a test to validate `null` +// is not a valid simple assignment target, cf. tests in language/expressions/assignment. +// Also see: sec-semantics-static-semantics-isvalidsimpleassignmenttarget +({null}); diff --git a/js/src/tests/test262/language/reserved-words/ident-reference-true-escaped.js b/js/src/tests/test262/language/reserved-words/ident-reference-true-escaped.js new file mode 100644 index 0000000000..1d4ef20386 --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/ident-reference-true-escaped.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-identifiers-static-semantics-early-errors +description: > + `false` is a reserved word and cannot be used as an identifier reference. +info: | + Identifier : IdentifierName but not ReservedWord + + It is a Syntax Error if StringValue of IdentifierName is the same String + value as the StringValue of any ReservedWord except for yield. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +tru\u0065 = 0; diff --git a/js/src/tests/test262/language/reserved-words/ident-reference-true.js b/js/src/tests/test262/language/reserved-words/ident-reference-true.js new file mode 100644 index 0000000000..8ab0141177 --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/ident-reference-true.js @@ -0,0 +1,24 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-identifiers-static-semantics-early-errors +description: > + `false` is a reserved word and cannot be used as an identifier reference. +info: | + Identifier : IdentifierName but not ReservedWord + + It is a Syntax Error if StringValue of IdentifierName is the same String + value as the StringValue of any ReservedWord except for yield. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +// It's tempting to write `true = 0`, but that'd be a test to validate `true` +// is not a valid simple assignment target, cf. tests in language/expressions/assignment. +// Also see: sec-semantics-static-semantics-isvalidsimpleassignmenttarget +({true}); diff --git a/js/src/tests/test262/language/reserved-words/label-ident-false-escaped.js b/js/src/tests/test262/language/reserved-words/label-ident-false-escaped.js new file mode 100644 index 0000000000..3900f9647a --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/label-ident-false-escaped.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-identifiers-static-semantics-early-errors +description: > + `false` is a reserved word and cannot be used as a label identifier. +info: | + Identifier : IdentifierName but not ReservedWord + + It is a Syntax Error if StringValue of IdentifierName is the same String + value as the StringValue of any ReservedWord except for yield. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +f\u0061lse: ; diff --git a/js/src/tests/test262/language/reserved-words/label-ident-false.js b/js/src/tests/test262/language/reserved-words/label-ident-false.js new file mode 100644 index 0000000000..889055081f --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/label-ident-false.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-identifiers-static-semantics-early-errors +description: > + `false` is a reserved word and cannot be used as a label identifier. +info: | + Identifier : IdentifierName but not ReservedWord + + It is a Syntax Error if StringValue of IdentifierName is the same String + value as the StringValue of any ReservedWord except for yield. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +false: ; diff --git a/js/src/tests/test262/language/reserved-words/label-ident-null-escaped.js b/js/src/tests/test262/language/reserved-words/label-ident-null-escaped.js new file mode 100644 index 0000000000..13ec61a2ff --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/label-ident-null-escaped.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-identifiers-static-semantics-early-errors +description: > + `false` is a reserved word and cannot be used as a label identifier. +info: | + Identifier : IdentifierName but not ReservedWord + + It is a Syntax Error if StringValue of IdentifierName is the same String + value as the StringValue of any ReservedWord except for yield. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +nul\u006c: ; diff --git a/js/src/tests/test262/language/reserved-words/label-ident-null.js b/js/src/tests/test262/language/reserved-words/label-ident-null.js new file mode 100644 index 0000000000..c5a83f19bb --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/label-ident-null.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-identifiers-static-semantics-early-errors +description: > + `false` is a reserved word and cannot be used as a label identifier. +info: | + Identifier : IdentifierName but not ReservedWord + + It is a Syntax Error if StringValue of IdentifierName is the same String + value as the StringValue of any ReservedWord except for yield. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +null: ; diff --git a/js/src/tests/test262/language/reserved-words/label-ident-true-escaped.js b/js/src/tests/test262/language/reserved-words/label-ident-true-escaped.js new file mode 100644 index 0000000000..b45944d878 --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/label-ident-true-escaped.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-identifiers-static-semantics-early-errors +description: > + `false` is a reserved word and cannot be used as a label identifier. +info: | + Identifier : IdentifierName but not ReservedWord + + It is a Syntax Error if StringValue of IdentifierName is the same String + value as the StringValue of any ReservedWord except for yield. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +tru\u0065: ; diff --git a/js/src/tests/test262/language/reserved-words/label-ident-true.js b/js/src/tests/test262/language/reserved-words/label-ident-true.js new file mode 100644 index 0000000000..8557001538 --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/label-ident-true.js @@ -0,0 +1,21 @@ +// |reftest| error:SyntaxError +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-identifiers-static-semantics-early-errors +description: > + `false` is a reserved word and cannot be used as a label identifier. +info: | + Identifier : IdentifierName but not ReservedWord + + It is a Syntax Error if StringValue of IdentifierName is the same String + value as the StringValue of any ReservedWord except for yield. +negative: + phase: parse + type: SyntaxError +---*/ + +$DONOTEVALUATE(); + +true: ; diff --git a/js/src/tests/test262/language/reserved-words/shell.js b/js/src/tests/test262/language/reserved-words/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/shell.js diff --git a/js/src/tests/test262/language/reserved-words/unreserved-words.js b/js/src/tests/test262/language/reserved-words/unreserved-words.js new file mode 100644 index 0000000000..ba61c930b5 --- /dev/null +++ b/js/src/tests/test262/language/reserved-words/unreserved-words.js @@ -0,0 +1,121 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: List of words that are not reserved +es5id: 7.6.1_A2 +description: Try assign 1 for not reserved words +---*/ + +// a +var and = 1; +var and_eq = 1; +var as = 1; +var asm = 1; +var assert = 1; +var auto = 1; +// b +var base = 1; +var bitand = 1; +var bitor = 1; +var bool = 1; +var byvalue = 1; +// c +var checked = 1; +var clone = 1; +var comment = 1; +var compl = 1; +var const_cast = 1; +// d +var decimal = 1; +var delegate = 1; +var dynamic_cast = 1; +// e +var explicit = 1; +var extern = 1; +var equals = 1; +var event = 1; +// f +var finalize = 1; +var fixed = 1; +var friend = 1; +var foreach = 1; +var future = 1; +// g +var getClass = 1; +var generic = 1; +// h +var hashCode = 1; +// i +var implicit = 1; +var infinity = 1; +var inline = 1; +var inner = 1; +var internal = 1; +var is = 1; +// j +// k +// l +var lock = 1; +// m +var mutable = 1; +// n +var namespace = 1; +var not = 1; +var notify = 1; +var notifyAll = 1; +var not_eq = 1; +// o +var object = 1; +var operator = 1; +var or = 1; +var or_eq = 1; +var out = 1; +var outer = 1; +var override = 1; +// p +var params = 1; +// q +// r +var readonly = 1; +var reinterpret_cast = 1; +var ref = 1; +var register = 1; + +// s +var sbyte = 1; +var signed = 1; +var sizeof = 1; +var stackalloc = 1; +var static_cast = 1; +var string = 1; +var strictfp = 1; +var struct = 1; +// t +var template = 1; +var toString = 1; +var typedef = 1; +var typeid = 1; +// u +var uint = 1; +var unchecked = 1; +var undefiend = 1; +var union = 1; +var unsafe = 1; +var unsigned = 1; +var use = 1; +var using = 1; +var ushort = 1; +// v +var valueOf = 1; +var virtual = 1; +// w +var wait = 1; +var wchar_t = 1; +// x +var xor = 1; +var xor_eq = 1; +// y +// z + +reportCompare(0, 0); |