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"; |
8 import 'dart:async'; | 9 import 'dart:async'; |
9 import 'package:test/test.dart'; | 10 import 'package:unittest/unittest.dart'; |
10 import 'event_helper.dart'; | 11 import 'event_helper.dart'; |
11 | 12 |
12 main() { | 13 main() { |
13 test("tomulti 1", () { | 14 test("tomulti 1", () { |
14 StreamController c = new StreamController<int>(sync: true); | 15 StreamController c = new StreamController<int>(sync: true); |
15 Stream<int> multi = c.stream.asBroadcastStream(); | 16 Stream<int> multi = c.stream.asBroadcastStream(); |
16 // Listen twice. | 17 // Listen twice. |
17 multi.listen(expectAsync((v) => expect(42, equals(v)))); | 18 multi.listen(expectAsync((v) => Expect.equals(42, v))); |
18 multi.listen(expectAsync((v) => expect(42, equals(v)))); | 19 multi.listen(expectAsync((v) => Expect.equals(42, v))); |
19 c.add(42); | 20 c.add(42); |
20 }); | 21 }); |
21 | 22 |
22 test("tomulti 2", () { | 23 test("tomulti 2", () { |
23 StreamController c = new StreamController<int>(sync: true); | 24 StreamController c = new StreamController<int>(sync: true); |
24 Stream<int> multi = c.stream.asBroadcastStream(); | 25 Stream<int> multi = c.stream.asBroadcastStream(); |
25 Events expected = new Events.fromIterable([1, 2, 3, 4, 5]); | 26 Events expected = new Events.fromIterable([1, 2, 3, 4, 5]); |
26 Events actual1 = new Events.capture(multi); | 27 Events actual1 = new Events.capture(multi); |
27 Events actual2 = new Events.capture(multi); | 28 Events actual2 = new Events.capture(multi); |
28 actual1.onDone(expectAsync(() { | 29 actual1.onDone(expectAsync(() { |
29 expect(expected.events, equals(actual1.events)); | 30 Expect.listEquals(expected.events, actual1.events); |
30 })); | 31 })); |
31 actual2.onDone(expectAsync(() { | 32 actual2.onDone(expectAsync(() { |
32 expect(expected.events, equals(actual2.events)); | 33 Expect.listEquals(expected.events, actual2.events); |
33 })); | 34 })); |
34 expected.replay(c); | 35 expected.replay(c); |
35 }); | 36 }); |
36 | 37 |
37 test("tomulti no-op", () { | 38 test("tomulti no-op", () { |
38 StreamController c = new StreamController<int>(sync: true); | 39 StreamController c = new StreamController<int>(sync: true); |
39 Stream<int> multi = c.stream.asBroadcastStream(); | 40 Stream<int> multi = c.stream.asBroadcastStream(); |
40 Events expected = new Events.fromIterable([1, 2, 3, 4, 5]); | 41 Events expected = new Events.fromIterable([1, 2, 3, 4, 5]); |
41 Events actual1 = new Events.capture(multi); | 42 Events actual1 = new Events.capture(multi); |
42 Events actual2 = new Events.capture(multi); | 43 Events actual2 = new Events.capture(multi); |
43 actual1.onDone(expectAsync(() { | 44 actual1.onDone(expectAsync(() { |
44 expect(expected.events, equals(actual1.events)); | 45 Expect.listEquals(expected.events, actual1.events); |
45 })); | 46 })); |
46 actual2.onDone(expectAsync(() { | 47 actual2.onDone(expectAsync(() { |
47 expect(expected.events, equals(actual2.events)); | 48 Expect.listEquals(expected.events, actual2.events); |
48 })); | 49 })); |
49 expected.replay(c); | 50 expected.replay(c); |
50 }); | 51 }); |
51 } | 52 } |
OLD | NEW |