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(); |
}); |
} |
- |