summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/eval/exhaustive-global-normalcaller-direct-normalcode.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/non262/eval/exhaustive-global-normalcaller-direct-normalcode.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/non262/eval/exhaustive-global-normalcaller-direct-normalcode.js')
-rw-r--r--js/src/tests/non262/eval/exhaustive-global-normalcaller-direct-normalcode.js172
1 files changed, 172 insertions, 0 deletions
diff --git a/js/src/tests/non262/eval/exhaustive-global-normalcaller-direct-normalcode.js b/js/src/tests/non262/eval/exhaustive-global-normalcaller-direct-normalcode.js
new file mode 100644
index 0000000000..cb56508527
--- /dev/null
+++ b/js/src/tests/non262/eval/exhaustive-global-normalcaller-direct-normalcode.js
@@ -0,0 +1,172 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 514568;
+var summary = "eval in all its myriad flavors";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+var x = 17;
+
+var ev = eval;
+
+var xcode =
+ "var x = 4;" +
+ "function actX(action)" +
+ "{" +
+ " switch (action)" +
+ " {" +
+ " case 'get':" +
+ " return x;" +
+ " case 'set1':" +
+ " x = 9;" +
+ " return;" +
+ " case 'set2':" +
+ " x = 23;" +
+ " return;" +
+ " case 'delete':" +
+ " try { return eval('delete x'); }" +
+ " catch (e) { return e.name; }" +
+ " }" +
+ "}" +
+ "actX;";
+
+var local0 = x;
+
+var f = eval(xcode);
+
+var inner1 = f("get");
+var local1 = x;
+
+x = 7;
+var inner2 = f("get");
+var local2 = x;
+
+f("set1");
+var inner3 = f("get");
+var local3 = x;
+
+var del = f("delete");
+var inner4 = f("get");
+var local4 = x;
+
+f("set2");
+var inner5 = f("get");
+var local5 = x;
+
+var resultsX =
+ {
+ local0: local0,
+ inner1: inner1, local1: local1,
+ inner2: inner2, local2: local2,
+ inner3: inner3, local3: local3,
+ del: del,
+ inner4: inner4, local4: local4,
+ inner5: inner5, local5: local5,
+ };
+
+assertEq(resultsX.local0, 17);
+
+assertEq(resultsX.inner1, 4);
+assertEq(resultsX.local1, 4);
+
+assertEq(resultsX.inner2, 7);
+assertEq(resultsX.local2, 7);
+
+assertEq(resultsX.inner3, 9);
+assertEq(resultsX.local3, 9);
+
+assertEq(resultsX.del, false);
+
+assertEq(resultsX.inner4, 9);
+assertEq(resultsX.local4, 9);
+
+assertEq(resultsX.inner5, 23);
+assertEq(resultsX.local5, 23);
+
+
+var ycode =
+ "var y = 5;" +
+ "function actY(action)" +
+ "{" +
+ " switch (action)" +
+ " {" +
+ " case 'get':" +
+ " return y;" +
+ " case 'set1':" +
+ " y = 2;" +
+ " return;" +
+ " case 'set2':" +
+ " y = 71;" +
+ " return;" +
+ " case 'delete':" +
+ " try { return eval('delete y'); }" +
+ " catch (e) { return e.name; }" +
+ " }" +
+ "}" +
+ "actY;";
+
+try { var local0 = y; } catch (e) { local0 = e.name; }
+
+var f = eval(ycode);
+
+var inner1 = f("get");
+var local1 = y;
+
+y = 8;
+var inner2 = f("get");
+var local2 = y;
+
+f("set1");
+var inner3 = f("get");
+var local3 = y;
+
+var del = f("delete");
+try { var inner4 = f("get"); } catch (e) { inner4 = e.name; }
+try { var local4 = y; } catch (e) { local4 = e.name; }
+
+f("set2");
+try { var inner5 = f("get"); } catch (e) { inner5 = e.name; }
+try { var local5 = y; } catch (e) { local5 = e.name; }
+
+var resultsY =
+ {
+ local0: local0,
+ inner1: inner1, local1: local1,
+ inner2: inner2, local2: local2,
+ inner3: inner3, local3: local3,
+ del: del,
+ inner4: inner4, local4: local4,
+ inner5: inner5, local5: local5,
+ };
+
+assertEq(resultsY.local0, "ReferenceError");
+
+assertEq(resultsY.inner1, 5);
+assertEq(resultsY.local1, 5);
+
+assertEq(resultsY.inner2, 8);
+assertEq(resultsY.local2, 8);
+
+assertEq(resultsY.inner3, 2);
+assertEq(resultsY.local3, 2);
+
+assertEq(resultsY.del, true);
+
+assertEq(resultsY.inner4, "ReferenceError");
+assertEq(resultsY.local4, "ReferenceError");
+
+assertEq(resultsY.inner5, 71);
+assertEq(resultsY.local5, 71);
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("Tests complete!");