Merge pull request #21 from dart-lang/fix-dart2-tests
fix tests for dart 2
diff --git a/.gitignore b/.gitignore
index 25a1df3..1447012 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
.buildlog
+.dart_tool/
.DS_Store
.idea
.pub/
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4813e9a..a2404d2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 1.6.6
+
+* Fix a Dart2 issue with inner stream transformation in `GuaranteeChannel`.
+
## 1.6.5
* Fix an issue with `JsonDocumentTransformer.bind` where it created an internal
diff --git a/lib/src/guarantee_channel.dart b/lib/src/guarantee_channel.dart
index f18cbb9..ba79ed9 100644
--- a/lib/src/guarantee_channel.dart
+++ b/lib/src/guarantee_channel.dart
@@ -39,7 +39,7 @@
// to single-subscription.
if (innerStream.isBroadcast) {
innerStream =
- innerStream.transform(const SingleSubscriptionTransformer());
+ innerStream.transform(new SingleSubscriptionTransformer<T, T>());
}
_streamController = new StreamController<T>(
diff --git a/pubspec.yaml b/pubspec.yaml
index 9221866..c121f5f 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: stream_channel
-version: 1.6.5
+version: 1.6.6
description: An abstraction for two-way communication channels.
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/dart-lang/stream_channel
diff --git a/test/json_document_transformer_test.dart b/test/json_document_transformer_test.dart
index 22bb830..b55a118 100644
--- a/test/json_document_transformer_test.dart
+++ b/test/json_document_transformer_test.dart
@@ -13,8 +13,8 @@
var sinkController;
StreamChannel<String> channel;
setUp(() {
- streamController = new StreamController();
- sinkController = new StreamController();
+ streamController = new StreamController<String>();
+ sinkController = new StreamController<String>();
channel =
new StreamChannel<String>(streamController.stream, sinkController.sink);
});
diff --git a/test/stream_channel_test.dart b/test/stream_channel_test.dart
index b8ebcbd..c29002f 100644
--- a/test/stream_channel_test.dart
+++ b/test/stream_channel_test.dart
@@ -10,9 +10,9 @@
import 'package:test/test.dart';
void main() {
- var streamController;
- var sinkController;
- var channel;
+ StreamController streamController;
+ StreamController sinkController;
+ StreamChannel channel;
setUp(() {
streamController = new StreamController();
sinkController = new StreamController();
@@ -58,36 +58,35 @@
});
test("transformStream() transforms only the stream", () async {
- var transformed = channel.transformStream(UTF8.decoder);
+ var transformed =
+ channel.cast<String>().transformStream(const LineSplitter());
- streamController.add([102, 111, 111, 98, 97, 114]);
+ streamController.add("hello world");
+ streamController.add(" what\nis");
+ streamController.add("\nup");
streamController.close();
- expect(await transformed.stream.toList(), equals(["foobar"]));
+ expect(await transformed.stream.toList(),
+ equals(["hello world what", "is", "up"]));
- transformed.sink.add("fblthp");
+ transformed.sink.add("fbl\nthp");
transformed.sink.close();
- expect(sinkController.stream.toList(), completion(equals(["fblthp"])));
+ expect(sinkController.stream.toList(), completion(equals(["fbl\nthp"])));
});
test("transformSink() transforms only the sink", () async {
- var transformed = channel.transformSink(
- new StreamSinkTransformer.fromStreamTransformer(UTF8.encoder));
+ var transformed = channel.cast<String>().transformSink(
+ new StreamSinkTransformer.fromStreamTransformer(const LineSplitter()));
- streamController.add([102, 111, 111, 98, 97, 114]);
+ streamController.add("fbl\nthp");
streamController.close();
- expect(
- await transformed.stream.toList(),
- equals([
- [102, 111, 111, 98, 97, 114]
- ]));
+ expect(await transformed.stream.toList(), equals(["fbl\nthp"]));
- transformed.sink.add("fblthp");
+ transformed.sink.add("hello world");
+ transformed.sink.add(" what\nis");
+ transformed.sink.add("\nup");
transformed.sink.close();
- expect(
- sinkController.stream.toList(),
- completion(equals([
- [102, 98, 108, 116, 104, 112]
- ])));
+ expect(sinkController.stream.toList(),
+ completion(equals(["hello world what", "is", "up"])));
});
test("changeStream() changes the stream", () {