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/tests/js1_8_1/strict | |
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/tests/js1_8_1/strict')
-rw-r--r-- | js/src/tests/js1_8_1/strict/12.2.1.js | 75 | ||||
-rw-r--r-- | js/src/tests/js1_8_1/strict/8.7.2.js | 17 | ||||
-rw-r--r-- | js/src/tests/js1_8_1/strict/shell.js | 88 |
3 files changed, 180 insertions, 0 deletions
diff --git a/js/src/tests/js1_8_1/strict/12.2.1.js b/js/src/tests/js1_8_1/strict/12.2.1.js new file mode 100644 index 000000000..674c7a7c6 --- /dev/null +++ b/js/src/tests/js1_8_1/strict/12.2.1.js @@ -0,0 +1,75 @@ +// |reftest| skip-if(Android) +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ + +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +/* + * In strict mode code, 'let' and 'const' declarations may not bind + * 'eval' or 'arguments'. + */ +assertEq(testLenientAndStrict('let eval;', + parsesSuccessfully, + parseRaisesException(SyntaxError)), + true); +assertEq(testLenientAndStrict('let x,eval;', + parsesSuccessfully, + parseRaisesException(SyntaxError)), + true); +assertEq(testLenientAndStrict('let arguments;', + parsesSuccessfully, + parseRaisesException(SyntaxError)), + true); +assertEq(testLenientAndStrict('let x,arguments;', + parsesSuccessfully, + parseRaisesException(SyntaxError)), + true); +assertEq(testLenientAndStrict('const eval = undefined;', + parsesSuccessfully, + parseRaisesException(SyntaxError)), + true); +assertEq(testLenientAndStrict('const x = undefined,eval = undefined;', + parsesSuccessfully, + parseRaisesException(SyntaxError)), + true); +assertEq(testLenientAndStrict('const arguments = undefined;', + parsesSuccessfully, + parseRaisesException(SyntaxError)), + true); +assertEq(testLenientAndStrict('const x = undefined,arguments = undefined;', + parsesSuccessfully, + parseRaisesException(SyntaxError)), + true); + +/* + * In strict mode code, 'let' declarations appearing in 'for' + * or 'for in' statements may not bind 'eval' or 'arguments'. + */ +assertEq(testLenientAndStrict('for (let eval in [])break;', + parsesSuccessfully, + parseRaisesException(SyntaxError)), + true); +assertEq(testLenientAndStrict('for (let [eval] in [])break;', + parsesSuccessfully, + parseRaisesException(SyntaxError)), + true); +assertEq(testLenientAndStrict('for (let {x:eval} in [])break;', + parsesSuccessfully, + parseRaisesException(SyntaxError)), + true); +assertEq(testLenientAndStrict('for (let arguments in [])break;', + parsesSuccessfully, + parseRaisesException(SyntaxError)), + true); +assertEq(testLenientAndStrict('for (let [arguments] in [])break;', + parsesSuccessfully, + parseRaisesException(SyntaxError)), + true); +assertEq(testLenientAndStrict('for (let {x:arguments} in [])break;', + parsesSuccessfully, + parseRaisesException(SyntaxError)), + true); + +reportCompare(true, true); diff --git a/js/src/tests/js1_8_1/strict/8.7.2.js b/js/src/tests/js1_8_1/strict/8.7.2.js new file mode 100644 index 000000000..8e1d76106 --- /dev/null +++ b/js/src/tests/js1_8_1/strict/8.7.2.js @@ -0,0 +1,17 @@ +// |reftest| skip-if(Android) +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ + +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +/* Check that assignment to a let-bound variable is permitted in both lenient and strict modes. */ + +/* Assigning to a let-declared variable is okay in strict and loose modes. */ +assertEq(testLenientAndStrict('let let_declared; let_declared=1', + completesNormally, + completesNormally), + true); + +reportCompare(true, true); diff --git a/js/src/tests/js1_8_1/strict/shell.js b/js/src/tests/js1_8_1/strict/shell.js new file mode 100644 index 000000000..7469bbf94 --- /dev/null +++ b/js/src/tests/js1_8_1/strict/shell.js @@ -0,0 +1,88 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ + +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + + +/* + * Return true if both of these return true: + * - LENIENT_PRED applied to CODE + * - STRICT_PRED applied to CODE with a use strict directive added to the front + * + * Run STRICT_PRED first, for testing code that affects the global environment + * in loose mode, but fails in strict mode. + */ +function testLenientAndStrict(code, lenient_pred, strict_pred) { + return (strict_pred("'use strict'; " + code) && + lenient_pred(code)); +} + +/* + * completesNormally(CODE) returns true if evaluating CODE (as eval + * code) completes normally (rather than throwing an exception). + */ +function completesNormally(code) { + try { + eval(code); + return true; + } catch (exception) { + return false; + } +} + +/* + * raisesException(EXCEPTION)(CODE) returns true if evaluating CODE (as eval + * code) throws an exception object whose prototype is + * EXCEPTION.prototype, and returns false if it throws any other error + * or evaluates successfully. For example: raises(TypeError)("0()") == + * true. + */ +function raisesException(exception) { + return function (code) { + try { + eval(code); + return false; + } catch (actual) { + return exception.prototype.isPrototypeOf(actual); + } + }; +}; + +/* + * parsesSuccessfully(CODE) returns true if CODE parses as function + * code without an error. + */ +function parsesSuccessfully(code) { + try { + Function(code); + return true; + } catch (exception) { + return false; + } +}; + +/* + * parseRaisesException(EXCEPTION)(CODE) returns true if parsing CODE + * as function code raises EXCEPTION. + */ +function parseRaisesException(exception) { + return function (code) { + try { + Function(code); + return false; + } catch (actual) { + return exception.prototype.isPrototypeOf(actual); + } + }; +}; + +/* + * Return the result of applying uneval to VAL, and replacing all runs + * of whitespace with a single horizontal space (poor man's + * tokenization). + */ +function clean_uneval(val) { + return uneval(val).replace(/\s+/g, ' '); +} |