From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../non262/strict/eval-variable-environment.js | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 js/src/tests/non262/strict/eval-variable-environment.js (limited to 'js/src/tests/non262/strict/eval-variable-environment.js') diff --git a/js/src/tests/non262/strict/eval-variable-environment.js b/js/src/tests/non262/strict/eval-variable-environment.js new file mode 100644 index 0000000000..a10f43f431 --- /dev/null +++ b/js/src/tests/non262/strict/eval-variable-environment.js @@ -0,0 +1,67 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var code; + +code = + "eval('var x = 2; typeof x');"; +assertEq(testLenientAndStrict(code, returns("number"), returns("number")), + true); + +code = + "eval('\"use strict\"; var x = 2; typeof x');"; +assertEq(testLenientAndStrict(code, returns("number"), returns("number")), + true); + +code = + "eval('var x = 2;'); " + + "typeof x"; +assertEq(testLenientAndStrict(code, returns("number"), returns("undefined")), + true); + +code = + "eval('\"use strict\"; var x = 2;'); " + + "typeof x"; +assertEq(testLenientAndStrict(code, returns("undefined"), returns("undefined")), + true); + +code = + "eval('\"use strict\"; var x = 2; typeof x'); " + + "typeof x"; +assertEq(testLenientAndStrict(code, returns("undefined"), returns("undefined")), + true); + +code = + "function test() " + + "{ " + + " eval('var x = 2;'); " + + " return typeof x; " + + "} " + + "test();"; +assertEq(testLenientAndStrict(code, returns("number"), returns("undefined")), + true); + +code = + "function test() " + + "{ " + + " 'use strict'; " + + " eval('var x = 2;'); " + + " return typeof x; " + + "} " + + "test();"; +assertEq(testLenientAndStrict(code, returns("undefined"), returns("undefined")), + true); + +code = + "function test() " + + "{ " + + " eval('\"use strict\"; var x = 2;'); " + + " return typeof x; " + + "} " + + "test();"; +assertEq(testLenientAndStrict(code, returns("undefined"), returns("undefined")), + true); + +reportCompare(true, true); -- cgit v1.2.3