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

Side by Side Diff: tests/language/asyncstar_yieldstar_test.dart

Issue 912513002: Status updates, and minor fixes to tests of async-await. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « tests/language/asyncstar_yield_test.dart ('k') | tests/language/await_for_cancel_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import "dart:async"; 5 import "dart:async";
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 import "package:async_helper/async_helper.dart"; 7 import "package:async_helper/async_helper.dart";
8 8
9 Stream<int> subStream(p) async* { 9 Stream<int> subStream(p) async* {
10 yield p; 10 yield p;
(...skipping 13 matching lines...) Expand all
24 Expect.isTrue(i < 10); 24 Expect.isTrue(i < 10);
25 // Canceling the stream-subscription should run the finalizer. 25 // Canceling the stream-subscription should run the finalizer.
26 finalized.complete(true); 26 finalized.complete(true);
27 } 27 }
28 } 28 }
29 29
30 foo2(Stream subStream) async* { 30 foo2(Stream subStream) async* {
31 yield* subStream; 31 yield* subStream;
32 } 32 }
33 33
34 main () async { 34 test() async {
35 asyncStart();
36 print("starting");
37 Expect.listEquals([0, 1], 35 Expect.listEquals([0, 1],
38 await (subStream(0).toList())); 36 await (subStream(0).toList()));
39 Completer<bool> finalized = new Completer<bool>(); 37 Completer<bool> finalized = new Completer<bool>();
40 Expect.listEquals(["outer", 0, 1, "outer", 1, 2, "outer", 2], 38 Expect.listEquals(["outer", 0, 1, "outer", 1, 2, "outer", 2],
41 await (foo(finalized).take(8).toList())); 39 await (foo(finalized).take(8).toList()));
42 Expect.isTrue(await (finalized.future)); 40 Expect.isTrue(await (finalized.future));
43 41
44 finalized = new Completer<bool>(); 42 finalized = new Completer<bool>();
45 // Canceling the stream while it is yield*-ing from the sub-stream. 43 // Canceling the stream while it is yield*-ing from the sub-stream.
46 Expect.listEquals(["outer", 0, 1, "outer", 1, 2, "outer"], 44 Expect.listEquals(["outer", 0, 1, "outer", 1, 2, "outer"],
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 83 }
86 if (event == 5) { 84 if (event == 5) {
87 subscription.cancel(); 85 subscription.cancel();
88 } 86 }
89 }); 87 });
90 // Test that the yield*'ed streamSubscription is paused, resumed and canceled 88 // Test that the yield*'ed streamSubscription is paused, resumed and canceled
91 // by the async* stream. 89 // by the async* stream.
92 Expect.isTrue(await pausedCompleter.future); 90 Expect.isTrue(await pausedCompleter.future);
93 Expect.isTrue(await resumedCompleter.future); 91 Expect.isTrue(await resumedCompleter.future);
94 Expect.isTrue(await canceledCompleter.future); 92 Expect.isTrue(await canceledCompleter.future);
95 93 }
96 asyncEnd(); 94
95 main() {
96 asyncStart();
97 test().then((_) {
98 asyncEnd();
99 });
97 } 100 }
OLDNEW
« no previous file with comments | « tests/language/asyncstar_yield_test.dart ('k') | tests/language/await_for_cancel_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698