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
; }
28 "function actX(action)" +
41 " try { return eval('delete x'); }" +
42 " catch (e) { return e.name; }" +
48 var global0
= globalX();
52 var inner1
= f("get");
54 var global1
= globalX();
57 var inner2
= f("get");
59 var global2
= globalX();
62 var inner3
= f("get");
64 var global3
= globalX();
66 var del
= f("delete");
67 var inner4
= f("get");
69 var global4
= globalX();
72 var inner5
= f("get");
74 var global5
= globalX();
77 local0
: local0
, global0
: global0
,
78 inner1
: inner1
, local1
: local1
, global1
: global1
,
79 inner2
: inner2
, local2
: local2
, global2
: global2
,
80 inner3
: inner3
, local3
: local3
, global3
: global3
,
82 inner4
: inner4
, local4
: local4
, global4
: global4
,
83 inner5
: inner5
, local5
: local5
, global5
: global5
,
87 var resultsX
= testX();
89 assertEq(resultsX
.local0
, 2);
90 assertEq(resultsX
.global0
, 17);
92 assertEq(resultsX
.inner1
, 4);
93 assertEq(resultsX
.local1
, 2);
94 assertEq(resultsX
.global1
, 17);
96 assertEq(resultsX
.inner2
, 4);
97 assertEq(resultsX
.local2
, 7);
98 assertEq(resultsX
.global2
, 17);
100 assertEq(resultsX
.inner3
, 9);
101 assertEq(resultsX
.local3
, 7);
102 assertEq(resultsX
.global3
, 17);
104 assertEq(resultsX
.del
, "SyntaxError");
106 assertEq(resultsX
.inner4
, 9);
107 assertEq(resultsX
.local4
, 7);
108 assertEq(resultsX
.global4
, 17);
110 assertEq(resultsX
.inner5
, 23);
111 assertEq(resultsX
.local5
, 7);
112 assertEq(resultsX
.global5
, 17);
121 "function actY(action)" +
134 " try { return eval('delete y'); }" +
135 " catch (e) { return e.name; }" +
141 var global0
= globalY();
145 var inner1
= f("get");
147 var global1
= globalY();
150 var inner2
= f("get");
152 var global2
= globalY();
155 var inner3
= f("get");
157 var global3
= globalY();
159 var del
= f("delete");
160 var inner4
= f("get");
162 var global4
= globalY();
165 var inner5
= f("get");
167 var global5
= globalY();
170 local0
: local0
, global0
: global0
,
171 inner1
: inner1
, local1
: local1
, global1
: global1
,
172 inner2
: inner2
, local2
: local2
, global2
: global2
,
173 inner3
: inner3
, local3
: local3
, global3
: global3
,
175 inner4
: inner4
, local4
: local4
, global4
: global4
,
176 inner5
: inner5
, local5
: local5
, global5
: global5
,
180 var resultsY
= testY();
182 assertEq(resultsY
.local0
, 42);
183 assertEq(resultsY
.global0
, 42);
185 assertEq(resultsY
.inner1
, 5);
186 assertEq(resultsY
.local1
, 42);
187 assertEq(resultsY
.global1
, 42);
189 assertEq(resultsY
.inner2
, 5);
190 assertEq(resultsY
.local2
, 8);
191 assertEq(resultsY
.global2
, 8);
193 assertEq(resultsY
.inner3
, 2);
194 assertEq(resultsY
.local3
, 8);
195 assertEq(resultsY
.global3
, 8);
197 assertEq(resultsY
.del
, "SyntaxError");
199 assertEq(resultsY
.inner4
, 2);
200 assertEq(resultsY
.local4
, 8);
201 assertEq(resultsY
.global4
, 8);
203 assertEq(resultsY
.inner5
, 71);
204 assertEq(resultsY
.local5
, 8);
205 assertEq(resultsY
.global5
, 8);
207 /******************************************************************************/
209 if (typeof reportCompare
=== "function")
210 reportCompare(true, true);
212 print("Tests complete!");
214 var successfullyParsed
= true;