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

Side by Side Diff: test/codegen/expect/language/await_future_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/await_future_test', null, /* Imports */[
2 'dart_sdk',
3 'expect',
4 'async_helper'
5 ], function load__await_future_test(exports, dart_sdk, expect, async_helper) {
6 'use strict';
7 const core = dart_sdk.core;
8 const async = dart_sdk.async;
9 const _interceptors = dart_sdk._interceptors;
10 const dart = dart_sdk.dart;
11 const dartx = dart_sdk.dartx;
12 const expect$ = expect.expect;
13 const async_helper$ = async_helper.async_helper;
14 const await_future_test = Object.create(null);
15 let FutureOfint = () => (FutureOfint = dart.constFn(async.Future$(core.int)))( );
16 let JSArrayOfString = () => (JSArrayOfString = dart.constFn(_interceptors.JSAr ray$(core.String)))();
17 let dynamicTodynamic = () => (dynamicTodynamic = dart.constFn(dart.definiteFun ctionType(dart.dynamic, [dart.dynamic])))();
18 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT ype(dart.dynamic, [])))();
19 let VoidToFuture = () => (VoidToFuture = dart.constFn(dart.definiteFunctionTyp e(async.Future, [])))();
20 let dynamicAnddynamicTodynamic = () => (dynamicAnddynamicTodynamic = dart.cons tFn(dart.definiteFunctionType(dart.dynamic, [dart.dynamic, dart.dynamic])))();
21 let VoidToFutureOfint = () => (VoidToFutureOfint = dart.constFn(dart.definiteF unctionType(FutureOfint(), [])))();
22 let intAndintTodynamic = () => (intAndintTodynamic = dart.constFn(dart.definit eFunctionType(dart.dynamic, [core.int, core.int])))();
23 let dynamicToFuture = () => (dynamicToFuture = dart.constFn(dart.definiteFunct ionType(async.Future, [dart.dynamic])))();
24 await_future_test.bar = function(p) {
25 return dart.async(function*(p) {
26 return p;
27 }, dart.dynamic, p);
28 };
29 dart.fn(await_future_test.bar, dynamicTodynamic());
30 await_future_test.baz = function(p) {
31 return async.Future.new(dart.fn(() => p, VoidTodynamic()));
32 };
33 dart.fn(await_future_test.baz, dynamicTodynamic());
34 await_future_test.foo = function() {
35 return dart.async(function*() {
36 let b = 0;
37 for (let i = 0; i < 10; i++) {
38 b = dart.notNull(b) + dart.notNull(core.int._check(dart.dsend(yield awai t_future_test.bar(1), '+', yield await_future_test.baz(2))));
39 }
40 return b;
41 }, dart.dynamic);
42 };
43 dart.fn(await_future_test.foo, VoidTodynamic());
44 await_future_test.faa = function() {
45 return dart.async(function*() {
46 return dart.dload(yield await_future_test.bar('faa'), 'length');
47 }, dart.dynamic);
48 };
49 dart.fn(await_future_test.faa, VoidTodynamic());
50 await_future_test.quaz = function(p) {
51 return dart.async(function*(p) {
52 let x = 0;
53 try {
54 for (let j = 0; j < 10; j++) {
55 x = dart.notNull(x) + dart.notNull(core.int._check(yield await_future_ test.baz(j)));
56 }
57 return x;
58 } finally {
59 expect$.Expect.equals(x, 45);
60 return p;
61 }
62 }, dart.dynamic, p);
63 };
64 dart.fn(await_future_test.quaz, dynamicTodynamic());
65 await_future_test.quazz = function() {
66 return dart.async(function*() {
67 let x = 0;
68 try {
69 try {
70 x = core.int._check(yield await_future_test.bar(1));
71 dart.throw(x);
72 } catch (e1) {
73 let y = (yield await_future_test.baz(dart.dsend(e1, '+', 1)));
74 dart.throw(y);
75 }
76
77 } catch (e2) {
78 return e2;
79 }
80
81 }, dart.dynamic);
82 };
83 dart.fn(await_future_test.quazz, VoidTodynamic());
84 await_future_test.nesting = function() {
85 return dart.async(function*() {
86 try {
87 try {
88 let x = 1;
89 let y = dart.fn(() => dart.async(function*() {
90 try {
91 let z = dart.dsend(yield await_future_test.bar(3), '+', x);
92 dart.throw(z);
93 } catch (e1) {
94 return e1;
95 }
96
97 }, dart.dynamic), VoidToFuture());
98 let a = (yield y());
99 dart.throw(a);
100 } catch (e2) {
101 dart.throw(dart.dsend(e2, '+', 1));
102 }
103
104 } catch (e3) {
105 return e3;
106 }
107
108 }, dart.dynamic);
109 };
110 dart.fn(await_future_test.nesting, VoidTodynamic());
111 await_future_test.awaitAsUnary = function(a, b) {
112 return dart.async(function*(a, b) {
113 return dart.dsend(yield a, '+', yield b);
114 }, dart.dynamic, a, b);
115 };
116 dart.fn(await_future_test.awaitAsUnary, dynamicAnddynamicTodynamic());
117 await_future_test.awaitIf = function(p) {
118 return dart.async(function*(p) {
119 if (dart.test(dart.dsend(p, '<', yield await_future_test.bar(5)))) {
120 return "p<5";
121 } else {
122 return "p>=5";
123 }
124 }, dart.dynamic, p);
125 };
126 dart.fn(await_future_test.awaitIf, dynamicTodynamic());
127 await_future_test.awaitNestedIf = function(p, q) {
128 return dart.async(function*(p, q) {
129 if (dart.equals(p, yield await_future_test.bar(5))) {
130 if (dart.test(dart.dsend(q, '<', yield await_future_test.bar(7)))) {
131 return "q<7";
132 } else {
133 return "q>=7";
134 }
135 } else {
136 return "p!=5";
137 }
138 return "!";
139 }, dart.dynamic, p, q);
140 };
141 dart.fn(await_future_test.awaitNestedIf, dynamicAnddynamicTodynamic());
142 await_future_test.awaitElseIf = function(p) {
143 return dart.async(function*(p) {
144 if (dart.test(dart.dsend(p, '>', yield await_future_test.bar(5)))) {
145 return "p>5";
146 } else if (dart.test(dart.dsend(p, '<', yield await_future_test.bar(5)))) {
147 return "p<5";
148 } else {
149 return "p==5";
150 }
151 return "!";
152 }, dart.dynamic, p);
153 };
154 dart.fn(await_future_test.awaitElseIf, dynamicTodynamic());
155 await_future_test.awaitReturn = function() {
156 return dart.async(function*() {
157 return yield await_future_test.bar(17);
158 }, dart.dynamic);
159 };
160 dart.fn(await_future_test.awaitReturn, VoidTodynamic());
161 await_future_test.awaitSwitch = function() {
162 return dart.async(function*() {
163 switch (yield await_future_test.bar(3)) {
164 case 1:
165 {
166 return 1;
167 break;
168 }
169 case 3:
170 {
171 return 3;
172 break;
173 }
174 default:
175 {
176 return -1;
177 }
178 }
179 }, dart.dynamic);
180 };
181 dart.fn(await_future_test.awaitSwitch, VoidTodynamic());
182 await_future_test.awaitNestedWhile = function(i, j) {
183 return dart.async(function*(i, j) {
184 let savedJ = j;
185 let decI = dart.fn(() => dart.async(function*() {
186 let x = i;
187 i = dart.notNull(x) - 1;
188 return x;
189 }, core.int), VoidToFutureOfint());
190 let decJ = dart.fn(() => dart.async(function*() {
191 let x = j;
192 j = dart.notNull(x) - 1;
193 return x;
194 }, core.int), VoidToFutureOfint());
195 let k = 0;
196 while (dart.notNull(yield decI()) > 0) {
197 j = savedJ;
198 while (0 < dart.notNull(yield decJ())) {
199 k++;
200 }
201 }
202 return k;
203 }, dart.dynamic, i, j);
204 };
205 dart.fn(await_future_test.awaitNestedWhile, intAndintTodynamic());
206 await_future_test.awaitNestedDoWhile = function(i, j) {
207 return dart.async(function*(i, j) {
208 let savedJ = j;
209 let decI = dart.fn(() => dart.async(function*() {
210 let x = i;
211 i = dart.notNull(x) - 1;
212 return x;
213 }, core.int), VoidToFutureOfint());
214 let decJ = dart.fn(() => dart.async(function*() {
215 let x = j;
216 j = dart.notNull(x) - 1;
217 return x;
218 }, core.int), VoidToFutureOfint());
219 let k = 0;
220 do {
221 do {
222 k++;
223 } while (0 < dart.notNull(yield decI()));
224 } while (dart.notNull(yield decJ()) > 0);
225 return k;
226 }, dart.dynamic, i, j);
227 };
228 dart.fn(await_future_test.awaitNestedDoWhile, intAndintTodynamic());
229 await_future_test.awaitFor = function() {
230 return dart.async(function*() {
231 let asyncInc = dart.fn(p => dart.async(function*(p) {
232 return dart.dsend(p, '+', 1);
233 }, dart.dynamic, p), dynamicToFuture());
234 let k = 0;
235 for (let j = core.int._check(yield await_future_test.bar(0)), i = core.int ._check(yield await_future_test.bar(1)); dart.notNull(j) < dart.notNull(core.num ._check(yield await_future_test.bar(5))); j = core.int._check(yield dart.dcall(a syncInc, j)), i = core.int._check(yield dart.dcall(asyncInc, i))) {
236 k = dart.notNull(k) + dart.notNull(i);
237 k = dart.notNull(k) + dart.notNull(j);
238 }
239 return k;
240 }, dart.dynamic);
241 };
242 dart.fn(await_future_test.awaitFor, VoidTodynamic());
243 await_future_test.awaitForIn = function() {
244 return dart.async(function*() {
245 let list = JSArrayOfString().of(['a', 'b', 'c']);
246 let k = '';
247 for (let c of core.Iterable._check(yield await_future_test.bar(list))) {
248 k = dart.notNull(k) + dart.notNull(core.String._check(c));
249 }
250 return k;
251 }, dart.dynamic);
252 };
253 dart.fn(await_future_test.awaitForIn, VoidTodynamic());
254 await_future_test.test = function() {
255 return dart.async(function*() {
256 let result = null;
257 for (let i = 0; i < 10; i++) {
258 result = (yield await_future_test.foo());
259 expect$.Expect.equals(30, result);
260 result = (yield await_future_test.faa());
261 expect$.Expect.equals(3, result);
262 result = (yield await_future_test.quaz(17));
263 expect$.Expect.equals(17, result);
264 result = (yield await_future_test.quazz());
265 expect$.Expect.equals(2, result);
266 result = (yield await_future_test.nesting());
267 expect$.Expect.equals(5, result);
268 result = (yield await_future_test.awaitIf(3));
269 expect$.Expect.equals("p<5", result);
270 result = (yield await_future_test.awaitIf(5));
271 expect$.Expect.equals("p>=5", result);
272 result = (yield await_future_test.awaitNestedIf(5, 3));
273 expect$.Expect.equals("q<7", result);
274 result = (yield await_future_test.awaitNestedIf(5, 8));
275 expect$.Expect.equals("q>=7", result);
276 result = (yield await_future_test.awaitNestedIf(3, 8));
277 expect$.Expect.equals("p!=5", result);
278 result = (yield await_future_test.awaitReturn());
279 expect$.Expect.equals(17, result);
280 result = (yield await_future_test.awaitSwitch());
281 expect$.Expect.equals(3, result);
282 result = (yield await_future_test.awaitElseIf(6));
283 expect$.Expect.equals("p>5", result);
284 result = (yield await_future_test.awaitElseIf(4));
285 expect$.Expect.equals("p<5", result);
286 result = (yield await_future_test.awaitElseIf(5));
287 expect$.Expect.equals("p==5", result);
288 result = (yield await_future_test.awaitNestedWhile(5, 3));
289 expect$.Expect.equals(15, result);
290 result = (yield await_future_test.awaitNestedWhile(4, 6));
291 expect$.Expect.equals(24, result);
292 result = (yield await_future_test.awaitAsUnary(await_future_test.bar(1), await_future_test.bar(2)));
293 expect$.Expect.equals(3, result);
294 result = (yield await_future_test.awaitFor());
295 expect$.Expect.equals(25, result);
296 result = (yield await_future_test.awaitForIn());
297 expect$.Expect.equals('abc', result);
298 }
299 }, dart.dynamic);
300 };
301 dart.fn(await_future_test.test, VoidTodynamic());
302 await_future_test.main = function() {
303 async_helper$.asyncStart();
304 dart.dsend(await_future_test.test(), 'then', dart.fn(_ => {
305 async_helper$.asyncEnd();
306 }, dynamicTodynamic()));
307 };
308 dart.fn(await_future_test.main, VoidTodynamic());
309 // Exports:
310 exports.await_future_test = await_future_test;
311 });
OLDNEW
« no previous file with comments | « test/codegen/expect/language/await_for_use_local_test.js ('k') | test/codegen/expect/language/await_nonfuture_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698