Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: test/codegen/expect/language/for_variable_capture_test.js

Issue 2128353002: Check in codegen test expectations. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 dart_library.library('language/for_variable_capture_test', null, /* Imports */[
2 'dart_sdk',
3 'expect'
4 ], function load__for_variable_capture_test(exports, dart_sdk, expect) {
5 'use strict';
6 const core = dart_sdk.core;
7 const _interceptors = dart_sdk._interceptors;
8 const dart = dart_sdk.dart;
9 const dartx = dart_sdk.dartx;
10 const expect$ = expect.expect;
11 const for_variable_capture_test = Object.create(null);
12 let JSArrayOfint = () => (JSArrayOfint = dart.constFn(_interceptors.JSArray$(c ore.int)))();
13 let dynamicTodynamic = () => (dynamicTodynamic = dart.constFn(dart.definiteFun ctionType(dart.dynamic, [dart.dynamic])))();
14 let VoidToint = () => (VoidToint = dart.constFn(dart.definiteFunctionType(core .int, [])))();
15 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT ype(dart.dynamic, [])))();
16 for_variable_capture_test.run = function(callback) {
17 return dart.dcall(callback);
18 };
19 dart.fn(for_variable_capture_test.run, dynamicTodynamic());
20 for_variable_capture_test.initializer = function() {
21 let closure = null;
22 for (let i = 0, fn = dart.fn(() => i, VoidToint()); i < 3; i++) {
23 i = i + 1;
24 closure = fn;
25 }
26 expect$.Expect.equals(1, dart.dcall(closure));
27 };
28 dart.fn(for_variable_capture_test.initializer, VoidTodynamic());
29 for_variable_capture_test.condition = function() {
30 let closures = [];
31 function check(callback) {
32 closures[dartx.add](callback);
33 return dart.dcall(callback);
34 }
35 dart.fn(check, dynamicTodynamic());
36 let values = [];
37 for (let i = 0; dart.test(dart.dsend(check(dart.fn(() => ++i, VoidToint())), '<', 8)); ++i) {
38 values[dartx.add](i);
39 }
40 expect$.Expect.listEquals(JSArrayOfint().of([1, 3, 5, 7]), values);
41 expect$.Expect.listEquals(JSArrayOfint().of([2, 4, 6, 8, 10]), closures[dart x.map](dart.dynamic)(for_variable_capture_test.run)[dartx.toList]());
42 };
43 dart.fn(for_variable_capture_test.condition, VoidTodynamic());
44 for_variable_capture_test.body = function() {
45 let closures = [];
46 for (let i = 0, j = 0; i < 3; i++) {
47 j++;
48 closures[dartx.add](dart.fn(() => i, VoidToint()));
49 closures[dartx.add](dart.fn(() => j, VoidToint()));
50 }
51 expect$.Expect.listEquals(JSArrayOfint().of([0, 1, 1, 2, 2, 3]), closures[da rtx.map](dart.dynamic)(for_variable_capture_test.run)[dartx.toList]());
52 };
53 dart.fn(for_variable_capture_test.body, VoidTodynamic());
54 for_variable_capture_test.update = function() {
55 let closures = [];
56 function check(callback) {
57 closures[dartx.add](callback);
58 return dart.dcall(callback);
59 }
60 dart.fn(check, dynamicTodynamic());
61 let values = [];
62 for (let i = 0; i < 4; check(dart.fn(() => ++i, VoidToint()))) {
63 values[dartx.add](i);
64 }
65 expect$.Expect.listEquals(JSArrayOfint().of([0, 1, 2, 3]), values);
66 expect$.Expect.listEquals(JSArrayOfint().of([2, 3, 4, 5]), closures[dartx.ma p](dart.dynamic)(for_variable_capture_test.run)[dartx.toList]());
67 };
68 dart.fn(for_variable_capture_test.update, VoidTodynamic());
69 for_variable_capture_test.initializer_condition = function() {
70 let values = [];
71 for (let i = 0, fn = dart.fn(() => i, VoidToint()); dart.test(dart.dsend(for _variable_capture_test.run(dart.fn(() => ++i, VoidToint())), '<', 3));) {
72 values[dartx.add](i);
73 values[dartx.add](fn());
74 }
75 expect$.Expect.listEquals(JSArrayOfint().of([1, 1, 2, 1]), values);
76 };
77 dart.fn(for_variable_capture_test.initializer_condition, VoidTodynamic());
78 for_variable_capture_test.initializer_update = function() {
79 let update_closures = [];
80 function update(callback) {
81 update_closures[dartx.add](callback);
82 return dart.dcall(callback);
83 }
84 dart.fn(update, dynamicTodynamic());
85 let init_closure = null;
86 for (let i = 0, fn = dart.fn(() => i, VoidToint()); i < 4; update(dart.fn(() => ++i, VoidToint()))) {
87 init_closure = fn;
88 if (i == 0) {
89 ++i;
90 }
91 }
92 expect$.Expect.equals(1, dart.dcall(init_closure));
93 expect$.Expect.listEquals(JSArrayOfint().of([3, 4, 5]), update_closures[dart x.map](dart.dynamic)(for_variable_capture_test.run)[dartx.toList]());
94 expect$.Expect.equals(1, dart.dcall(init_closure));
95 };
96 dart.fn(for_variable_capture_test.initializer_update, VoidTodynamic());
97 for_variable_capture_test.initializer_body = function() {
98 let closures = [];
99 for (let i = 0, fn = dart.fn(() => i, VoidToint()); i < 3; i++) {
100 closures[dartx.add](dart.fn(() => i, VoidToint()));
101 closures[dartx.add](fn);
102 fn = dart.fn(() => i, VoidToint());
103 }
104 expect$.Expect.listEquals(JSArrayOfint().of([0, 0, 1, 0, 2, 1]), closures[da rtx.map](dart.dynamic)(for_variable_capture_test.run)[dartx.toList]());
105 };
106 dart.fn(for_variable_capture_test.initializer_body, VoidTodynamic());
107 for_variable_capture_test.condition_update = function() {
108 let cond_closures = [];
109 function check(callback) {
110 cond_closures[dartx.add](callback);
111 return dart.dcall(callback);
112 }
113 dart.fn(check, dynamicTodynamic());
114 let update_closures = [];
115 function update(callback) {
116 update_closures[dartx.add](callback);
117 return dart.dcall(callback);
118 }
119 dart.fn(update, dynamicTodynamic());
120 let values = [];
121 for (let i = 0; dart.test(dart.dsend(check(dart.fn(() => i, VoidToint())), ' <', 4)); update(dart.fn(() => ++i, VoidToint()))) {
122 values[dartx.add](i);
123 }
124 expect$.Expect.listEquals(JSArrayOfint().of([0, 1, 2, 3]), values);
125 expect$.Expect.listEquals(JSArrayOfint().of([0, 1, 2, 3, 4]), cond_closures[ dartx.map](dart.dynamic)(for_variable_capture_test.run)[dartx.toList]());
126 expect$.Expect.listEquals(JSArrayOfint().of([2, 3, 4, 5]), update_closures[d artx.map](dart.dynamic)(for_variable_capture_test.run)[dartx.toList]());
127 expect$.Expect.listEquals(JSArrayOfint().of([0, 2, 3, 4, 5]), cond_closures[ dartx.map](dart.dynamic)(for_variable_capture_test.run)[dartx.toList]());
128 };
129 dart.fn(for_variable_capture_test.condition_update, VoidTodynamic());
130 for_variable_capture_test.condition_body = function() {
131 let cond_closures = [];
132 function check(callback) {
133 cond_closures[dartx.add](callback);
134 return dart.dcall(callback);
135 }
136 dart.fn(check, dynamicTodynamic());
137 let body_closures = [];
138 function do_body(callback) {
139 body_closures[dartx.add](callback);
140 return dart.dcall(callback);
141 }
142 dart.fn(do_body, dynamicTodynamic());
143 for (let i = 0; dart.test(dart.dsend(check(dart.fn(() => i, VoidToint())), ' <', 4)); ++i) {
144 do_body(dart.fn(() => i, VoidToint()));
145 }
146 expect$.Expect.listEquals(JSArrayOfint().of([0, 1, 2, 3, 4]), cond_closures[ dartx.map](dart.dynamic)(for_variable_capture_test.run)[dartx.toList]());
147 expect$.Expect.listEquals(JSArrayOfint().of([0, 1, 2, 3]), body_closures[dar tx.map](dart.dynamic)(for_variable_capture_test.run)[dartx.toList]());
148 };
149 dart.fn(for_variable_capture_test.condition_body, VoidTodynamic());
150 for_variable_capture_test.initializer_condition_update = function() {
151 let init = null;
152 let cond_closures = [];
153 function check(callback) {
154 cond_closures[dartx.add](callback);
155 return dart.dcall(callback);
156 }
157 dart.fn(check, dynamicTodynamic());
158 let update_closures = [];
159 function update(callback) {
160 update_closures[dartx.add](callback);
161 return dart.dcall(callback);
162 }
163 dart.fn(update, dynamicTodynamic());
164 let values = [];
165 for (let i = 0, fn = dart.fn(() => i, VoidToint()); dart.test(dart.dsend(che ck(dart.fn(() => ++i, VoidToint())), '<', 8)); update(dart.fn(() => ++i, VoidToi nt()))) {
166 init = fn;
167 values[dartx.add](i);
168 }
169 expect$.Expect.listEquals(JSArrayOfint().of([1, 3, 5, 7]), values);
170 expect$.Expect.equals(1, dart.dcall(init));
171 expect$.Expect.listEquals(JSArrayOfint().of([2, 4, 6, 8, 10]), cond_closures [dartx.map](dart.dynamic)(for_variable_capture_test.run)[dartx.toList]());
172 expect$.Expect.listEquals(JSArrayOfint().of([5, 7, 9, 11]), update_closures[ dartx.map](dart.dynamic)(for_variable_capture_test.run)[dartx.toList]());
173 };
174 dart.fn(for_variable_capture_test.initializer_condition_update, VoidTodynamic( ));
175 for_variable_capture_test.initializer_condition_body = function() {
176 let init = null;
177 let cond_closures = [];
178 function check(callback) {
179 cond_closures[dartx.add](callback);
180 return dart.dcall(callback);
181 }
182 dart.fn(check, dynamicTodynamic());
183 let body_closures = [];
184 function do_body(callback) {
185 body_closures[dartx.add](callback);
186 return dart.dcall(callback);
187 }
188 dart.fn(do_body, dynamicTodynamic());
189 let values = [];
190 for (let i = 0, fn = dart.fn(() => i, VoidToint()); dart.test(dart.dsend(che ck(dart.fn(() => ++i, VoidToint())), '<', 8));) {
191 init = fn;
192 do_body(dart.fn(() => ++i, VoidToint()));
193 values[dartx.add](i);
194 }
195 expect$.Expect.listEquals(JSArrayOfint().of([2, 4, 6, 8]), values);
196 expect$.Expect.equals(2, dart.dcall(init));
197 expect$.Expect.listEquals(JSArrayOfint().of([3, 5, 7, 9, 10]), cond_closures [dartx.map](dart.dynamic)(for_variable_capture_test.run)[dartx.toList]());
198 expect$.Expect.listEquals(JSArrayOfint().of([4, 6, 8, 10]), body_closures[da rtx.map](dart.dynamic)(for_variable_capture_test.run)[dartx.toList]());
199 };
200 dart.fn(for_variable_capture_test.initializer_condition_body, VoidTodynamic()) ;
201 for_variable_capture_test.initializer_update_body = function() {
202 let init = null;
203 let update_closures = [];
204 function update(callback) {
205 update_closures[dartx.add](callback);
206 return dart.dcall(callback);
207 }
208 dart.fn(update, dynamicTodynamic());
209 let body_closures = [];
210 function do_body(callback) {
211 body_closures[dartx.add](callback);
212 return dart.dcall(callback);
213 }
214 dart.fn(do_body, dynamicTodynamic());
215 let values = [];
216 for (let i = 0, fn = dart.fn(() => i, VoidToint()); i < 8; update(dart.fn(() => ++i, VoidToint()))) {
217 init = fn;
218 do_body(dart.fn(() => ++i, VoidToint()));
219 values[dartx.add](i);
220 }
221 expect$.Expect.listEquals(JSArrayOfint().of([1, 3, 5, 7]), values);
222 expect$.Expect.equals(1, dart.dcall(init));
223 expect$.Expect.listEquals(JSArrayOfint().of([4, 6, 8, 9]), update_closures[d artx.map](dart.dynamic)(for_variable_capture_test.run)[dartx.toList]());
224 expect$.Expect.listEquals(JSArrayOfint().of([2, 5, 7, 9]), body_closures[dar tx.map](dart.dynamic)(for_variable_capture_test.run)[dartx.toList]());
225 };
226 dart.fn(for_variable_capture_test.initializer_update_body, VoidTodynamic());
227 for_variable_capture_test.condition_update_body = function() {
228 let cond_closures = [];
229 function check(callback) {
230 cond_closures[dartx.add](callback);
231 return dart.dcall(callback);
232 }
233 dart.fn(check, dynamicTodynamic());
234 let update_closures = [];
235 function update(callback) {
236 update_closures[dartx.add](callback);
237 return dart.dcall(callback);
238 }
239 dart.fn(update, dynamicTodynamic());
240 let body_closures = [];
241 function do_body(callback) {
242 body_closures[dartx.add](callback);
243 return dart.dcall(callback);
244 }
245 dart.fn(do_body, dynamicTodynamic());
246 let values = [];
247 for (let i = 0; dart.test(dart.dsend(check(dart.fn(() => i, VoidToint())), ' <', 8)); update(dart.fn(() => ++i, VoidToint()))) {
248 do_body(dart.fn(() => ++i, VoidToint()));
249 values[dartx.add](i);
250 }
251 expect$.Expect.listEquals(JSArrayOfint().of([1, 3, 5, 7]), values);
252 expect$.Expect.listEquals(JSArrayOfint().of([1, 3, 5, 7, 8]), cond_closures[ dartx.map](dart.dynamic)(for_variable_capture_test.run)[dartx.toList]());
253 expect$.Expect.listEquals(JSArrayOfint().of([4, 6, 8, 9]), update_closures[d artx.map](dart.dynamic)(for_variable_capture_test.run)[dartx.toList]());
254 expect$.Expect.listEquals(JSArrayOfint().of([2, 5, 7, 9]), body_closures[dar tx.map](dart.dynamic)(for_variable_capture_test.run)[dartx.toList]());
255 expect$.Expect.listEquals(JSArrayOfint().of([2, 5, 7, 9, 9]), cond_closures[ dartx.map](dart.dynamic)(for_variable_capture_test.run)[dartx.toList]());
256 };
257 dart.fn(for_variable_capture_test.condition_update_body, VoidTodynamic());
258 for_variable_capture_test.initializer_condition_update_body = function() {
259 let init = null;
260 let cond_closures = [];
261 function check(callback) {
262 cond_closures[dartx.add](callback);
263 return dart.dcall(callback);
264 }
265 dart.fn(check, dynamicTodynamic());
266 let update_closures = [];
267 function update(callback) {
268 update_closures[dartx.add](callback);
269 return dart.dcall(callback);
270 }
271 dart.fn(update, dynamicTodynamic());
272 let body_closures = [];
273 function do_body(callback) {
274 body_closures[dartx.add](callback);
275 return dart.dcall(callback);
276 }
277 dart.fn(do_body, dynamicTodynamic());
278 let values = [];
279 for (let i = 0, fn = dart.fn(() => i, VoidToint()); dart.test(dart.dsend(che ck(dart.fn(() => i, VoidToint())), '<', 8)); update(dart.fn(() => ++i, VoidToint ()))) {
280 init = fn;
281 do_body(dart.fn(() => ++i, VoidToint()));
282 values[dartx.add](i);
283 }
284 expect$.Expect.listEquals(JSArrayOfint().of([1, 3, 5, 7]), values);
285 expect$.Expect.equals(1, dart.dcall(init));
286 expect$.Expect.listEquals(JSArrayOfint().of([1, 3, 5, 7, 8]), cond_closures[ dartx.map](dart.dynamic)(for_variable_capture_test.run)[dartx.toList]());
287 expect$.Expect.listEquals(JSArrayOfint().of([4, 6, 8, 9]), update_closures[d artx.map](dart.dynamic)(for_variable_capture_test.run)[dartx.toList]());
288 expect$.Expect.listEquals(JSArrayOfint().of([2, 5, 7, 9]), body_closures[dar tx.map](dart.dynamic)(for_variable_capture_test.run)[dartx.toList]());
289 expect$.Expect.listEquals(JSArrayOfint().of([2, 5, 7, 9, 9]), cond_closures[ dartx.map](dart.dynamic)(for_variable_capture_test.run)[dartx.toList]());
290 };
291 dart.fn(for_variable_capture_test.initializer_condition_update_body, VoidTodyn amic());
292 for_variable_capture_test.main = function() {
293 for_variable_capture_test.initializer();
294 for_variable_capture_test.condition();
295 for_variable_capture_test.update();
296 for_variable_capture_test.body();
297 for_variable_capture_test.initializer_condition();
298 for_variable_capture_test.initializer_update();
299 for_variable_capture_test.initializer_body();
300 for_variable_capture_test.condition_update();
301 for_variable_capture_test.condition_body();
302 for_variable_capture_test.initializer_condition_update();
303 for_variable_capture_test.initializer_condition_body();
304 for_variable_capture_test.initializer_update_body();
305 for_variable_capture_test.condition_update_body();
306 for_variable_capture_test.initializer_condition_update_body();
307 };
308 dart.fn(for_variable_capture_test.main, VoidTodynamic());
309 // Exports:
310 exports.for_variable_capture_test = for_variable_capture_test;
311 });
OLDNEW
« no previous file with comments | « test/codegen/expect/language/for_test.js ('k') | test/codegen/expect/language/for_without_condition_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698