Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix tests for dart 2 #21

Merged
merged 3 commits into from
May 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.buildlog
.dart_tool/
.DS_Store
.idea
.pub/
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/src/guarantee_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class GuaranteeChannel<T> extends StreamChannelMixin<T> {
// to single-subscription.
if (innerStream.isBroadcast) {
innerStream =
innerStream.transform(const SingleSubscriptionTransformer());
innerStream.transform(new SingleSubscriptionTransformer<T, T>());
}

_streamController = new StreamController<T>(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
homepage: https://github.com/dart-lang/stream_channel
Expand Down
4 changes: 2 additions & 2 deletions test/json_document_transformer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ void main() {
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);
});
Expand Down
43 changes: 21 additions & 22 deletions test/stream_channel_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import 'package:stream_channel/stream_channel.dart';
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();
Expand Down Expand Up @@ -58,36 +58,35 @@ void main() {
});

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", () {
Expand Down