Index: test/isolate_channel_test.dart |
diff --git a/test/isolate_channel_test.dart b/test/isolate_channel_test.dart |
index 9e4fddc954989332717118b62866081f0041ff85..fa4d8d5325525112c4d82cb0a64ac54ffc16ddb9 100644 |
--- a/test/isolate_channel_test.dart |
+++ b/test/isolate_channel_test.dart |
@@ -123,4 +123,39 @@ void main() { |
channel.sink.add(1); |
}); |
}); |
+ |
+ group("connect constructors", () { |
+ var connectPort; |
+ setUp(() { |
+ connectPort = new ReceivePort(); |
+ }); |
+ |
+ tearDown(() { |
+ connectPort.close(); |
+ }); |
+ |
+ test("create a connected pair of channels", () { |
+ var channel1 = new IsolateChannel.connectReceive(connectPort); |
+ var channel2 = new IsolateChannel.connectSend(connectPort.sendPort); |
+ |
+ channel1.sink.add(1); |
+ channel1.sink.add(2); |
+ channel1.sink.add(3); |
+ expect(channel2.stream.take(3).toList(), completion(equals([1, 2, 3]))); |
+ |
+ channel2.sink.add(4); |
+ channel2.sink.add(5); |
+ channel2.sink.add(6); |
+ expect(channel1.stream.take(3).toList(), completion(equals([4, 5, 6]))); |
+ }); |
+ |
+ test("the receiving channel produces an error if it gets the wrong message", |
+ () { |
+ var connectedChannel = new IsolateChannel.connectReceive(connectPort); |
+ connectPort.sendPort.send("wrong value"); |
+ |
+ expect(connectedChannel.stream.toList(), throwsStateError); |
+ expect(connectedChannel.sink.done, completes); |
+ }); |
+ }); |
} |