Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / mozilla / eval / script-tests / exhaustive-fun-strictcaller-direct-normalcode.js
blobd87fe5391e57744c60dde6b9c64fecf52efa54f3
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);
10 /**************
11 * BEGIN TEST *
12 **************/
14 var x = 17;
15 function globalX() { return x; }
16 var y = 42;
17 function globalY() { return y; }
19 var ev = eval;
21 function testX()
23 "use strict";
25 var x = 2;
26 var xcode =
27 "var x = 4;" +
28 "function actX(action)" +
29 "{" +
30 " switch (action)" +
31 " {" +
32 " case 'get':" +
33 " return x;" +
34 " case 'set1':" +
35 " x = 9;" +
36 " return;" +
37 " case 'set2':" +
38 " x = 23;" +
39 " return;" +
40 " case 'delete':" +
41 " try { return eval('delete x'); }" +
42 " catch (e) { return e.name; }" +
43 " }" +
44 "}" +
45 "actX;";
47 var local0 = x;
48 var global0 = globalX();
50 var f = eval(xcode);
52 var inner1 = f("get");
53 var local1 = x;
54 var global1 = globalX();
56 x = 7;
57 var inner2 = f("get");
58 var local2 = x;
59 var global2 = globalX();
61 f("set1");
62 var inner3 = f("get");
63 var local3 = x;
64 var global3 = globalX();
66 var del = f("delete");
67 var inner4 = f("get");
68 var local4 = x;
69 var global4 = globalX();
71 f("set2");
72 var inner5 = f("get");
73 var local5 = x;
74 var global5 = globalX();
76 return {
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,
81 del: del,
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);
115 function testY()
117 "use strict";
119 var ycode =
120 "var y = 5;" +
121 "function actY(action)" +
122 "{" +
123 " switch (action)" +
124 " {" +
125 " case 'get':" +
126 " return y;" +
127 " case 'set1':" +
128 " y = 2;" +
129 " return;" +
130 " case 'set2':" +
131 " y = 71;" +
132 " return;" +
133 " case 'delete':" +
134 " try { return eval('delete y'); }" +
135 " catch (e) { return e.name; }" +
136 " }" +
137 "}" +
138 "actY;";
140 var local0 = y;
141 var global0 = globalY();
143 var f = eval(ycode);
145 var inner1 = f("get");
146 var local1 = y;
147 var global1 = globalY();
149 y = 8;
150 var inner2 = f("get");
151 var local2 = y;
152 var global2 = globalY();
154 f("set1");
155 var inner3 = f("get");
156 var local3 = y;
157 var global3 = globalY();
159 var del = f("delete");
160 var inner4 = f("get");
161 var local4 = y;
162 var global4 = globalY();
164 f("set2");
165 var inner5 = f("get");
166 var local5 = y;
167 var global5 = globalY();
169 return {
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,
174 del: del,
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;