| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // Test the basic StreamController and StreamController.singleSubscription. | 5 // Test the basic StreamController and StreamController.singleSubscription. |
| 6 library stream_single_test; | 6 library stream_single_test; |
| 7 | 7 |
| 8 import "package:expect/expect.dart"; | |
| 9 import 'dart:async'; | 8 import 'dart:async'; |
| 10 import 'package:unittest/unittest.dart'; | 9 import 'package:test/test.dart'; |
| 11 import 'event_helper.dart'; | 10 import 'event_helper.dart'; |
| 12 | 11 |
| 13 main() { | 12 main() { |
| 14 test("tomulti 1", () { | 13 test("tomulti 1", () { |
| 15 StreamController c = new StreamController<int>(sync: true); | 14 StreamController c = new StreamController<int>(sync: true); |
| 16 Stream<int> multi = c.stream.asBroadcastStream(); | 15 Stream<int> multi = c.stream.asBroadcastStream(); |
| 17 // Listen twice. | 16 // Listen twice. |
| 18 multi.listen(expectAsync((v) => Expect.equals(42, v))); | 17 multi.listen(expectAsync((v) => expect(42, equals(v)))); |
| 19 multi.listen(expectAsync((v) => Expect.equals(42, v))); | 18 multi.listen(expectAsync((v) => expect(42, equals(v)))); |
| 20 c.add(42); | 19 c.add(42); |
| 21 }); | 20 }); |
| 22 | 21 |
| 23 test("tomulti 2", () { | 22 test("tomulti 2", () { |
| 24 StreamController c = new StreamController<int>(sync: true); | 23 StreamController c = new StreamController<int>(sync: true); |
| 25 Stream<int> multi = c.stream.asBroadcastStream(); | 24 Stream<int> multi = c.stream.asBroadcastStream(); |
| 26 Events expected = new Events.fromIterable([1, 2, 3, 4, 5]); | 25 Events expected = new Events.fromIterable([1, 2, 3, 4, 5]); |
| 27 Events actual1 = new Events.capture(multi); | 26 Events actual1 = new Events.capture(multi); |
| 28 Events actual2 = new Events.capture(multi); | 27 Events actual2 = new Events.capture(multi); |
| 29 actual1.onDone(expectAsync(() { | 28 actual1.onDone(expectAsync(() { |
| 30 Expect.listEquals(expected.events, actual1.events); | 29 expect(expected.events, equals(actual1.events)); |
| 31 })); | 30 })); |
| 32 actual2.onDone(expectAsync(() { | 31 actual2.onDone(expectAsync(() { |
| 33 Expect.listEquals(expected.events, actual2.events); | 32 expect(expected.events, equals(actual2.events)); |
| 34 })); | 33 })); |
| 35 expected.replay(c); | 34 expected.replay(c); |
| 36 }); | 35 }); |
| 37 | 36 |
| 38 test("tomulti no-op", () { | 37 test("tomulti no-op", () { |
| 39 StreamController c = new StreamController<int>(sync: true); | 38 StreamController c = new StreamController<int>(sync: true); |
| 40 Stream<int> multi = c.stream.asBroadcastStream(); | 39 Stream<int> multi = c.stream.asBroadcastStream(); |
| 41 Events expected = new Events.fromIterable([1, 2, 3, 4, 5]); | 40 Events expected = new Events.fromIterable([1, 2, 3, 4, 5]); |
| 42 Events actual1 = new Events.capture(multi); | 41 Events actual1 = new Events.capture(multi); |
| 43 Events actual2 = new Events.capture(multi); | 42 Events actual2 = new Events.capture(multi); |
| 44 actual1.onDone(expectAsync(() { | 43 actual1.onDone(expectAsync(() { |
| 45 Expect.listEquals(expected.events, actual1.events); | 44 expect(expected.events, equals(actual1.events)); |
| 46 })); | 45 })); |
| 47 actual2.onDone(expectAsync(() { | 46 actual2.onDone(expectAsync(() { |
| 48 Expect.listEquals(expected.events, actual2.events); | 47 expect(expected.events, equals(actual2.events)); |
| 49 })); | 48 })); |
| 50 expected.replay(c); | 49 expected.replay(c); |
| 51 }); | 50 }); |
| 52 } | 51 } |
| OLD | NEW |