diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /js/src/tests/non262/eval | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
22 files changed, 3245 insertions, 0 deletions
diff --git a/js/src/tests/non262/eval/browser.js b/js/src/tests/non262/eval/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/non262/eval/browser.js diff --git a/js/src/tests/non262/eval/exhaustive-fun-normalcaller-direct-normalcode.js b/js/src/tests/non262/eval/exhaustive-fun-normalcaller-direct-normalcode.js new file mode 100644 index 0000000000..1a4b56c635 --- /dev/null +++ b/js/src/tests/non262/eval/exhaustive-fun-normalcaller-direct-normalcode.js @@ -0,0 +1,208 @@ +// 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; +function globalX() { return x; } +var y = 42; +function globalY() { return y; } + +var ev = eval; + +function testX() +{ + var x = 2; + 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 global0 = globalX(); + + var f = eval(xcode); + + var inner1 = f("get"); + var local1 = x; + var global1 = globalX(); + + x = 7; + var inner2 = f("get"); + var local2 = x; + var global2 = globalX(); + + f("set1"); + var inner3 = f("get"); + var local3 = x; + var global3 = globalX(); + + var del = f("delete"); + var inner4 = f("get"); + var local4 = x; + var global4 = globalX(); + + f("set2"); + var inner5 = f("get"); + var local5 = x; + var global5 = globalX(); + + return { + local0: local0, global0: global0, + inner1: inner1, local1: local1, global1: global1, + inner2: inner2, local2: local2, global2: global2, + inner3: inner3, local3: local3, global3: global3, + del: del, + inner4: inner4, local4: local4, global4: global4, + inner5: inner5, local5: local5, global5: global5, + }; +} + +var resultsX = testX(); + +assertEq(resultsX.local0, 2); +assertEq(resultsX.global0, 17); + +assertEq(resultsX.inner1, 4); +assertEq(resultsX.local1, 4); +assertEq(resultsX.global1, 17); + +assertEq(resultsX.inner2, 7); +assertEq(resultsX.local2, 7); +assertEq(resultsX.global2, 17); + +assertEq(resultsX.inner3, 9); +assertEq(resultsX.local3, 9); +assertEq(resultsX.global3, 17); + +assertEq(resultsX.del, false); + +assertEq(resultsX.inner4, 9); +assertEq(resultsX.local4, 9); +assertEq(resultsX.global4, 17); + +assertEq(resultsX.inner5, 23); +assertEq(resultsX.local5, 23); +assertEq(resultsX.global5, 17); + + +function testY() +{ + 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;"; + + var local0 = y; + var global0 = globalY(); + + var f = eval(ycode); + + var inner1 = f("get"); + var local1 = y; + var global1 = globalY(); + + y = 8; + var inner2 = f("get"); + var local2 = y; + var global2 = globalY(); + + f("set1"); + var inner3 = f("get"); + var local3 = y; + var global3 = globalY(); + + var del = f("delete"); + var inner4 = f("get"); + var local4 = y; + var global4 = globalY(); + + f("set2"); + var inner5 = f("get"); + var local5 = y; + var global5 = globalY(); + + return { + local0: local0, global0: global0, + inner1: inner1, local1: local1, global1: global1, + inner2: inner2, local2: local2, global2: global2, + inner3: inner3, local3: local3, global3: global3, + del: del, + inner4: inner4, local4: local4, global4: global4, + inner5: inner5, local5: local5, global5: global5, + }; +} + +var resultsY = testY(); + +assertEq(resultsY.local0, 42); +assertEq(resultsY.global0, 42); + +assertEq(resultsY.inner1, 5); +assertEq(resultsY.local1, 5); +assertEq(resultsY.global1, 42); + +assertEq(resultsY.inner2, 8); +assertEq(resultsY.local2, 8); +assertEq(resultsY.global2, 42); + +assertEq(resultsY.inner3, 2); +assertEq(resultsY.local3, 2); +assertEq(resultsY.global3, 42); + +assertEq(resultsY.del, true); + +assertEq(resultsY.inner4, 42); +assertEq(resultsY.local4, 42); +assertEq(resultsY.global4, 42); + +assertEq(resultsY.inner5, 71); +assertEq(resultsY.local5, 71); +assertEq(resultsY.global5, 71); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete!"); diff --git a/js/src/tests/non262/eval/exhaustive-fun-normalcaller-direct-strictcode.js b/js/src/tests/non262/eval/exhaustive-fun-normalcaller-direct-strictcode.js new file mode 100644 index 0000000000..7bd4ea6585 --- /dev/null +++ b/js/src/tests/non262/eval/exhaustive-fun-normalcaller-direct-strictcode.js @@ -0,0 +1,210 @@ +// 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; +function globalX() { return x; } +var y = 42; +function globalY() { return y; } + +var ev = eval; + +function testX() +{ + var x = 2; + var xcode = + "'use strict';" + + "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 global0 = globalX(); + + var f = eval(xcode); + + var inner1 = f("get"); + var local1 = x; + var global1 = globalX(); + + x = 7; + var inner2 = f("get"); + var local2 = x; + var global2 = globalX(); + + f("set1"); + var inner3 = f("get"); + var local3 = x; + var global3 = globalX(); + + var del = f("delete"); + var inner4 = f("get"); + var local4 = x; + var global4 = globalX(); + + f("set2"); + var inner5 = f("get"); + var local5 = x; + var global5 = globalX(); + + return { + local0: local0, global0: global0, + inner1: inner1, local1: local1, global1: global1, + inner2: inner2, local2: local2, global2: global2, + inner3: inner3, local3: local3, global3: global3, + del: del, + inner4: inner4, local4: local4, global4: global4, + inner5: inner5, local5: local5, global5: global5, + }; +} + +var resultsX = testX(); + +assertEq(resultsX.local0, 2); +assertEq(resultsX.global0, 17); + +assertEq(resultsX.inner1, 4); +assertEq(resultsX.local1, 2); +assertEq(resultsX.global1, 17); + +assertEq(resultsX.inner2, 4); +assertEq(resultsX.local2, 7); +assertEq(resultsX.global2, 17); + +assertEq(resultsX.inner3, 9); +assertEq(resultsX.local3, 7); +assertEq(resultsX.global3, 17); + +assertEq(resultsX.del, "SyntaxError"); + +assertEq(resultsX.inner4, 9); +assertEq(resultsX.local4, 7); +assertEq(resultsX.global4, 17); + +assertEq(resultsX.inner5, 23); +assertEq(resultsX.local5, 7); +assertEq(resultsX.global5, 17); + + +function testY() +{ + var ycode = + "'use strict';" + + "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;"; + + var local0 = y; + var global0 = globalY(); + + var f = eval(ycode); + + var inner1 = f("get"); + var local1 = y; + var global1 = globalY(); + + y = 8; + var inner2 = f("get"); + var local2 = y; + var global2 = globalY(); + + f("set1"); + var inner3 = f("get"); + var local3 = y; + var global3 = globalY(); + + var del = f("delete"); + var inner4 = f("get"); + var local4 = y; + var global4 = globalY(); + + f("set2"); + var inner5 = f("get"); + var local5 = y; + var global5 = globalY(); + + return { + local0: local0, global0: global0, + inner1: inner1, local1: local1, global1: global1, + inner2: inner2, local2: local2, global2: global2, + inner3: inner3, local3: local3, global3: global3, + del: del, + inner4: inner4, local4: local4, global4: global4, + inner5: inner5, local5: local5, global5: global5, + }; +} + +var resultsY = testY(); + +assertEq(resultsY.local0, 42); +assertEq(resultsY.global0, 42); + +assertEq(resultsY.inner1, 5); +assertEq(resultsY.local1, 42); +assertEq(resultsY.global1, 42); + +assertEq(resultsY.inner2, 5); +assertEq(resultsY.local2, 8); +assertEq(resultsY.global2, 8); + +assertEq(resultsY.inner3, 2); +assertEq(resultsY.local3, 8); +assertEq(resultsY.global3, 8); + +assertEq(resultsY.del, "SyntaxError"); + +assertEq(resultsY.inner4, 2); +assertEq(resultsY.local4, 8); +assertEq(resultsY.global4, 8); + +assertEq(resultsY.inner5, 71); +assertEq(resultsY.local5, 8); +assertEq(resultsY.global5, 8); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete!"); diff --git a/js/src/tests/non262/eval/exhaustive-fun-normalcaller-indirect-normalcode.js b/js/src/tests/non262/eval/exhaustive-fun-normalcaller-indirect-normalcode.js new file mode 100644 index 0000000000..d75496fa51 --- /dev/null +++ b/js/src/tests/non262/eval/exhaustive-fun-normalcaller-indirect-normalcode.js @@ -0,0 +1,208 @@ +// 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; +function globalX() { return x; } +var y = 42; +function globalY() { return y; } + +var ev = eval; + +function testX() +{ + var x = 2; + 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 global0 = globalX(); + + var f = ev(xcode); + + var inner1 = f("get"); + var local1 = x; + var global1 = globalX(); + + x = 7; + var inner2 = f("get"); + var local2 = x; + var global2 = globalX(); + + f("set1"); + var inner3 = f("get"); + var local3 = x; + var global3 = globalX(); + + var del = f("delete"); + var inner4 = f("get"); + var local4 = x; + var global4 = globalX(); + + f("set2"); + var inner5 = f("get"); + var local5 = x; + var global5 = globalX(); + + return { + local0: local0, global0: global0, + inner1: inner1, local1: local1, global1: global1, + inner2: inner2, local2: local2, global2: global2, + inner3: inner3, local3: local3, global3: global3, + del: del, + inner4: inner4, local4: local4, global4: global4, + inner5: inner5, local5: local5, global5: global5, + }; +} + +var resultsX = testX(); + +assertEq(resultsX.local0, 2); +assertEq(resultsX.global0, 17); + +assertEq(resultsX.inner1, 4); +assertEq(resultsX.local1, 2); +assertEq(resultsX.global1, 4); + +assertEq(resultsX.inner2, 4); +assertEq(resultsX.local2, 7); +assertEq(resultsX.global2, 4); + +assertEq(resultsX.inner3, 9); +assertEq(resultsX.local3, 7); +assertEq(resultsX.global3, 9); + +assertEq(resultsX.del, false); + +assertEq(resultsX.inner4, 9); +assertEq(resultsX.local4, 7); +assertEq(resultsX.global4, 9); + +assertEq(resultsX.inner5, 23); +assertEq(resultsX.local5, 7); +assertEq(resultsX.global5, 23); + + +function testY() +{ + 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;"; + + var local0 = y; + var global0 = globalY(); + + var f = ev(ycode); + + var inner1 = f("get"); + var local1 = y; + var global1 = globalY(); + + y = 8; + var inner2 = f("get"); + var local2 = y; + var global2 = globalY(); + + f("set1"); + var inner3 = f("get"); + var local3 = y; + var global3 = globalY(); + + var del = f("delete"); + var inner4 = f("get"); + var local4 = y; + var global4 = globalY(); + + f("set2"); + var inner5 = f("get"); + var local5 = y; + var global5 = globalY(); + + return { + local0: local0, global0: global0, + inner1: inner1, local1: local1, global1: global1, + inner2: inner2, local2: local2, global2: global2, + inner3: inner3, local3: local3, global3: global3, + del: del, + inner4: inner4, local4: local4, global4: global4, + inner5: inner5, local5: local5, global5: global5, + }; +} + +var resultsY = testY(); + +assertEq(resultsY.local0, 42); +assertEq(resultsY.global0, 42); + +assertEq(resultsY.inner1, 5); +assertEq(resultsY.local1, 5); +assertEq(resultsY.global1, 5); + +assertEq(resultsY.inner2, 8); +assertEq(resultsY.local2, 8); +assertEq(resultsY.global2, 8); + +assertEq(resultsY.inner3, 2); +assertEq(resultsY.local3, 2); +assertEq(resultsY.global3, 2); + +assertEq(resultsY.del, false); + +assertEq(resultsY.inner4, 2); +assertEq(resultsY.local4, 2); +assertEq(resultsY.global4, 2); + +assertEq(resultsY.inner5, 71); +assertEq(resultsY.local5, 71); +assertEq(resultsY.global5, 71); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete!"); diff --git a/js/src/tests/non262/eval/exhaustive-fun-normalcaller-indirect-strictcode.js b/js/src/tests/non262/eval/exhaustive-fun-normalcaller-indirect-strictcode.js new file mode 100644 index 0000000000..f38fc1b58e --- /dev/null +++ b/js/src/tests/non262/eval/exhaustive-fun-normalcaller-indirect-strictcode.js @@ -0,0 +1,210 @@ +// 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; +function globalX() { return x; } +var y = 42; +function globalY() { return y; } + +var ev = eval; + +function testX() +{ + var x = 2; + var xcode = + "'use strict';" + + "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 global0 = globalX(); + + var f = ev(xcode); + + var inner1 = f("get"); + var local1 = x; + var global1 = globalX(); + + x = 7; + var inner2 = f("get"); + var local2 = x; + var global2 = globalX(); + + f("set1"); + var inner3 = f("get"); + var local3 = x; + var global3 = globalX(); + + var del = f("delete"); + var inner4 = f("get"); + var local4 = x; + var global4 = globalX(); + + f("set2"); + var inner5 = f("get"); + var local5 = x; + var global5 = globalX(); + + return { + local0: local0, global0: global0, + inner1: inner1, local1: local1, global1: global1, + inner2: inner2, local2: local2, global2: global2, + inner3: inner3, local3: local3, global3: global3, + del: del, + inner4: inner4, local4: local4, global4: global4, + inner5: inner5, local5: local5, global5: global5, + }; +} + +var resultsX = testX(); + +assertEq(resultsX.local0, 2); +assertEq(resultsX.global0, 17); + +assertEq(resultsX.inner1, 4); +assertEq(resultsX.local1, 2); +assertEq(resultsX.global1, 17); + +assertEq(resultsX.inner2, 4); +assertEq(resultsX.local2, 7); +assertEq(resultsX.global2, 17); + +assertEq(resultsX.inner3, 9); +assertEq(resultsX.local3, 7); +assertEq(resultsX.global3, 17); + +assertEq(resultsX.del, "SyntaxError"); + +assertEq(resultsX.inner4, 9); +assertEq(resultsX.local4, 7); +assertEq(resultsX.global4, 17); + +assertEq(resultsX.inner5, 23); +assertEq(resultsX.local5, 7); +assertEq(resultsX.global5, 17); + + +function testY() +{ + var ycode = + "'use strict';" + + "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;"; + + var local0 = y; + var global0 = globalY(); + + var f = ev(ycode); + + var inner1 = f("get"); + var local1 = y; + var global1 = globalY(); + + y = 8; + var inner2 = f("get"); + var local2 = y; + var global2 = globalY(); + + f("set1"); + var inner3 = f("get"); + var local3 = y; + var global3 = globalY(); + + var del = f("delete"); + var inner4 = f("get"); + var local4 = y; + var global4 = globalY(); + + f("set2"); + var inner5 = f("get"); + var local5 = y; + var global5 = globalY(); + + return { + local0: local0, global0: global0, + inner1: inner1, local1: local1, global1: global1, + inner2: inner2, local2: local2, global2: global2, + inner3: inner3, local3: local3, global3: global3, + del: del, + inner4: inner4, local4: local4, global4: global4, + inner5: inner5, local5: local5, global5: global5, + }; +} + +var resultsY = testY(); + +assertEq(resultsY.local0, 42); +assertEq(resultsY.global0, 42); + +assertEq(resultsY.inner1, 5); +assertEq(resultsY.local1, 42); +assertEq(resultsY.global1, 42); + +assertEq(resultsY.inner2, 5); +assertEq(resultsY.local2, 8); +assertEq(resultsY.global2, 8); + +assertEq(resultsY.inner3, 2); +assertEq(resultsY.local3, 8); +assertEq(resultsY.global3, 8); + +assertEq(resultsY.del, "SyntaxError"); + +assertEq(resultsY.inner4, 2); +assertEq(resultsY.local4, 8); +assertEq(resultsY.global4, 8); + +assertEq(resultsY.inner5, 71); +assertEq(resultsY.local5, 8); +assertEq(resultsY.global5, 8); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete!"); diff --git a/js/src/tests/non262/eval/exhaustive-fun-strictcaller-direct-normalcode.js b/js/src/tests/non262/eval/exhaustive-fun-strictcaller-direct-normalcode.js new file mode 100644 index 0000000000..5d556458b8 --- /dev/null +++ b/js/src/tests/non262/eval/exhaustive-fun-strictcaller-direct-normalcode.js @@ -0,0 +1,212 @@ +// 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; +function globalX() { return x; } +var y = 42; +function globalY() { return y; } + +var ev = eval; + +function testX() +{ + "use strict"; + + var x = 2; + 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 global0 = globalX(); + + var f = eval(xcode); + + var inner1 = f("get"); + var local1 = x; + var global1 = globalX(); + + x = 7; + var inner2 = f("get"); + var local2 = x; + var global2 = globalX(); + + f("set1"); + var inner3 = f("get"); + var local3 = x; + var global3 = globalX(); + + var del = f("delete"); + var inner4 = f("get"); + var local4 = x; + var global4 = globalX(); + + f("set2"); + var inner5 = f("get"); + var local5 = x; + var global5 = globalX(); + + return { + local0: local0, global0: global0, + inner1: inner1, local1: local1, global1: global1, + inner2: inner2, local2: local2, global2: global2, + inner3: inner3, local3: local3, global3: global3, + del: del, + inner4: inner4, local4: local4, global4: global4, + inner5: inner5, local5: local5, global5: global5, + }; +} + +var resultsX = testX(); + +assertEq(resultsX.local0, 2); +assertEq(resultsX.global0, 17); + +assertEq(resultsX.inner1, 4); +assertEq(resultsX.local1, 2); +assertEq(resultsX.global1, 17); + +assertEq(resultsX.inner2, 4); +assertEq(resultsX.local2, 7); +assertEq(resultsX.global2, 17); + +assertEq(resultsX.inner3, 9); +assertEq(resultsX.local3, 7); +assertEq(resultsX.global3, 17); + +assertEq(resultsX.del, "SyntaxError"); + +assertEq(resultsX.inner4, 9); +assertEq(resultsX.local4, 7); +assertEq(resultsX.global4, 17); + +assertEq(resultsX.inner5, 23); +assertEq(resultsX.local5, 7); +assertEq(resultsX.global5, 17); + + +function testY() +{ + "use strict"; + + 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;"; + + var local0 = y; + var global0 = globalY(); + + var f = eval(ycode); + + var inner1 = f("get"); + var local1 = y; + var global1 = globalY(); + + y = 8; + var inner2 = f("get"); + var local2 = y; + var global2 = globalY(); + + f("set1"); + var inner3 = f("get"); + var local3 = y; + var global3 = globalY(); + + var del = f("delete"); + var inner4 = f("get"); + var local4 = y; + var global4 = globalY(); + + f("set2"); + var inner5 = f("get"); + var local5 = y; + var global5 = globalY(); + + return { + local0: local0, global0: global0, + inner1: inner1, local1: local1, global1: global1, + inner2: inner2, local2: local2, global2: global2, + inner3: inner3, local3: local3, global3: global3, + del: del, + inner4: inner4, local4: local4, global4: global4, + inner5: inner5, local5: local5, global5: global5, + }; +} + +var resultsY = testY(); + +assertEq(resultsY.local0, 42); +assertEq(resultsY.global0, 42); + +assertEq(resultsY.inner1, 5); +assertEq(resultsY.local1, 42); +assertEq(resultsY.global1, 42); + +assertEq(resultsY.inner2, 5); +assertEq(resultsY.local2, 8); +assertEq(resultsY.global2, 8); + +assertEq(resultsY.inner3, 2); +assertEq(resultsY.local3, 8); +assertEq(resultsY.global3, 8); + +assertEq(resultsY.del, "SyntaxError"); + +assertEq(resultsY.inner4, 2); +assertEq(resultsY.local4, 8); +assertEq(resultsY.global4, 8); + +assertEq(resultsY.inner5, 71); +assertEq(resultsY.local5, 8); +assertEq(resultsY.global5, 8); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete!"); diff --git a/js/src/tests/non262/eval/exhaustive-fun-strictcaller-direct-strictcode.js b/js/src/tests/non262/eval/exhaustive-fun-strictcaller-direct-strictcode.js new file mode 100644 index 0000000000..a215a3ce70 --- /dev/null +++ b/js/src/tests/non262/eval/exhaustive-fun-strictcaller-direct-strictcode.js @@ -0,0 +1,214 @@ +// 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; +function globalX() { return x; } +var y = 42; +function globalY() { return y; } + +var ev = eval; + +function testX() +{ + "use strict"; + + var x = 2; + var xcode = + "'use strict';" + + "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 global0 = globalX(); + + var f = eval(xcode); + + var inner1 = f("get"); + var local1 = x; + var global1 = globalX(); + + x = 7; + var inner2 = f("get"); + var local2 = x; + var global2 = globalX(); + + f("set1"); + var inner3 = f("get"); + var local3 = x; + var global3 = globalX(); + + var del = f("delete"); + var inner4 = f("get"); + var local4 = x; + var global4 = globalX(); + + f("set2"); + var inner5 = f("get"); + var local5 = x; + var global5 = globalX(); + + return { + local0: local0, global0: global0, + inner1: inner1, local1: local1, global1: global1, + inner2: inner2, local2: local2, global2: global2, + inner3: inner3, local3: local3, global3: global3, + del: del, + inner4: inner4, local4: local4, global4: global4, + inner5: inner5, local5: local5, global5: global5, + }; +} + +var resultsX = testX(); + +assertEq(resultsX.local0, 2); +assertEq(resultsX.global0, 17); + +assertEq(resultsX.inner1, 4); +assertEq(resultsX.local1, 2); +assertEq(resultsX.global1, 17); + +assertEq(resultsX.inner2, 4); +assertEq(resultsX.local2, 7); +assertEq(resultsX.global2, 17); + +assertEq(resultsX.inner3, 9); +assertEq(resultsX.local3, 7); +assertEq(resultsX.global3, 17); + +assertEq(resultsX.del, "SyntaxError"); + +assertEq(resultsX.inner4, 9); +assertEq(resultsX.local4, 7); +assertEq(resultsX.global4, 17); + +assertEq(resultsX.inner5, 23); +assertEq(resultsX.local5, 7); +assertEq(resultsX.global5, 17); + + +function testY() +{ + "use strict"; + + var ycode = + "'use strict';" + + "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;"; + + var local0 = y; + var global0 = globalY(); + + var f = eval(ycode); + + var inner1 = f("get"); + var local1 = y; + var global1 = globalY(); + + y = 8; + var inner2 = f("get"); + var local2 = y; + var global2 = globalY(); + + f("set1"); + var inner3 = f("get"); + var local3 = y; + var global3 = globalY(); + + var del = f("delete"); + var inner4 = f("get"); + var local4 = y; + var global4 = globalY(); + + f("set2"); + var inner5 = f("get"); + var local5 = y; + var global5 = globalY(); + + return { + local0: local0, global0: global0, + inner1: inner1, local1: local1, global1: global1, + inner2: inner2, local2: local2, global2: global2, + inner3: inner3, local3: local3, global3: global3, + del: del, + inner4: inner4, local4: local4, global4: global4, + inner5: inner5, local5: local5, global5: global5, + }; +} + +var resultsY = testY(); + +assertEq(resultsY.local0, 42); +assertEq(resultsY.global0, 42); + +assertEq(resultsY.inner1, 5); +assertEq(resultsY.local1, 42); +assertEq(resultsY.global1, 42); + +assertEq(resultsY.inner2, 5); +assertEq(resultsY.local2, 8); +assertEq(resultsY.global2, 8); + +assertEq(resultsY.inner3, 2); +assertEq(resultsY.local3, 8); +assertEq(resultsY.global3, 8); + +assertEq(resultsY.del, "SyntaxError"); + +assertEq(resultsY.inner4, 2); +assertEq(resultsY.local4, 8); +assertEq(resultsY.global4, 8); + +assertEq(resultsY.inner5, 71); +assertEq(resultsY.local5, 8); +assertEq(resultsY.global5, 8); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete!"); diff --git a/js/src/tests/non262/eval/exhaustive-fun-strictcaller-indirect-normalcode.js b/js/src/tests/non262/eval/exhaustive-fun-strictcaller-indirect-normalcode.js new file mode 100644 index 0000000000..8b3016d2ea --- /dev/null +++ b/js/src/tests/non262/eval/exhaustive-fun-strictcaller-indirect-normalcode.js @@ -0,0 +1,212 @@ +// 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; +function globalX() { return x; } +var y = 42; +function globalY() { return y; } + +var ev = eval; + +function testX() +{ + "use strict"; + + var x = 2; + 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 global0 = globalX(); + + var f = ev(xcode); + + var inner1 = f("get"); + var local1 = x; + var global1 = globalX(); + + x = 7; + var inner2 = f("get"); + var local2 = x; + var global2 = globalX(); + + f("set1"); + var inner3 = f("get"); + var local3 = x; + var global3 = globalX(); + + var del = f("delete"); + var inner4 = f("get"); + var local4 = x; + var global4 = globalX(); + + f("set2"); + var inner5 = f("get"); + var local5 = x; + var global5 = globalX(); + + return { + local0: local0, global0: global0, + inner1: inner1, local1: local1, global1: global1, + inner2: inner2, local2: local2, global2: global2, + inner3: inner3, local3: local3, global3: global3, + del: del, + inner4: inner4, local4: local4, global4: global4, + inner5: inner5, local5: local5, global5: global5, + }; +} + +var resultsX = testX(); + +assertEq(resultsX.local0, 2); +assertEq(resultsX.global0, 17); + +assertEq(resultsX.inner1, 4); +assertEq(resultsX.local1, 2); +assertEq(resultsX.global1, 4); + +assertEq(resultsX.inner2, 4); +assertEq(resultsX.local2, 7); +assertEq(resultsX.global2, 4); + +assertEq(resultsX.inner3, 9); +assertEq(resultsX.local3, 7); +assertEq(resultsX.global3, 9); + +assertEq(resultsX.del, false); + +assertEq(resultsX.inner4, 9); +assertEq(resultsX.local4, 7); +assertEq(resultsX.global4, 9); + +assertEq(resultsX.inner5, 23); +assertEq(resultsX.local5, 7); +assertEq(resultsX.global5, 23); + + +function testY() +{ + "use strict"; + + 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;"; + + var local0 = y; + var global0 = globalY(); + + var f = ev(ycode); + + var inner1 = f("get"); + var local1 = y; + var global1 = globalY(); + + y = 8; + var inner2 = f("get"); + var local2 = y; + var global2 = globalY(); + + f("set1"); + var inner3 = f("get"); + var local3 = y; + var global3 = globalY(); + + var del = f("delete"); + var inner4 = f("get"); + var local4 = y; + var global4 = globalY(); + + f("set2"); + var inner5 = f("get"); + var local5 = y; + var global5 = globalY(); + + return { + local0: local0, global0: global0, + inner1: inner1, local1: local1, global1: global1, + inner2: inner2, local2: local2, global2: global2, + inner3: inner3, local3: local3, global3: global3, + del: del, + inner4: inner4, local4: local4, global4: global4, + inner5: inner5, local5: local5, global5: global5, + }; +} + +var resultsY = testY(); + +assertEq(resultsY.local0, 42); +assertEq(resultsY.global0, 42); + +assertEq(resultsY.inner1, 5); +assertEq(resultsY.local1, 5); +assertEq(resultsY.global1, 5); + +assertEq(resultsY.inner2, 8); +assertEq(resultsY.local2, 8); +assertEq(resultsY.global2, 8); + +assertEq(resultsY.inner3, 2); +assertEq(resultsY.local3, 2); +assertEq(resultsY.global3, 2); + +assertEq(resultsY.del, false); + +assertEq(resultsY.inner4, 2); +assertEq(resultsY.local4, 2); +assertEq(resultsY.global4, 2); + +assertEq(resultsY.inner5, 71); +assertEq(resultsY.local5, 71); +assertEq(resultsY.global5, 71); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete!"); diff --git a/js/src/tests/non262/eval/exhaustive-fun-strictcaller-indirect-strictcode.js b/js/src/tests/non262/eval/exhaustive-fun-strictcaller-indirect-strictcode.js new file mode 100644 index 0000000000..4157369bae --- /dev/null +++ b/js/src/tests/non262/eval/exhaustive-fun-strictcaller-indirect-strictcode.js @@ -0,0 +1,214 @@ +// 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; +function globalX() { return x; } +var y = 42; +function globalY() { return y; } + +var ev = eval; + +function testX() +{ + "use strict"; + + var x = 2; + var xcode = + "'use strict';" + + "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 global0 = globalX(); + + var f = ev(xcode); + + var inner1 = f("get"); + var local1 = x; + var global1 = globalX(); + + x = 7; + var inner2 = f("get"); + var local2 = x; + var global2 = globalX(); + + f("set1"); + var inner3 = f("get"); + var local3 = x; + var global3 = globalX(); + + var del = f("delete"); + var inner4 = f("get"); + var local4 = x; + var global4 = globalX(); + + f("set2"); + var inner5 = f("get"); + var local5 = x; + var global5 = globalX(); + + return { + local0: local0, global0: global0, + inner1: inner1, local1: local1, global1: global1, + inner2: inner2, local2: local2, global2: global2, + inner3: inner3, local3: local3, global3: global3, + del: del, + inner4: inner4, local4: local4, global4: global4, + inner5: inner5, local5: local5, global5: global5, + }; +} + +var resultsX = testX(); + +assertEq(resultsX.local0, 2); +assertEq(resultsX.global0, 17); + +assertEq(resultsX.inner1, 4); +assertEq(resultsX.local1, 2); +assertEq(resultsX.global1, 17); + +assertEq(resultsX.inner2, 4); +assertEq(resultsX.local2, 7); +assertEq(resultsX.global2, 17); + +assertEq(resultsX.inner3, 9); +assertEq(resultsX.local3, 7); +assertEq(resultsX.global3, 17); + +assertEq(resultsX.del, "SyntaxError"); + +assertEq(resultsX.inner4, 9); +assertEq(resultsX.local4, 7); +assertEq(resultsX.global4, 17); + +assertEq(resultsX.inner5, 23); +assertEq(resultsX.local5, 7); +assertEq(resultsX.global5, 17); + + +function testY() +{ + "use strict"; + + var ycode = + "'use strict';" + + "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;"; + + var local0 = y; + var global0 = globalY(); + + var f = ev(ycode); + + var inner1 = f("get"); + var local1 = y; + var global1 = globalY(); + + y = 8; + var inner2 = f("get"); + var local2 = y; + var global2 = globalY(); + + f("set1"); + var inner3 = f("get"); + var local3 = y; + var global3 = globalY(); + + var del = f("delete"); + var inner4 = f("get"); + var local4 = y; + var global4 = globalY(); + + f("set2"); + var inner5 = f("get"); + var local5 = y; + var global5 = globalY(); + + return { + local0: local0, global0: global0, + inner1: inner1, local1: local1, global1: global1, + inner2: inner2, local2: local2, global2: global2, + inner3: inner3, local3: local3, global3: global3, + del: del, + inner4: inner4, local4: local4, global4: global4, + inner5: inner5, local5: local5, global5: global5, + }; +} + +var resultsY = testY(); + +assertEq(resultsY.local0, 42); +assertEq(resultsY.global0, 42); + +assertEq(resultsY.inner1, 5); +assertEq(resultsY.local1, 42); +assertEq(resultsY.global1, 42); + +assertEq(resultsY.inner2, 5); +assertEq(resultsY.local2, 8); +assertEq(resultsY.global2, 8); + +assertEq(resultsY.inner3, 2); +assertEq(resultsY.local3, 8); +assertEq(resultsY.global3, 8); + +assertEq(resultsY.del, "SyntaxError"); + +assertEq(resultsY.inner4, 2); +assertEq(resultsY.local4, 8); +assertEq(resultsY.global4, 8); + +assertEq(resultsY.inner5, 71); +assertEq(resultsY.local5, 8); +assertEq(resultsY.global5, 8); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete!"); 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!"); diff --git a/js/src/tests/non262/eval/exhaustive-global-normalcaller-direct-strictcode.js b/js/src/tests/non262/eval/exhaustive-global-normalcaller-direct-strictcode.js new file mode 100644 index 0000000000..cede8de838 --- /dev/null +++ b/js/src/tests/non262/eval/exhaustive-global-normalcaller-direct-strictcode.js @@ -0,0 +1,174 @@ +// 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 = + "'use strict';" + + "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, 17); + +assertEq(resultsX.inner2, 4); +assertEq(resultsX.local2, 7); + +assertEq(resultsX.inner3, 9); +assertEq(resultsX.local3, 7); + +assertEq(resultsX.del, "SyntaxError"); + +assertEq(resultsX.inner4, 9); +assertEq(resultsX.local4, 7); + +assertEq(resultsX.inner5, 23); +assertEq(resultsX.local5, 7); + + +var ycode = + "'use strict';" + + "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"); +try { var local1 = y; } catch (e) { local1 = e.name; } + +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, "ReferenceError"); + +assertEq(resultsY.inner2, 5); +assertEq(resultsY.local2, 8); + +assertEq(resultsY.inner3, 2); +assertEq(resultsY.local3, 8); + +assertEq(resultsY.del, "SyntaxError"); + +assertEq(resultsY.inner4, 2); +assertEq(resultsY.local4, 8); + +assertEq(resultsY.inner5, 71); +assertEq(resultsY.local5, 8); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete!"); diff --git a/js/src/tests/non262/eval/exhaustive-global-normalcaller-indirect-normalcode.js b/js/src/tests/non262/eval/exhaustive-global-normalcaller-indirect-normalcode.js new file mode 100644 index 0000000000..5f4089f3d1 --- /dev/null +++ b/js/src/tests/non262/eval/exhaustive-global-normalcaller-indirect-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 = ev(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 = ev(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!"); diff --git a/js/src/tests/non262/eval/exhaustive-global-normalcaller-indirect-strictcode.js b/js/src/tests/non262/eval/exhaustive-global-normalcaller-indirect-strictcode.js new file mode 100644 index 0000000000..c225b97966 --- /dev/null +++ b/js/src/tests/non262/eval/exhaustive-global-normalcaller-indirect-strictcode.js @@ -0,0 +1,174 @@ +// 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 = + "'use strict';" + + "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 = ev(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, 17); + +assertEq(resultsX.inner2, 4); +assertEq(resultsX.local2, 7); + +assertEq(resultsX.inner3, 9); +assertEq(resultsX.local3, 7); + +assertEq(resultsX.del, "SyntaxError"); + +assertEq(resultsX.inner4, 9); +assertEq(resultsX.local4, 7); + +assertEq(resultsX.inner5, 23); +assertEq(resultsX.local5, 7); + + +var ycode = + "'use strict';" + + "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 = ev(ycode); + +var inner1 = f("get"); +try { var local1 = y; } catch (e) { local1 = e.name; } + +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, "ReferenceError"); + +assertEq(resultsY.inner2, 5); +assertEq(resultsY.local2, 8); + +assertEq(resultsY.inner3, 2); +assertEq(resultsY.local3, 8); + +assertEq(resultsY.del, "SyntaxError"); + +assertEq(resultsY.inner4, 2); +assertEq(resultsY.local4, 8); + +assertEq(resultsY.inner5, 71); +assertEq(resultsY.local5, 8); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete!"); diff --git a/js/src/tests/non262/eval/exhaustive-global-strictcaller-direct-normalcode.js b/js/src/tests/non262/eval/exhaustive-global-strictcaller-direct-normalcode.js new file mode 100644 index 0000000000..4a6b289f29 --- /dev/null +++ b/js/src/tests/non262/eval/exhaustive-global-strictcaller-direct-normalcode.js @@ -0,0 +1,173 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ +"use strict"; + +//----------------------------------------------------------------------------- +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, 17); + +assertEq(resultsX.inner2, 4); +assertEq(resultsX.local2, 7); + +assertEq(resultsX.inner3, 9); +assertEq(resultsX.local3, 7); + +assertEq(resultsX.del, "SyntaxError"); + +assertEq(resultsX.inner4, 9); +assertEq(resultsX.local4, 7); + +assertEq(resultsX.inner5, 23); +assertEq(resultsX.local5, 7); + + +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"); +try { var local1 = y; } catch (e) { local1 = e.name; } + +try { y = 8; } catch (e) { assertEq(e.name, "ReferenceError"); } +var inner2 = f("get"); +try { var local2 = y; } catch (e) { local2 = e.name; } + +f("set1"); +var inner3 = f("get"); +try { var local3 = y; } catch (e) { local3 = e.name; } + +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, "ReferenceError"); + +assertEq(resultsY.inner2, 5); +assertEq(resultsY.local2, "ReferenceError"); + +assertEq(resultsY.inner3, 2); +assertEq(resultsY.local3, "ReferenceError"); + +assertEq(resultsY.del, "SyntaxError"); + +assertEq(resultsY.inner4, 2); +assertEq(resultsY.local4, "ReferenceError"); + +assertEq(resultsY.inner5, 71); +assertEq(resultsY.local5, "ReferenceError"); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete!"); diff --git a/js/src/tests/non262/eval/exhaustive-global-strictcaller-direct-strictcode.js b/js/src/tests/non262/eval/exhaustive-global-strictcaller-direct-strictcode.js new file mode 100644 index 0000000000..2e624ecb36 --- /dev/null +++ b/js/src/tests/non262/eval/exhaustive-global-strictcaller-direct-strictcode.js @@ -0,0 +1,175 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ +"use strict"; + +//----------------------------------------------------------------------------- +var BUGNUMBER = 514568; +var summary = "eval in all its myriad flavors"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var x = 17; + +var ev = eval; + +var xcode = + "'use strict';" + + "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, 17); + +assertEq(resultsX.inner2, 4); +assertEq(resultsX.local2, 7); + +assertEq(resultsX.inner3, 9); +assertEq(resultsX.local3, 7); + +assertEq(resultsX.del, "SyntaxError"); + +assertEq(resultsX.inner4, 9); +assertEq(resultsX.local4, 7); + +assertEq(resultsX.inner5, 23); +assertEq(resultsX.local5, 7); + + +var ycode = + "'use strict';" + + "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"); +try { var local1 = y; } catch (e) { local1 = e.name; } + +try { y = 8; } catch (e) { assertEq(e.name, "ReferenceError"); } +var inner2 = f("get"); +try { var local2 = y; } catch (e) { local2 = e.name; } + +f("set1"); +var inner3 = f("get"); +try { var local3 = y; } catch (e) { local3 = e.name; } + +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, "ReferenceError"); + +assertEq(resultsY.inner2, 5); +assertEq(resultsY.local2, "ReferenceError"); + +assertEq(resultsY.inner3, 2); +assertEq(resultsY.local3, "ReferenceError"); + +assertEq(resultsY.del, "SyntaxError"); + +assertEq(resultsY.inner4, 2); +assertEq(resultsY.local4, "ReferenceError"); + +assertEq(resultsY.inner5, 71); +assertEq(resultsY.local5, "ReferenceError"); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete!"); diff --git a/js/src/tests/non262/eval/exhaustive-global-strictcaller-indirect-normalcode.js b/js/src/tests/non262/eval/exhaustive-global-strictcaller-indirect-normalcode.js new file mode 100644 index 0000000000..ac11ccb73d --- /dev/null +++ b/js/src/tests/non262/eval/exhaustive-global-strictcaller-indirect-normalcode.js @@ -0,0 +1,173 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ +"use strict"; + +//----------------------------------------------------------------------------- +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 = ev(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 = ev(ycode); + +var inner1 = f("get"); +var local1 = y; + +try { y = 8; } catch (e) { assertEq(e.name, "ReferenceError"); } +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!"); diff --git a/js/src/tests/non262/eval/exhaustive-global-strictcaller-indirect-strictcode.js b/js/src/tests/non262/eval/exhaustive-global-strictcaller-indirect-strictcode.js new file mode 100644 index 0000000000..137a8bad71 --- /dev/null +++ b/js/src/tests/non262/eval/exhaustive-global-strictcaller-indirect-strictcode.js @@ -0,0 +1,175 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ +"use strict"; + +//----------------------------------------------------------------------------- +var BUGNUMBER = 514568; +var summary = "eval in all its myriad flavors"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var x = 17; + +var ev = eval; + +var xcode = + "'use strict';" + + "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 = ev(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, 17); + +assertEq(resultsX.inner2, 4); +assertEq(resultsX.local2, 7); + +assertEq(resultsX.inner3, 9); +assertEq(resultsX.local3, 7); + +assertEq(resultsX.del, "SyntaxError"); + +assertEq(resultsX.inner4, 9); +assertEq(resultsX.local4, 7); + +assertEq(resultsX.inner5, 23); +assertEq(resultsX.local5, 7); + + +var ycode = + "'use strict';" + + "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 = ev(ycode); + +var inner1 = f("get"); +try { var local1 = y; } catch (e) { local1 = e.name; } + +try { y = 8; } catch (e) { assertEq(e.name, "ReferenceError"); } +var inner2 = f("get"); +try { var local2 = y; } catch (e) { local2 = e.name; } + +f("set1"); +var inner3 = f("get"); +try { var local3 = y; } catch (e) { local3 = e.name; } + +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, "ReferenceError"); + +assertEq(resultsY.inner2, 5); +assertEq(resultsY.local2, "ReferenceError"); + +assertEq(resultsY.inner3, 2); +assertEq(resultsY.local3, "ReferenceError"); + +assertEq(resultsY.del, "SyntaxError"); + +assertEq(resultsY.inner4, 2); +assertEq(resultsY.local4, "ReferenceError"); + +assertEq(resultsY.inner5, 71); +assertEq(resultsY.local5, "ReferenceError"); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete!"); diff --git a/js/src/tests/non262/eval/line-terminator-paragraph-terminator.js b/js/src/tests/non262/eval/line-terminator-paragraph-terminator.js new file mode 100644 index 0000000000..9a904073ab --- /dev/null +++ b/js/src/tests/non262/eval/line-terminator-paragraph-terminator.js @@ -0,0 +1,24 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 657367; +var summary = + "eval via the JSON parser should parse strings containing U+2028/U+2029 " + + "(as of <https://tc39.github.io/proposal-json-superset/>, that is)"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +assertEq(eval('("\u2028")'), "\u2028"); +assertEq(eval('("\u2029")'), "\u2029"); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete!"); diff --git a/js/src/tests/non262/eval/redeclared-arguments-in-param-expression-eval.js b/js/src/tests/non262/eval/redeclared-arguments-in-param-expression-eval.js new file mode 100644 index 0000000000..58d94d6f70 --- /dev/null +++ b/js/src/tests/non262/eval/redeclared-arguments-in-param-expression-eval.js @@ -0,0 +1,87 @@ +// Ensure there's no predefined |arguments| binding. +assertEq("arguments" in this, false); + +// Declare |arguments| when no pre-existing (and explicit) |arguments| bindings are present. +function f1(p = eval("var arguments")) {} +assertThrowsInstanceOf(f1, SyntaxError); + +// Declare |arguments| when the function body contains an |arguments| var-binding. +function f2(p = eval("var arguments")) { + var arguments; +} +assertThrowsInstanceOf(f2, SyntaxError); + +// Declare |arguments| when the function body contains an |arguments| function declaration. +// +// <https://tc39.es/ecma262/#sec-functiondeclarationinstantiation> doesn't create the +// implicit |arguments| binding when no parameter expressions are present. This case +// may be special-cased in implementations and therefore should be tested specifically. +function f3(p = eval("var arguments")) { + function arguments() {} +} +assertThrowsInstanceOf(f3, SyntaxError); + +// Declare |arguments| when the function body contains an |arguments| lexical binding. +// +// <https://tc39.es/ecma262/#sec-functiondeclarationinstantiation> doesn't create the +// implicit |arguments| binding when no parameter expressions are present. This case +// may be special-cased in implementations and therefore should be tested specifically. +function f4(p = eval("var arguments")) { + let arguments; +} +assertThrowsInstanceOf(f4, SyntaxError); + +// Declare |arguments| when a following parameter is named |arguments|. +function f5(p = eval("var arguments"), arguments) {} +assertThrowsInstanceOf(f5, SyntaxError); + +// Declare |arguments| when a preceding parameter is named |arguments|. +function f6(arguments, p = eval("var arguments")) {} +assertThrowsInstanceOf(f6, SyntaxError); + + +// Repeat the same kind of tests for arrow function. + +// Declare |arguments| when no pre-existing |arguments| bindings are present. +var a1 = (p = eval("var arguments = 'param'")) => { + assertEq(arguments, "param"); +}; +a1(); + +// Declare |arguments| when the function body contains an |arguments| var-binding. +var a2 = (p = eval("var arguments = 'param'"), q = () => arguments) => { + var arguments = "local"; + assertEq(arguments, "local"); + assertEq(q(), "param"); +}; +a2(); + +// Declare |arguments| when the function body contains an |arguments| function declaration. +var a3 = (p = eval("var arguments = 'param'"), q = () => arguments) => { + function arguments() {} + assertEq(typeof arguments, "function"); + assertEq(q(), "param"); +}; +a3(); + +// Declare |arguments| when the function body contains an |arguments| lexical binding. +var a4 = (p = eval("var arguments = 'param'"), q = () => arguments) => { + let arguments = "local"; + assertEq(arguments, "local"); + assertEq(q(), "param"); +}; +a4(); + +// Declare |arguments| when a following parameter is named |arguments|. +var a5 = (p = eval("var arguments"), arguments) => {}; +assertThrowsInstanceOf(a5, SyntaxError); + +// Declare |arguments| when a preceding parameter is named |arguments|. +var a6 = (arguments, p = eval("var arguments")) => {}; +assertThrowsInstanceOf(a6, SyntaxError); + +// None of the direct eval calls introduced a global |arguments| binding. +assertEq("arguments" in this, false); + +if (typeof reportCompare === "function") + reportCompare(true, true); diff --git a/js/src/tests/non262/eval/regress-531682.js b/js/src/tests/non262/eval/regress-531682.js new file mode 100644 index 0000000000..416bc59fac --- /dev/null +++ b/js/src/tests/non262/eval/regress-531682.js @@ -0,0 +1,32 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 531682; +var summary = 'Checking proper wrapping of scope in eval(source, scope)'; +var actual; +var expect; + +//----------------------------------------------------------------------------- +var x = 0; + +test(); +//----------------------------------------------------------------------------- + +function scope1() { + eval('var x = 1;'); + return function() { return x; } +} + +function test() { + printBugNumber(BUGNUMBER); + printStatus (summary); + + // The scope chain in eval should be just scope1() and the global object. + actual = eval('x', scope1()); + expect = 0; + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/non262/eval/shell.js b/js/src/tests/non262/eval/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/non262/eval/shell.js diff --git a/js/src/tests/non262/eval/undeclared-name-in-nested-strict-eval.js b/js/src/tests/non262/eval/undeclared-name-in-nested-strict-eval.js new file mode 100644 index 0000000000..1cefe474b5 --- /dev/null +++ b/js/src/tests/non262/eval/undeclared-name-in-nested-strict-eval.js @@ -0,0 +1,26 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ +"use strict"; + +//----------------------------------------------------------------------------- +var BUGNUMBER = 514568; +var summary = + "Verify that we don't optimize free names to gnames in eval code that's " + + "global, when the name refers to a binding introduced by a strict mode " + + "eval frame"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +var x = "global"; +assertEq(eval('var x = "eval"; eval("x")'), "eval"); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete!"); |