michael@0: // Any copyright is dedicated to the Public Domain. michael@0: // http://creativecommons.org/licenses/publicdomain/ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: print("(eval)(...) is a direct eval, (1, eval)() isn't, etc."); michael@0: michael@0: /************** michael@0: * BEGIN TEST * michael@0: **************/ michael@0: michael@0: /* michael@0: * Justification: michael@0: * michael@0: * https://mail.mozilla.org/pipermail/es5-discuss/2010-October/003724.html michael@0: * michael@0: * Note also bug 537673. michael@0: */ michael@0: michael@0: var t = "global"; michael@0: michael@0: function group() michael@0: { michael@0: var t = "local"; michael@0: return (eval)("t"); michael@0: } michael@0: assertEq(group(), "local"); michael@0: michael@0: function groupAndComma() michael@0: { michael@0: var t = "local"; michael@0: return (1, eval)("t"); michael@0: } michael@0: assertEq(groupAndComma(), "global"); michael@0: michael@0: function groupAndTrueTernary() michael@0: { michael@0: var t = "local"; michael@0: return (true ? eval : null)("t"); michael@0: } michael@0: assertEq(groupAndTrueTernary(), "global"); michael@0: michael@0: function groupAndEmptyStringTernary() michael@0: { michael@0: var t = "local"; michael@0: return ("" ? null : eval)("t"); michael@0: } michael@0: assertEq(groupAndEmptyStringTernary(), "global"); michael@0: michael@0: function groupAndZeroTernary() michael@0: { michael@0: var t = "local"; michael@0: return (0 ? null : eval)("t"); michael@0: } michael@0: assertEq(groupAndZeroTernary(), "global"); michael@0: michael@0: function groupAndNaNTernary() michael@0: { michael@0: var t = "local"; michael@0: return (0 / 0 ? null : eval)("t"); michael@0: } michael@0: assertEq(groupAndNaNTernary(), "global"); michael@0: michael@0: /******************************************************************************/ michael@0: michael@0: if (typeof reportCompare === "function") michael@0: reportCompare(true, true); michael@0: michael@0: print("All tests passed!");