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

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

Issue 1415533015: If computation of Stream.periodic throws, forward the error to the stream. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Now ith actual change too. Created 5 years, 2 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 | « sdk/lib/async/stream.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/async/stream_periodic6_test.dart
diff --git a/tests/lib/async/stream_periodic_test.dart b/tests/lib/async/stream_periodic6_test.dart
similarity index 56%
copy from tests/lib/async/stream_periodic_test.dart
copy to tests/lib/async/stream_periodic6_test.dart
index b333966065bd78c19ff70e73ec83c92227443e96..1d4ffa332b05adc41b2fd3dfe73eaef735d2c1e5 100644
--- a/tests/lib/async/stream_periodic_test.dart
+++ b/tests/lib/async/stream_periodic6_test.dart
@@ -10,13 +10,20 @@ import 'package:unittest/unittest.dart';
main() {
test("stream-periodic1", () {
- Stream stream = new Stream.periodic(const Duration(milliseconds: 1));
- int receivedCount = 0;
+ Stream stream = new Stream.periodic(const Duration(milliseconds: 1),
+ (i) {
+ if (i == 3) throw 42;
+ return i;
+ });
+ int expected = 0;
var subscription;
subscription = stream.listen(expectAsync((data) {
- expect(data, isNull);
- receivedCount++;
- if (receivedCount == 5) subscription.cancel();
- }, count: 5));
+ expect(data, expected++);
+ if (expected == 5) subscription.cancel();
+ }, count: 4),
+ onError: expectAsync((e, s) {
+ expect(e, 42);
floitsch 2015/10/31 00:10:08 maybe also check, that expected == 3. Not necessar
Lasse Reichstein Nielsen 2015/10/31 11:09:10 I think the expectAsync ensures that the function
floitsch 2015/10/31 19:51:30 Right. Missed that one...
+ expected++;
+ }));
});
}
« no previous file with comments | « sdk/lib/async/stream.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698