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

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

mercurial