diff options
Diffstat (limited to 'js/src/tests/ecma_5/eval')
20 files changed, 3175 insertions, 0 deletions
diff --git a/js/src/tests/ecma_5/eval/browser.js b/js/src/tests/ecma_5/eval/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/ecma_5/eval/browser.js diff --git a/js/src/tests/ecma_5/eval/exhaustive-fun-normalcaller-direct-normalcode.js b/js/src/tests/ecma_5/eval/exhaustive-fun-normalcaller-direct-normalcode.js new file mode 100644 index 000000000..1a4b56c63 --- /dev/null +++ b/js/src/tests/ecma_5/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/ecma_5/eval/exhaustive-fun-normalcaller-direct-strictcode.js b/js/src/tests/ecma_5/eval/exhaustive-fun-normalcaller-direct-strictcode.js new file mode 100644 index 000000000..7bd4ea658 --- /dev/null +++ b/js/src/tests/ecma_5/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/ecma_5/eval/exhaustive-fun-normalcaller-indirect-normalcode.js b/js/src/tests/ecma_5/eval/exhaustive-fun-normalcaller-indirect-normalcode.js new file mode 100644 index 000000000..d75496fa5 --- /dev/null +++ b/js/src/tests/ecma_5/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/ecma_5/eval/exhaustive-fun-normalcaller-indirect-strictcode.js b/js/src/tests/ecma_5/eval/exhaustive-fun-normalcaller-indirect-strictcode.js new file mode 100644 index 000000000..f38fc1b58 --- /dev/null +++ b/js/src/tests/ecma_5/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/ecma_5/eval/exhaustive-fun-strictcaller-direct-normalcode.js b/js/src/tests/ecma_5/eval/exhaustive-fun-strictcaller-direct-normalcode.js new file mode 100644 index 000000000..5d556458b --- /dev/null +++ b/js/src/tests/ecma_5/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/ecma_5/eval/exhaustive-fun-strictcaller-direct-strictcode.js b/js/src/tests/ecma_5/eval/exhaustive-fun-strictcaller-direct-strictcode.js new file mode 100644 index 000000000..a215a3ce7 --- /dev/null +++ b/js/src/tests/ecma_5/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/ecma_5/eval/exhaustive-fun-strictcaller-indirect-normalcode.js b/js/src/tests/ecma_5/eval/exhaustive-fun-strictcaller-indirect-normalcode.js new file mode 100644 index 000000000..8b3016d2e --- /dev/null +++ b/js/src/tests/ecma_5/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/ecma_5/eval/exhaustive-fun-strictcaller-indirect-strictcode.js b/js/src/tests/ecma_5/eval/exhaustive-fun-strictcaller-indirect-strictcode.js new file mode 100644 index 000000000..4157369ba --- /dev/null +++ b/js/src/tests/ecma_5/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/ecma_5/eval/exhaustive-global-normalcaller-direct-normalcode.js b/js/src/tests/ecma_5/eval/exhaustive-global-normalcaller-direct-normalcode.js new file mode 100644 index 000000000..cb5650852 --- /dev/null +++ b/js/src/tests/ecma_5/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/ecma_5/eval/exhaustive-global-normalcaller-direct-strictcode.js b/js/src/tests/ecma_5/eval/exhaustive-global-normalcaller-direct-strictcode.js new file mode 100644 index 000000000..cede8de83 --- /dev/null +++ b/js/src/tests/ecma_5/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/ecma_5/eval/exhaustive-global-normalcaller-indirect-normalcode.js b/js/src/tests/ecma_5/eval/exhaustive-global-normalcaller-indirect-normalcode.js new file mode 100644 index 000000000..5f4089f3d --- /dev/null +++ b/js/src/tests/ecma_5/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/ecma_5/eval/exhaustive-global-normalcaller-indirect-strictcode.js b/js/src/tests/ecma_5/eval/exhaustive-global-normalcaller-indirect-strictcode.js new file mode 100644 index 000000000..c225b9796 --- /dev/null +++ b/js/src/tests/ecma_5/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/ecma_5/eval/exhaustive-global-strictcaller-direct-normalcode.js b/js/src/tests/ecma_5/eval/exhaustive-global-strictcaller-direct-normalcode.js new file mode 100644 index 000000000..4a6b289f2 --- /dev/null +++ b/js/src/tests/ecma_5/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/ecma_5/eval/exhaustive-global-strictcaller-direct-strictcode.js b/js/src/tests/ecma_5/eval/exhaustive-global-strictcaller-direct-strictcode.js new file mode 100644 index 000000000..2e624ecb3 --- /dev/null +++ b/js/src/tests/ecma_5/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/ecma_5/eval/exhaustive-global-strictcaller-indirect-normalcode.js b/js/src/tests/ecma_5/eval/exhaustive-global-strictcaller-indirect-normalcode.js new file mode 100644 index 000000000..ac11ccb73 --- /dev/null +++ b/js/src/tests/ecma_5/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/ecma_5/eval/exhaustive-global-strictcaller-indirect-strictcode.js b/js/src/tests/ecma_5/eval/exhaustive-global-strictcaller-indirect-strictcode.js new file mode 100644 index 000000000..137a8bad7 --- /dev/null +++ b/js/src/tests/ecma_5/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/ecma_5/eval/line-terminator-paragraph-terminator.js b/js/src/tests/ecma_5/eval/line-terminator-paragraph-terminator.js new file mode 100644 index 000000000..61047fb10 --- /dev/null +++ b/js/src/tests/ecma_5/eval/line-terminator-paragraph-terminator.js @@ -0,0 +1,73 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 657367; +var summary = "eval must not parse strings containing U+2028 or U+2029"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +function esc(s) +{ + return s.split("").map(function(v) + { + var code = + ("000" + v.charCodeAt(0).toString(16)).slice(-4); + return "\\u" + code; + }).join(""); +} + +try +{ + var r = eval('"\u2028"'); + throw new Error("\"\\u2028\" didn't throw, returned " + esc(r)); +} +catch (e) +{ + assertEq(e instanceof SyntaxError, true, + "U+2028 is not a valid string character"); +} + +try +{ + var r = eval('("\u2028")'); + throw new Error("(\"\\u2028\") didn't throw, returned " + esc(r)); +} +catch (e) +{ + assertEq(e instanceof SyntaxError, true, + "U+2028 is not a valid string character"); +} + +try +{ + var r = eval('"\u2029"'); + throw new Error("\"\\u2029\" didn't throw, returned " + esc(r)); +} +catch (e) +{ + assertEq(e instanceof SyntaxError, true, + "U+2029 is not a valid string character"); +} + +try +{ + var r = eval('("\u2029")'); + throw new Error("(\"\\u2029\") didn't throw, returned " + esc(r)); +} +catch (e) +{ + assertEq(e instanceof SyntaxError, true, + "U+2029 is not a valid string character"); +} + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete!"); diff --git a/js/src/tests/ecma_5/eval/shell.js b/js/src/tests/ecma_5/eval/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/ecma_5/eval/shell.js diff --git a/js/src/tests/ecma_5/eval/undeclared-name-in-nested-strict-eval.js b/js/src/tests/ecma_5/eval/undeclared-name-in-nested-strict-eval.js new file mode 100644 index 000000000..1cefe474b --- /dev/null +++ b/js/src/tests/ecma_5/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!"); |