js/src/tests/ecma_5/Global/parenthesized-eval-is-direct.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // Any copyright is dedicated to the Public Domain.
     2 // http://creativecommons.org/licenses/publicdomain/
     4 //-----------------------------------------------------------------------------
     5 print("(eval)(...) is a direct eval, (1, eval)() isn't, etc.");
     7 /**************
     8  * BEGIN TEST *
     9  **************/
    11 /*
    12  * Justification:
    13  *
    14  *   https://mail.mozilla.org/pipermail/es5-discuss/2010-October/003724.html
    15  *
    16  * Note also bug 537673.
    17  */
    19 var t = "global";
    21 function group()
    22 {
    23   var t = "local";
    24   return (eval)("t");
    25 }
    26 assertEq(group(), "local");
    28 function groupAndComma()
    29 {
    30   var t = "local";
    31   return (1, eval)("t");
    32 }
    33 assertEq(groupAndComma(), "global");
    35 function groupAndTrueTernary()
    36 {
    37   var t = "local";
    38   return (true ? eval : null)("t");
    39 }
    40 assertEq(groupAndTrueTernary(), "global");
    42 function groupAndEmptyStringTernary()
    43 {
    44   var t = "local";
    45   return ("" ? null : eval)("t");
    46 }
    47 assertEq(groupAndEmptyStringTernary(), "global");
    49 function groupAndZeroTernary()
    50 {
    51   var t = "local";
    52   return (0 ? null : eval)("t");
    53 }
    54 assertEq(groupAndZeroTernary(), "global");
    56 function groupAndNaNTernary()
    57 {
    58   var t = "local";
    59   return (0 / 0 ? null : eval)("t");
    60 }
    61 assertEq(groupAndNaNTernary(), "global");
    63 /******************************************************************************/
    65 if (typeof reportCompare === "function")
    66   reportCompare(true, true);
    68 print("All tests passed!");

mercurial