Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(747)

Side by Side Diff: tests/lib/async/stream_event_transform_test.dart

Issue 12610006: Renamed StreamSink to EventSink. Renamed signalError to addError. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Changed inheritance back! Now create StreamSink instead of EventSink where we create them. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 'dart:async'; 7 import 'dart:async';
8 import '../../../pkg/unittest/lib/unittest.dart'; 8 import '../../../pkg/unittest/lib/unittest.dart';
9 import 'event_helper.dart'; 9 import 'event_helper.dart';
10 10
11 void handleData(int data, StreamSink<int> sink) { 11 void handleData(int data, EventSink<int> sink) {
12 sink.signalError(new AsyncError("$data")); 12 sink.addError(new AsyncError("$data"));
13 sink.add(data + 1); 13 sink.add(data + 1);
14 } 14 }
15 15
16 void handleError(AsyncError e, StreamSink<int> sink) { 16 void handleError(AsyncError e, EventSink<int> sink) {
17 String value = e.error; 17 String value = e.error;
18 int data = int.parse(value); 18 int data = int.parse(value);
19 sink.add(data); 19 sink.add(data);
20 sink.signalError(new AsyncError("${data + 1}")); 20 sink.addError(new AsyncError("${data + 1}"));
21 } 21 }
22 22
23 void handleDone(StreamSink<int> sink) { 23 void handleDone(EventSink<int> sink) {
24 sink.add(99); 24 sink.add(99);
25 sink.close(); 25 sink.close();
26 } 26 }
27 27
28 class EventTransformer extends StreamEventTransformer<int,int> { 28 class EventTransformer extends StreamEventTransformer<int,int> {
29 void handleData(int data, StreamSink<int> sink) { 29 void handleData(int data, EventSink<int> sink) {
30 sink.signalError(new AsyncError("$data")); 30 sink.addError(new AsyncError("$data"));
31 sink.add(data + 1); 31 sink.add(data + 1);
32 } 32 }
33 33
34 void handleError(AsyncError e, StreamSink<int> sink) { 34 void handleError(AsyncError e, EventSink<int> sink) {
35 String value = e.error; 35 String value = e.error;
36 int data = int.parse(value); 36 int data = int.parse(value);
37 sink.add(data); 37 sink.add(data);
38 sink.signalError(new AsyncError("${data + 1}")); 38 sink.addError(new AsyncError("${data + 1}"));
39 } 39 }
40 40
41 void handleDone(StreamSink<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();
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)
(...skipping 20 matching lines...) Expand all
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698