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
; }
29 "function actX(action)" +
42 " try { return eval('delete x'); }" +
43 " catch (e) { return e.name; }" +
49 var global0
= globalX();
53 var inner1
= f("get");
55 var global1
= globalX();
58 var inner2
= f("get");
60 var global2
= globalX();
63 var inner3
= f("get");
65 var global3
= globalX();
67 var del
= f("delete");
68 var inner4
= f("get");
70 var global4
= globalX();
73 var inner5
= f("get");
75 var global5
= globalX();
78 local0
: local0
, global0
: global0
,
79 inner1
: inner1
, local1
: local1
, global1
: global1
,
80 inner2
: inner2
, local2
: local2
, global2
: global2
,
81 inner3
: inner3
, local3
: local3
, global3
: global3
,
83 inner4
: inner4
, local4
: local4
, global4
: global4
,
84 inner5
: inner5
, local5
: local5
, global5
: global5
,
88 var resultsX
= testX();
90 assertEq(resultsX
.local0
, 2);
91 assertEq(resultsX
.global0
, 17);
93 assertEq(resultsX
.inner1
, 4);
94 assertEq(resultsX
.local1
, 2);
95 assertEq(resultsX
.global1
, 17);
97 assertEq(resultsX
.inner2
, 4);
98 assertEq(resultsX
.local2
, 7);
99 assertEq(resultsX
.global2
, 17);
101 assertEq(resultsX
.inner3
, 9);
102 assertEq(resultsX
.local3
, 7);
103 assertEq(resultsX
.global3
, 17);
105 assertEq(resultsX
.del
, "SyntaxError");
107 assertEq(resultsX
.inner4
, 9);
108 assertEq(resultsX
.local4
, 7);
109 assertEq(resultsX
.global4
, 17);
111 assertEq(resultsX
.inner5
, 23);
112 assertEq(resultsX
.local5
, 7);
113 assertEq(resultsX
.global5
, 17);
123 "function actY(action)" +
136 " try { return eval('delete y'); }" +
137 " catch (e) { return e.name; }" +
143 var global0
= globalY();
147 var inner1
= f("get");
149 var global1
= globalY();
152 var inner2
= f("get");
154 var global2
= globalY();
157 var inner3
= f("get");
159 var global3
= globalY();
161 var del
= f("delete");
162 var inner4
= f("get");
164 var global4
= globalY();
167 var inner5
= f("get");
169 var global5
= globalY();
172 local0
: local0
, global0
: global0
,
173 inner1
: inner1
, local1
: local1
, global1
: global1
,
174 inner2
: inner2
, local2
: local2
, global2
: global2
,
175 inner3
: inner3
, local3
: local3
, global3
: global3
,
177 inner4
: inner4
, local4
: local4
, global4
: global4
,
178 inner5
: inner5
, local5
: local5
, global5
: global5
,
182 var resultsY
= testY();
184 assertEq(resultsY
.local0
, 42);
185 assertEq(resultsY
.global0
, 42);
187 assertEq(resultsY
.inner1
, 5);
188 assertEq(resultsY
.local1
, 42);
189 assertEq(resultsY
.global1
, 42);
191 assertEq(resultsY
.inner2
, 5);
192 assertEq(resultsY
.local2
, 8);
193 assertEq(resultsY
.global2
, 8);
195 assertEq(resultsY
.inner3
, 2);
196 assertEq(resultsY
.local3
, 8);
197 assertEq(resultsY
.global3
, 8);
199 assertEq(resultsY
.del
, "SyntaxError");
201 assertEq(resultsY
.inner4
, 2);
202 assertEq(resultsY
.local4
, 8);
203 assertEq(resultsY
.global4
, 8);
205 assertEq(resultsY
.inner5
, 71);
206 assertEq(resultsY
.local5
, 8);
207 assertEq(resultsY
.global5
, 8);
209 /******************************************************************************/
211 if (typeof reportCompare
=== "function")
212 reportCompare(true, true);
214 print("Tests complete!");
216 var successfullyParsed
= true;