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