Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / mozilla / eval / script-tests / exhaustive-global-strictcaller-direct-normalcode.js
bloba97987b8cc376b85b55313f07b4e9ada58a994b2
1 // Any copyright is dedicated to the Public Domain.
2 // http://creativecommons.org/licenses/publicdomain/
3 "use strict";
5 //-----------------------------------------------------------------------------
6 var BUGNUMBER = 514568;
7 var summary = "eval in all its myriad flavors";
9 print(BUGNUMBER + ": " + summary);
11 /**************
12 * BEGIN TEST *
13 **************/
15 var x = 17;
17 var ev = eval;
19 var xcode =
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 = eval(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 "var y = 5;" +
96 "function actY(action)" +
97 "{" +
98 " switch (action)" +
99 " {" +
100 " case 'get':" +
101 " return y;" +
102 " case 'set1':" +
103 " y = 2;" +
104 " return;" +
105 " case 'set2':" +
106 " y = 71;" +
107 " return;" +
108 " case 'delete':" +
109 " try { return eval('delete y'); }" +
110 " catch (e) { return e.name; }" +
111 " }" +
112 "}" +
113 "actY;";
115 try { var local0 = y; } catch (e) { local0 = e.name; }
117 var f = eval(ycode);
119 var inner1 = f("get");
120 try { var local1 = y; } catch (e) { local1 = e.name; }
122 try { y = 8; } catch (e) { assertEq(e.name, "ReferenceError"); }
123 var inner2 = f("get");
124 try { var local2 = y; } catch (e) { local2 = e.name; }
126 f("set1");
127 var inner3 = f("get");
128 try { var local3 = y; } catch (e) { local3 = e.name; }
130 var del = f("delete");
131 try { var inner4 = f("get"); } catch (e) { inner4 = e.name; }
132 try { var local4 = y; } catch (e) { local4 = e.name; }
134 f("set2");
135 try { var inner5 = f("get"); } catch (e) { inner5 = e.name; }
136 try { var local5 = y; } catch (e) { local5 = e.name; }
138 var resultsY =
140 local0: local0,
141 inner1: inner1, local1: local1,
142 inner2: inner2, local2: local2,
143 inner3: inner3, local3: local3,
144 del: del,
145 inner4: inner4, local4: local4,
146 inner5: inner5, local5: local5,
149 assertEq(resultsY.local0, "ReferenceError");
151 assertEq(resultsY.inner1, 5);
152 assertEq(resultsY.local1, "ReferenceError");
154 assertEq(resultsY.inner2, 5);
155 assertEq(resultsY.local2, "ReferenceError");
157 assertEq(resultsY.inner3, 2);
158 assertEq(resultsY.local3, "ReferenceError");
160 assertEq(resultsY.del, "SyntaxError");
162 assertEq(resultsY.inner4, 2);
163 assertEq(resultsY.local4, "ReferenceError");
165 assertEq(resultsY.inner5, 71);
166 assertEq(resultsY.local5, "ReferenceError");
168 /******************************************************************************/
170 if (typeof reportCompare === "function")
171 reportCompare(true, true);
173 print("Tests complete!");
175 var successfullyParsed = true;