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 library stream_event_transform_test; | 5 library stream_event_transform_test; |
6 | 6 |
7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import '../../../pkg/unittest/lib/unittest.dart'; | 9 import '../../../pkg/unittest/lib/unittest.dart'; |
10 import 'event_helper.dart'; | 10 import 'event_helper.dart'; |
(...skipping 28 matching lines...) Expand all Loading... |
39 } | 39 } |
40 | 40 |
41 void handleDone(EventSink<int> sink) { | 41 void handleDone(EventSink<int> sink) { |
42 sink.add(99); | 42 sink.add(99); |
43 sink.close(); | 43 sink.close(); |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
47 main() { | 47 main() { |
48 { | 48 { |
49 StreamController c = new StreamController(); | 49 StreamController c = new StreamController(sync: true); |
50 Events expected = new Events()..error("0")..add(1) | 50 Events expected = new Events()..error("0")..add(1) |
51 ..error("1")..add(2) | 51 ..error("1")..add(2) |
52 ..add(3)..error("4") | 52 ..add(3)..error("4") |
53 ..add(99)..close(); | 53 ..add(99)..close(); |
54 Events input = new Events()..add(0)..add(1)..error("3")..close(); | 54 Events input = new Events()..add(0)..add(1)..error("3")..close(); |
55 Events actual = new Events.capture( | 55 Events actual = new Events.capture( |
56 c.stream.transform(new EventTransformer())); | 56 c.stream.transform(new EventTransformer())); |
57 actual.onDone(() { | 57 actual.onDone(() { |
58 Expect.listEquals(expected.events, actual.events); | 58 Expect.listEquals(expected.events, actual.events); |
59 }); | 59 }); |
60 input.replay(c); | 60 input.replay(c); |
61 } | 61 } |
62 | 62 |
63 { | 63 { |
64 StreamController c = new StreamController(); | 64 StreamController c = new StreamController(sync: true); |
65 Events expected = new Events()..error("0")..add(1) | 65 Events expected = new Events()..error("0")..add(1) |
66 ..error("1")..add(2) | 66 ..error("1")..add(2) |
67 ..add(3)..error("4") | 67 ..add(3)..error("4") |
68 ..add(99)..close(); | 68 ..add(99)..close(); |
69 Events input = new Events()..add(0)..add(1)..error("3")..close(); | 69 Events input = new Events()..add(0)..add(1)..error("3")..close(); |
70 Events actual = new Events.capture( | 70 Events actual = new Events.capture( |
71 c.stream.transform(new StreamTransformer( | 71 c.stream.transform(new StreamTransformer( |
72 handleData: handleData, | 72 handleData: handleData, |
73 handleError: handleError, | 73 handleError: handleError, |
74 handleDone: handleDone | 74 handleDone: handleDone |
75 ))); | 75 ))); |
76 actual.onDone(() { | 76 actual.onDone(() { |
77 Expect.listEquals(expected.events, actual.events); | 77 Expect.listEquals(expected.events, actual.events); |
78 }); | 78 }); |
79 input.replay(c); | 79 input.replay(c); |
80 } | 80 } |
81 } | 81 } |
OLD | NEW |