diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/jit-test/tests/basic/object-shorthand.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/jit-test/tests/basic/object-shorthand.js')
-rw-r--r-- | js/src/jit-test/tests/basic/object-shorthand.js | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/basic/object-shorthand.js b/js/src/jit-test/tests/basic/object-shorthand.js new file mode 100644 index 000000000..934f46680 --- /dev/null +++ b/js/src/jit-test/tests/basic/object-shorthand.js @@ -0,0 +1,90 @@ + +load(libdir + 'asserts.js'); + +// globals: +a = b = get = set = eval = arguments = 10; + +assertEq({arguments}.arguments, 10); + +var o = {a, b: b, get, set: set}; +assertEq(o.a, 10); +assertEq(o.b, 10); +assertEq(o.get, 10); +assertEq(o.set, 10); + +var names = ['a', 'get', 'set', 'eval']; +// global +names.forEach(ident => + assertEq(new Function('return {' + ident + '}.' + ident + ';')(), 10)); +// local +names.forEach(ident => + assertEq(new Function('var ' + ident + ' = 20; return {' + ident + '}.' + ident + ';')(), 20)); +// scope +names.forEach(ident => + assertEq(new Function('var ' + ident + ' = 30; return (function () {return {' + ident + '}.' + ident + ';})();')(), 30)); + +var reserved = [ + 'break', + 'do', + 'in', + 'typeof', + 'case', + 'else', + 'instanceof', + 'var', + 'catch', + 'export', + 'new', + 'void', + 'class', + 'extends', + 'return', + 'while', + 'const', + 'finally', + 'super', + 'with', + 'continue', + 'for', + 'switch', + 'debugger', + 'function', + 'this', + 'delete', + 'import', + 'try', + 'enum', + 'null', + 'true', + 'false' +]; + +// non-identifiers should also throw +var nonidents = [ + '"str"', + '0' +]; + +reserved.concat(nonidents).forEach(ident => + assertThrowsInstanceOf(() => new Function('return {' + ident + '}'), SyntaxError)); + +var reservedStrict = [ + 'implements', + 'interface', + 'package', + 'private', + 'protected', + 'public', + 'static', + // XXX: according to 12.1.1, these should only be errors in strict code: + // see https://bugzilla.mozilla.org/show_bug.cgi?id=1032150 + //'let', + //'yield' +]; + +reservedStrict.forEach(ident => + assertEq(new Function('var ' + ident + ' = 10; return {' + ident + '}.' + ident + ';')(), 10)); + +reservedStrict.concat(['let', 'yield']).forEach(ident => + assertThrowsInstanceOf(() => new Function('"use strict"; return {' + ident + '}'), SyntaxError)); + |