Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / mozilla / eval / script-tests / exhaustive-fun-strictcaller-indirect-strictcode.js
blob5f769cc011fa02be1bdf0801ee827430d768b706
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 "'use strict';" +
28 "var x = 4;" +
29 "function actX(action)" +
30 "{" +
31 " switch (action)" +
32 " {" +
33 " case 'get':" +
34 " return x;" +
35 " case 'set1':" +
36 " x = 9;" +
37 " return;" +
38 " case 'set2':" +
39 " x = 23;" +
40 " return;" +
41 " case 'delete':" +
42 " try { return eval('delete x'); }" +
43 " catch (e) { return e.name; }" +
44 " }" +
45 "}" +
46 "actX;";
48 var local0 = x;
49 var global0 = globalX();
51 var f = ev(xcode);
53 var inner1 = f("get");
54 var local1 = x;
55 var global1 = globalX();
57 x = 7;
58 var inner2 = f("get");
59 var local2 = x;
60 var global2 = globalX();
62 f("set1");
63 var inner3 = f("get");
64 var local3 = x;
65 var global3 = globalX();
67 var del = f("delete");
68 var inner4 = f("get");
69 var local4 = x;
70 var global4 = globalX();
72 f("set2");
73 var inner5 = f("get");
74 var local5 = x;
75 var global5 = globalX();
77 return {
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,
82 del: del,
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);
116 function testY()
118 "use strict";
120 var ycode =
121 "'use strict';" +
122 "var y = 5;" +
123 "function actY(action)" +
124 "{" +
125 " switch (action)" +
126 " {" +
127 " case 'get':" +
128 " return y;" +
129 " case 'set1':" +
130 " y = 2;" +
131 " return;" +
132 " case 'set2':" +
133 " y = 71;" +
134 " return;" +
135 " case 'delete':" +
136 " try { return eval('delete y'); }" +
137 " catch (e) { return e.name; }" +
138 " }" +
139 "}" +
140 "actY;";
142 var local0 = y;
143 var global0 = globalY();
145 var f = ev(ycode);
147 var inner1 = f("get");
148 var local1 = y;
149 var global1 = globalY();
151 y = 8;
152 var inner2 = f("get");
153 var local2 = y;
154 var global2 = globalY();
156 f("set1");
157 var inner3 = f("get");
158 var local3 = y;
159 var global3 = globalY();
161 var del = f("delete");
162 var inner4 = f("get");
163 var local4 = y;
164 var global4 = globalY();
166 f("set2");
167 var inner5 = f("get");
168 var local5 = y;
169 var global5 = globalY();
171 return {
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,
176 del: del,
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;