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

Unified Diff: tests/lib/async/wait_for_cancel_test.dart

Issue 1284223005: Forward cancel subscription in stream pipes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comment. Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/language/language.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/async/wait_for_cancel_test.dart
diff --git a/tests/language/async_star_stream_take_test.dart b/tests/lib/async/wait_for_cancel_test.dart
similarity index 50%
copy from tests/language/async_star_stream_take_test.dart
copy to tests/lib/async/wait_for_cancel_test.dart
index 095082b0a36bca0fda34f50b2a6a6bcce58da1d4..7c400849ff9413e45a299459db2945c62b9f2a04 100644
--- a/tests/language/async_star_stream_take_test.dart
+++ b/tests/lib/async/wait_for_cancel_test.dart
@@ -6,21 +6,20 @@ import "dart:async";
import "package:expect/expect.dart";
import "package:async_helper/async_helper.dart";
-Stream makeStream(int n) async* {
- for (int i = 0; i < n; i++) yield i;
-}
-
main() {
- f(Stream s) async {
- var r = 0;
- await for(var v in s.take(5)) r += v;
- return r;
- }
-
asyncStart();
- f(makeStream(10)).then((v) {
- Expect.equals(10, v);
+
+ bool waitedForCancel = false;
+
+ var controller = new StreamController(
+ onCancel: () => new Future(() => waitedForCancel = true));
+ var sub = controller.stream.take(1).listen((x) {
+ Expect.fail("onData should not be called");
+ });
+ var cancelFuture = sub.cancel();
+ Expect.isNotNull(cancelFuture);
+ cancelFuture.then((_) {
+ Expect.isTrue(waitedForCancel);
asyncEnd();
});
}
-
« no previous file with comments | « tests/language/language.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698