1 // Any copyright is dedicated to the Public Domain.
2 // http://creativecommons.org/licenses/publicdomain/
4 //-----------------------------------------------------------------------------
5 var BUGNUMBER
= 514568;
6 var summary
= "eval in all its myriad flavors";
8 print(BUGNUMBER
+ ": " + summary
);
15 function globalX() { return x
; }
17 function globalY() { return y
; }
27 "function actX(action)" +
40 " try { return eval('delete x'); }" +
41 " catch (e) { return e.name; }" +
47 var global0
= globalX();
51 var inner1
= f("get");
53 var global1
= globalX();
56 var inner2
= f("get");
58 var global2
= globalX();
61 var inner3
= f("get");
63 var global3
= globalX();
65 var del
= f("delete");
66 var inner4
= f("get");
68 var global4
= globalX();
71 var inner5
= f("get");
73 var global5
= globalX();
76 local0
: local0
, global0
: global0
,
77 inner1
: inner1
, local1
: local1
, global1
: global1
,
78 inner2
: inner2
, local2
: local2
, global2
: global2
,
79 inner3
: inner3
, local3
: local3
, global3
: global3
,
81 inner4
: inner4
, local4
: local4
, global4
: global4
,
82 inner5
: inner5
, local5
: local5
, global5
: global5
,
86 var resultsX
= testX();
88 assertEq(resultsX
.local0
, 2);
89 assertEq(resultsX
.global0
, 17);
91 assertEq(resultsX
.inner1
, 4);
92 assertEq(resultsX
.local1
, 2);
93 assertEq(resultsX
.global1
, 17);
95 assertEq(resultsX
.inner2
, 4);
96 assertEq(resultsX
.local2
, 7);
97 assertEq(resultsX
.global2
, 17);
99 assertEq(resultsX
.inner3
, 9);
100 assertEq(resultsX
.local3
, 7);
101 assertEq(resultsX
.global3
, 17);
103 assertEq(resultsX
.del
, "SyntaxError");
105 assertEq(resultsX
.inner4
, 9);
106 assertEq(resultsX
.local4
, 7);
107 assertEq(resultsX
.global4
, 17);
109 assertEq(resultsX
.inner5
, 23);
110 assertEq(resultsX
.local5
, 7);
111 assertEq(resultsX
.global5
, 17);
119 "function actY(action)" +
132 " try { return eval('delete y'); }" +
133 " catch (e) { return e.name; }" +
139 var global0
= globalY();
143 var inner1
= f("get");
145 var global1
= globalY();
148 var inner2
= f("get");
150 var global2
= globalY();
153 var inner3
= f("get");
155 var global3
= globalY();
157 var del
= f("delete");
158 var inner4
= f("get");
160 var global4
= globalY();
163 var inner5
= f("get");
165 var global5
= globalY();
168 local0
: local0
, global0
: global0
,
169 inner1
: inner1
, local1
: local1
, global1
: global1
,
170 inner2
: inner2
, local2
: local2
, global2
: global2
,
171 inner3
: inner3
, local3
: local3
, global3
: global3
,
173 inner4
: inner4
, local4
: local4
, global4
: global4
,
174 inner5
: inner5
, local5
: local5
, global5
: global5
,
178 var resultsY
= testY();
180 assertEq(resultsY
.local0
, 42);
181 assertEq(resultsY
.global0
, 42);
183 assertEq(resultsY
.inner1
, 5);
184 assertEq(resultsY
.local1
, 42);
185 assertEq(resultsY
.global1
, 42);
187 assertEq(resultsY
.inner2
, 5);
188 assertEq(resultsY
.local2
, 8);
189 assertEq(resultsY
.global2
, 8);
191 assertEq(resultsY
.inner3
, 2);
192 assertEq(resultsY
.local3
, 8);
193 assertEq(resultsY
.global3
, 8);
195 assertEq(resultsY
.del
, "SyntaxError");
197 assertEq(resultsY
.inner4
, 2);
198 assertEq(resultsY
.local4
, 8);
199 assertEq(resultsY
.global4
, 8);
201 assertEq(resultsY
.inner5
, 71);
202 assertEq(resultsY
.local5
, 8);
203 assertEq(resultsY
.global5
, 8);
205 /******************************************************************************/
207 if (typeof reportCompare
=== "function")
208 reportCompare(true, true);
210 print("Tests complete!");
212 var successfullyParsed
= true;