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

Unified Diff: sdk/lib/_internal/pub/test/error_group_test.dart

Issue 14753009: Make StreamSubscription be the active part of a stream. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 7 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/_internal/pub/lib/src/error_group.dart ('k') | sdk/lib/async/stream.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/test/error_group_test.dart
diff --git a/sdk/lib/_internal/pub/test/error_group_test.dart b/sdk/lib/_internal/pub/test/error_group_test.dart
index ff2f699dbacd75574e7b677a65c1bd600896746b..d22f12cf63ee7421178f2a6893610bdea7d8db79 100644
--- a/sdk/lib/_internal/pub/test/error_group_test.dart
+++ b/sdk/lib/_internal/pub/test/error_group_test.dart
@@ -210,8 +210,16 @@ main() {
});
test('should pass through values from the stream', () {
- expect(stream.elementAt(0), completion(equals(1)));
- expect(stream.elementAt(1), completion(equals(2)));
+ StreamIterator iter = new StreamIterator(stream);
+ iter.moveNext().then((hasNext) {
+ expect(hasNext, isTrue);
+ expect(iter.current, equals(1));
+ iter.moveNext().then((hasNext) {
+ expect(hasNext, isTrue);
+ expect(iter.current, equals(2));
+ expect(iter.moveNext(), completion(isFalse));
+ });
+ });
expect(errorGroup.done, completes);
controller..add(1)..add(2)..close();
@@ -232,15 +240,14 @@ main() {
});
test('should pass a signaled exception to the stream if it has a listener '
- 'and should unsubscribe that stream', () {
- expect(stream.first, throwsFormatException);
+ 'and should unsubscribe that stream', () {
// errorGroup shouldn't top-level the exception
+ expect(stream.first, throwsFormatException);
errorGroup.signalError(new FormatException());
- expect(stream.first.catchError((_) {
+ expect(new Future(() {
controller.add('value');
- return stream.isEmpty;
- }), completion(isTrue));
+ }), completes);
});
test('should notify the error group of a signaled exception even if the '
@@ -345,10 +352,12 @@ main() {
test("shouldn't throw a top-level exception if a stream receives an error "
"after the other listened stream completes", () {
- expect(stream1.toList(), completion(equals(['value1', 'value2'])));
+ var signal = new Completer();
+ expect(stream1.toList().whenComplete(signal.complete),
+ completion(equals(['value1', 'value2'])));
controller1..add('value1')..add('value2')..close();
- expect(stream1.toList().then((_) {
+ expect(signal.future.then((_) {
// shouldn't cause a top-level exception
controller2.addError(new FormatException());
}), completes);
@@ -356,10 +365,12 @@ main() {
test("shouldn't throw a top-level exception if an error is signaled after "
"one listened stream completes", () {
- expect(stream1.toList(), completion(equals(['value1', 'value2'])));
+ var signal = new Completer();
+ expect(stream1.toList().whenComplete(signal.complete),
+ completion(equals(['value1', 'value2'])));
controller1..add('value1')..add('value2')..close();
- expect(stream1.toList().then((_) {
+ expect(signal.future.then((_) {
// shouldn't cause a top-level exception
errorGroup.signalError(new FormatException());
}), completes);
@@ -419,10 +430,12 @@ main() {
test("shouldn't throw a top-level exception if the future receives an "
"error after the listened stream completes", () {
- expect(stream.toList(), completion(equals(['value1', 'value2'])));
+ var signal = new Completer();
+ expect(stream.toList().whenComplete(signal.complete),
+ completion(equals(['value1', 'value2'])));
controller..add('value1')..add('value2')..close();
- expect(stream.toList().then((_) {
+ expect(signal.future.then((_) {
// shouldn't cause a top-level exception
completer.completeError(new FormatException());
}), completes);
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/error_group.dart ('k') | sdk/lib/async/stream.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698