Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / mozilla / eval / script-tests / exhaustive-fun-normalcaller-direct-strictcode.js
bloba4113292b70d15c4ad789d75018787b15c84d2c4
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 var x = 2;
24 var xcode =
25 "'use strict';" +
26 "var x = 4;" +
27 "function actX(action)" +
28 "{" +
29 " switch (action)" +
30 " {" +
31 " case 'get':" +
32 " return x;" +
33 " case 'set1':" +
34 " x = 9;" +
35 " return;" +
36 " case 'set2':" +
37 " x = 23;" +
38 " return;" +
39 " case 'delete':" +
40 " try { return eval('delete x'); }" +
41 " catch (e) { return e.name; }" +
42 " }" +
43 "}" +
44 "actX;";
46 var local0 = x;
47 var global0 = globalX();
49 var f = eval(xcode);
51 var inner1 = f("get");
52 var local1 = x;
53 var global1 = globalX();
55 x = 7;
56 var inner2 = f("get");
57 var local2 = x;
58 var global2 = globalX();
60 f("set1");
61 var inner3 = f("get");
62 var local3 = x;
63 var global3 = globalX();
65 var del = f("delete");
66 var inner4 = f("get");
67 var local4 = x;
68 var global4 = globalX();
70 f("set2");
71 var inner5 = f("get");
72 var local5 = x;
73 var global5 = globalX();
75 return {
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,
80 del: del,
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);
114 function testY()
116 var ycode =
117 "'use strict';" +
118 "var y = 5;" +
119 "function actY(action)" +
120 "{" +
121 " switch (action)" +
122 " {" +
123 " case 'get':" +
124 " return y;" +
125 " case 'set1':" +
126 " y = 2;" +
127 " return;" +
128 " case 'set2':" +
129 " y = 71;" +
130 " return;" +
131 " case 'delete':" +
132 " try { return eval('delete y'); }" +
133 " catch (e) { return e.name; }" +
134 " }" +
135 "}" +
136 "actY;";
138 var local0 = y;
139 var global0 = globalY();
141 var f = eval(ycode);
143 var inner1 = f("get");
144 var local1 = y;
145 var global1 = globalY();
147 y = 8;
148 var inner2 = f("get");
149 var local2 = y;
150 var global2 = globalY();
152 f("set1");
153 var inner3 = f("get");
154 var local3 = y;
155 var global3 = globalY();
157 var del = f("delete");
158 var inner4 = f("get");
159 var local4 = y;
160 var global4 = globalY();
162 f("set2");
163 var inner5 = f("get");
164 var local5 = y;
165 var global5 = globalY();
167 return {
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,
172 del: del,
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;