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

Side by Side Diff: test/codegen/expect/language/await_for_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_for_test', null, /* Imports */[
2 'dart_sdk',
3 'async_helper',
4 'expect'
5 ], function load__await_for_test(exports, dart_sdk, async_helper, expect) {
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 async_helper$ = async_helper.async_helper;
13 const expect$ = expect.expect;
14 const await_for_test = Object.create(null);
15 let JSArrayOfFuture = () => (JSArrayOfFuture = dart.constFn(_interceptors.JSAr ray$(async.Future)))();
16 let VoidToStream = () => (VoidToStream = dart.constFn(dart.definiteFunctionTyp e(async.Stream, [])))();
17 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT ype(dart.dynamic, [])))();
18 let ListTodynamic = () => (ListTodynamic = dart.constFn(dart.definiteFunctionT ype(dart.dynamic, [core.List])))();
19 let dynamicTovoid = () => (dynamicTovoid = dart.constFn(dart.definiteFunctionT ype(dart.void, [dart.dynamic])))();
20 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(da rt.void, [])))();
21 let intToStream = () => (intToStream = dart.constFn(dart.definiteFunctionType( async.Stream, [core.int])))();
22 await_for_test.Trace = class Trace extends core.Object {
23 new() {
24 this.trace = "";
25 }
26 record(x) {
27 this.trace = dart.notNull(this.trace) + dart.notNull(dart.toString(x));
28 }
29 toString() {
30 return this.trace;
31 }
32 };
33 dart.setSignature(await_for_test.Trace, {
34 methods: () => ({record: dart.definiteFunctionType(dart.dynamic, [dart.dynam ic])})
35 });
36 await_for_test.makeMeAStream = function() {
37 return await_for_test.timedCounter(5);
38 };
39 dart.fn(await_for_test.makeMeAStream, VoidToStream());
40 dart.defineLazy(await_for_test, {
41 get t1() {
42 return new await_for_test.Trace();
43 },
44 set t1(_) {}
45 });
46 await_for_test.consumeOne = function() {
47 return dart.async(function*() {
48 let s = await_for_test.makeMeAStream();
49 let it = async.StreamIterator.new(s);
50 while (dart.test(yield it.moveNext())) {
51 let x = it.current;
52 await_for_test.t1.record(x);
53 }
54 await_for_test.t1.record("X");
55 }, dart.dynamic);
56 };
57 dart.fn(await_for_test.consumeOne, VoidTodynamic());
58 dart.defineLazy(await_for_test, {
59 get t2() {
60 return new await_for_test.Trace();
61 },
62 set t2(_) {}
63 });
64 await_for_test.consumeTwo = function() {
65 return dart.async(function*() {
66 let it = async.StreamIterator.new(await_for_test.makeMeAStream());
67 try {
68 while (yield it.moveNext()) {
69 let x = it.current;
70 await_for_test.t2.record(x);
71 }
72 } finally {
73 yield it.cancel();
74 }
75 await_for_test.t2.record("Y");
76 }, dart.dynamic);
77 };
78 dart.fn(await_for_test.consumeTwo, VoidTodynamic());
79 dart.defineLazy(await_for_test, {
80 get t3() {
81 return new await_for_test.Trace();
82 },
83 set t3(_) {}
84 });
85 await_for_test.consumeNested = function() {
86 return dart.async(function*() {
87 let it = async.StreamIterator.new(await_for_test.makeMeAStream());
88 try {
89 while (yield it.moveNext()) {
90 let x = it.current;
91 await_for_test.t3.record(x);
92 let it$ = async.StreamIterator.new(await_for_test.makeMeAStream());
93 try {
94 while (yield it$.moveNext()) {
95 let y = it$.current;
96 await_for_test.t3.record(y);
97 }
98 } finally {
99 yield it$.cancel();
100 }
101 await_for_test.t3.record("|");
102 }
103 } finally {
104 yield it.cancel();
105 }
106 await_for_test.t3.record("Z");
107 }, dart.dynamic);
108 };
109 dart.fn(await_for_test.consumeNested, VoidTodynamic());
110 dart.defineLazy(await_for_test, {
111 get t4() {
112 return new await_for_test.Trace();
113 },
114 set t4(_) {}
115 });
116 await_for_test.consumeSomeOfInfinite = function() {
117 return dart.async(function*() {
118 let i = 0;
119 let it = async.StreamIterator.new(await_for_test.infiniteStream());
120 try {
121 while (yield it.moveNext()) {
122 let x = it.current;
123 i++;
124 if (i > 10) break;
125 await_for_test.t4.record(x);
126 }
127 } finally {
128 yield it.cancel();
129 }
130 await_for_test.t4.record("U");
131 }, dart.dynamic);
132 };
133 dart.fn(await_for_test.consumeSomeOfInfinite, VoidTodynamic());
134 await_for_test.main = function() {
135 let f1 = await_for_test.consumeOne();
136 await_for_test.t1.record("T1:");
137 let f2 = await_for_test.consumeTwo();
138 await_for_test.t2.record("T2:");
139 let f3 = await_for_test.consumeNested();
140 await_for_test.t3.record("T3:");
141 let f4 = await_for_test.consumeSomeOfInfinite();
142 await_for_test.t4.record("T4:");
143 async_helper$.asyncStart();
144 async.Future.wait(dart.dynamic)(JSArrayOfFuture().of([async.Future._check(f1 ), async.Future._check(f2), async.Future._check(f3), async.Future._check(f4)])). then(dart.dynamic)(dart.fn(_ => {
145 expect$.Expect.equals("T1:12345X", dart.toString(await_for_test.t1));
146 expect$.Expect.equals("T2:12345Y", dart.toString(await_for_test.t2));
147 expect$.Expect.equals("T3:112345|212345|312345|412345|512345|Z", dart.toSt ring(await_for_test.t3));
148 expect$.Expect.equals("T4:12345678910U", dart.toString(await_for_test.t4)) ;
149 async_helper$.asyncEnd();
150 }, ListTodynamic()));
151 };
152 dart.fn(await_for_test.main, VoidTodynamic());
153 let const$;
154 await_for_test.timedCounter = function(maxCount) {
155 let controller = null;
156 let timer = null;
157 let counter = 0;
158 function tick(_) {
159 counter++;
160 controller.add(counter);
161 if (counter >= dart.notNull(maxCount)) {
162 timer.cancel();
163 controller.close();
164 }
165 }
166 dart.fn(tick, dynamicTovoid());
167 function startTimer() {
168 timer = async.Timer.periodic(const$ || (const$ = dart.const(new core.Durat ion({milliseconds: 10}))), tick);
169 }
170 dart.fn(startTimer, VoidTovoid());
171 function stopTimer() {
172 if (timer != null) {
173 timer.cancel();
174 timer = null;
175 }
176 }
177 dart.fn(stopTimer, VoidTovoid());
178 controller = async.StreamController.new({onListen: startTimer, onPause: stop Timer, onResume: startTimer, onCancel: stopTimer});
179 return controller.stream;
180 };
181 dart.fn(await_for_test.timedCounter, intToStream());
182 let const$0;
183 await_for_test.infiniteStream = function() {
184 let controller = null;
185 let timer = null;
186 let counter = 0;
187 function tick(_) {
188 counter++;
189 controller.add(counter);
190 }
191 dart.fn(tick, dynamicTovoid());
192 function startTimer() {
193 timer = async.Timer.periodic(const$0 || (const$0 = dart.const(new core.Dur ation({milliseconds: 10}))), tick);
194 }
195 dart.fn(startTimer, VoidTovoid());
196 function stopTimer() {
197 if (timer != null) {
198 timer.cancel();
199 timer = null;
200 }
201 }
202 dart.fn(stopTimer, VoidTovoid());
203 controller = async.StreamController.new({onListen: startTimer, onPause: stop Timer, onResume: startTimer, onCancel: stopTimer});
204 return controller.stream;
205 };
206 dart.fn(await_for_test.infiniteStream, VoidToStream());
207 // Exports:
208 exports.await_for_test = await_for_test;
209 });
OLDNEW
« no previous file with comments | « test/codegen/expect/language/await_for_cancel_test.js ('k') | test/codegen/expect/language/await_for_use_local_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698