Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / mozilla / eval / script-tests / exhaustive-global-normalcaller-indirect-strictcode.js
blobf37e84e6225839c7c02f63b647cfcd9111d8f8e9
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;
16 var ev = eval;
18 var xcode =
19 "'use strict';" +
20 "var x = 4;" +
21 "function actX(action)" +
22 "{" +
23 " switch (action)" +
24 " {" +
25 " case 'get':" +
26 " return x;" +
27 " case 'set1':" +
28 " x = 9;" +
29 " return;" +
30 " case 'set2':" +
31 " x = 23;" +
32 " return;" +
33 " case 'delete':" +
34 " try { return eval('delete x'); }" +
35 " catch (e) { return e.name; }" +
36 " }" +
37 "}" +
38 "actX;";
40 var local0 = x;
42 var f = ev(xcode);
44 var inner1 = f("get");
45 var local1 = x;
47 x = 7;
48 var inner2 = f("get");
49 var local2 = x;
51 f("set1");
52 var inner3 = f("get");
53 var local3 = x;
55 var del = f("delete");
56 var inner4 = f("get");
57 var local4 = x;
59 f("set2");
60 var inner5 = f("get");
61 var local5 = x;
63 var resultsX =
65 local0: local0,
66 inner1: inner1, local1: local1,
67 inner2: inner2, local2: local2,
68 inner3: inner3, local3: local3,
69 del: del,
70 inner4: inner4, local4: local4,
71 inner5: inner5, local5: local5,
74 assertEq(resultsX.local0, 17);
76 assertEq(resultsX.inner1, 4);
77 assertEq(resultsX.local1, 17);
79 assertEq(resultsX.inner2, 4);
80 assertEq(resultsX.local2, 7);
82 assertEq(resultsX.inner3, 9);
83 assertEq(resultsX.local3, 7);
85 assertEq(resultsX.del, "SyntaxError");
87 assertEq(resultsX.inner4, 9);
88 assertEq(resultsX.local4, 7);
90 assertEq(resultsX.inner5, 23);
91 assertEq(resultsX.local5, 7);
94 var ycode =
95 "'use strict';" +
96 "var y = 5;" +
97 "function actY(action)" +
98 "{" +
99 " switch (action)" +
100 " {" +
101 " case 'get':" +
102 " return y;" +
103 " case 'set1':" +
104 " y = 2;" +
105 " return;" +
106 " case 'set2':" +
107 " y = 71;" +
108 " return;" +
109 " case 'delete':" +
110 " try { return eval('delete y'); }" +
111 " catch (e) { return e.name; }" +
112 " }" +
113 "}" +
114 "actY;";
116 try { var local0 = y; } catch (e) { local0 = e.name; }
118 var f = ev(ycode);
120 var inner1 = f("get");
121 try { var local1 = y; } catch (e) { local1 = e.name; }
123 y = 8;
124 var inner2 = f("get");
125 var local2 = y;
127 f("set1");
128 var inner3 = f("get");
129 var local3 = y;
131 var del = f("delete");
132 try { var inner4 = f("get"); } catch (e) { inner4 = e.name; }
133 try { var local4 = y; } catch (e) { local4 = e.name; }
135 f("set2");
136 try { var inner5 = f("get"); } catch (e) { inner5 = e.name; }
137 try { var local5 = y; } catch (e) { local5 = e.name; }
139 var resultsY =
141 local0: local0,
142 inner1: inner1, local1: local1,
143 inner2: inner2, local2: local2,
144 inner3: inner3, local3: local3,
145 del: del,
146 inner4: inner4, local4: local4,
147 inner5: inner5, local5: local5,
150 assertEq(resultsY.local0, "ReferenceError");
152 assertEq(resultsY.inner1, 5);
153 assertEq(resultsY.local1, "ReferenceError");
155 assertEq(resultsY.inner2, 5);
156 assertEq(resultsY.local2, 8);
158 assertEq(resultsY.inner3, 2);
159 assertEq(resultsY.local3, 8);
161 assertEq(resultsY.del, "SyntaxError");
163 assertEq(resultsY.inner4, 2);
164 assertEq(resultsY.local4, 8);
166 assertEq(resultsY.inner5, 71);
167 assertEq(resultsY.local5, 8);
169 /******************************************************************************/
171 if (typeof reportCompare === "function")
172 reportCompare(true, true);
174 print("Tests complete!");
176 var successfullyParsed = true;