mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 01:30:32 +00:00
2e75c3d7ca
stream_controller_async_test and stream_join_test are built on async_minitest, so most of the issues were fixed by migrating it to use Never as the bottom type rather than Null. Change-Id: I6f43e818a7a8d6793844166c8f9fc07b3b0f7a16 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143562 Reviewed-by: Alexander Markov <alexmarkov@google.com> Reviewed-by: Régis Crelier <regis@google.com> Commit-Queue: Liam Appelbe <liama@google.com>
75 lines
1.8 KiB
Dart
75 lines
1.8 KiB
Dart
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
// Test the basic StreamController and StreamController.singleSubscription.
|
|
library stream_join_test;
|
|
|
|
import 'dart:async';
|
|
|
|
import 'package:expect/expect.dart';
|
|
import 'package:async_helper/async_minitest.dart';
|
|
|
|
import 'event_helper.dart';
|
|
|
|
main() {
|
|
test("join-empty", () {
|
|
StreamController c = new StreamController();
|
|
c.stream.join("X").then(expectAsync((String s) => expect(s, equals(""))));
|
|
c.close();
|
|
});
|
|
|
|
test("join-single", () {
|
|
StreamController c = new StreamController();
|
|
c.stream
|
|
.join("X")
|
|
.then(expectAsync((String s) => expect(s, equals("foo"))));
|
|
c.add("foo");
|
|
c.close();
|
|
});
|
|
|
|
test("join-three", () {
|
|
StreamController c = new StreamController();
|
|
c.stream
|
|
.join("X")
|
|
.then(expectAsync((String s) => expect(s, equals("fooXbarXbaz"))));
|
|
c.add("foo");
|
|
c.add("bar");
|
|
c.add("baz");
|
|
c.close();
|
|
});
|
|
|
|
test("join-three-non-string", () {
|
|
StreamController c = new StreamController();
|
|
c.stream
|
|
.join("X")
|
|
.then(expectAsync((String s) => expect(s, equals("fooXbarXbaz"))));
|
|
c.add(new Foo("foo"));
|
|
c.add(new Foo("bar"));
|
|
c.add(new Foo("baz"));
|
|
c.close();
|
|
});
|
|
|
|
test("join-error", () {
|
|
StreamController c = new StreamController();
|
|
Future<String?>.value(c.stream.join("X"))
|
|
.catchError(expectAsync((String s) => expect(s, equals("BAD!"))));
|
|
c.add(new Foo("foo"));
|
|
c.add(new Foo("bar"));
|
|
c.add(new Bad());
|
|
c.add(new Foo("baz"));
|
|
c.close();
|
|
});
|
|
}
|
|
|
|
class Foo {
|
|
String value;
|
|
Foo(this.value);
|
|
String toString() => value;
|
|
}
|
|
|
|
class Bad {
|
|
Bad();
|
|
String toString() => throw "BAD!";
|
|
}
|