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

Side by Side Diff: tests/standalone/io/string_transformer_test.dart

Issue 22927016: Remove the LineTransformer from dart:io (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Changed one status file Created 7 years, 4 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
« no previous file with comments | « tests/standalone/io/stdin_sync_test.dart ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 import "package:expect/expect.dart";
6 import "dart:async"; 5 import "dart:async";
6 import "dart:convert";
7 import "dart:io"; 7 import "dart:io";
8 import "dart:isolate"; 8 import "dart:isolate";
9 import "dart:utf"; 9 import "dart:utf";
10 10
11 import "package:expect/expect.dart";
12
11 void main() { 13 void main() {
12 testUtf8(); 14 testUtf8();
13 testLatin1(); 15 testLatin1();
14 testAscii(); 16 testAscii();
15 testReadLine1(); 17 testReadLine1();
16 testReadLine2(); 18 testReadLine2();
17 testErrorHandler(); 19 testErrorHandler();
18 testLatin1EncoderError(); 20 testLatin1EncoderError();
19 } 21 }
20 22
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 Expect.equals("Dart", s.substring(1, 5)); 96 Expect.equals("Dart", s.substring(1, 5));
95 Expect.equals(new String.fromCharCodes([0x7f]), s[5]); 97 Expect.equals(new String.fromCharCodes([0x7f]), s[5]);
96 Expect.equals('????', s.substring(6, 10)); 98 Expect.equals('????', s.substring(6, 10));
97 }); 99 });
98 } 100 }
99 101
100 void testReadLine1() { 102 void testReadLine1() {
101 var controller = new StreamController(sync: true); 103 var controller = new StreamController(sync: true);
102 var stream = controller.stream 104 var stream = controller.stream
103 .transform(new StringDecoder()) 105 .transform(new StringDecoder())
104 .transform(new LineTransformer()); 106 .transform(new LineSplitter());
105 107
106 var stage = 0; 108 var stage = 0;
107 109
108 void stringData(line) { 110 void stringData(line) {
109 Expect.equals(stage, 0); 111 Expect.equals(stage, 0);
110 Expect.equals("Line", line); 112 Expect.equals("Line", line);
111 stage++; 113 stage++;
112 } 114 }
113 115
114 void streamClosed() { 116 void streamClosed() {
115 Expect.equals(1, stage); 117 Expect.equals(1, stage);
116 } 118 }
117 119
118 stream.listen( 120 stream.listen(
119 stringData, 121 stringData,
120 onDone: streamClosed); 122 onDone: streamClosed);
121 123
122 // Note: codeUnits is fine. Text is ASCII. 124 // Note: codeUnits is fine. Text is ASCII.
123 controller.add("Line".codeUnits); 125 controller.add("Line".codeUnits);
124 controller.close(); 126 controller.close();
125 Expect.equals(1, stage); 127 Expect.equals(1, stage);
126 } 128 }
127 129
128 void testReadLine2() { 130 void testReadLine2() {
129 var controller = new StreamController(sync: true); 131 var controller = new StreamController(sync: true);
130 132
131 var stream = controller.stream 133 var stream = controller.stream
132 .transform(new StringDecoder()) 134 .transform(new StringDecoder())
133 .transform(new LineTransformer()); 135 .transform(new LineSplitter());
134 136
135 var expectedLines = ['Line1', 'Line2','Line3', 'Line4', 137 var expectedLines = ['Line1', 'Line2','Line3', 'Line4',
136 '', '', '', '', '', '', 138 '', '', '', '', '', '',
137 'Line5', 'Line6']; 139 'Line5', 'Line6'];
138 140
139 var index = 0; 141 var index = 0;
140 142
141 stream.listen((line) { 143 stream.listen((line) {
142 Expect.equals(expectedLines[index++], line); 144 Expect.equals(expectedLines[index++], line);
143 }); 145 });
(...skipping 10 matching lines...) Expand all
154 156
155 class TestException implements Exception { 157 class TestException implements Exception {
156 TestException(); 158 TestException();
157 } 159 }
158 160
159 void testErrorHandler() { 161 void testErrorHandler() {
160 var controller = new StreamController(sync: true); 162 var controller = new StreamController(sync: true);
161 var errors = 0; 163 var errors = 0;
162 var stream = controller.stream 164 var stream = controller.stream
163 .transform(new StringDecoder()) 165 .transform(new StringDecoder())
164 .transform(new LineTransformer()); 166 .transform(new LineSplitter());
165 stream.listen( 167 stream.listen(
166 (_) {}, 168 (_) {},
167 onDone: () { 169 onDone: () {
168 Expect.equals(1, errors); 170 Expect.equals(1, errors);
169 }, 171 },
170 onError: (error) { 172 onError: (error) {
171 errors++; 173 errors++;
172 Expect.isTrue(error is TestException); 174 Expect.isTrue(error is TestException);
173 }); 175 });
174 controller.addError(new TestException()); 176 controller.addError(new TestException());
(...skipping 14 matching lines...) Expand all
189 .transform(new StringEncoder(Encoding.ISO_8859_1)); 191 .transform(new StringEncoder(Encoding.ISO_8859_1));
190 stream.listen( 192 stream.listen(
191 (s) { 193 (s) {
192 Expect.fail("data not expected"); 194 Expect.fail("data not expected");
193 }, 195 },
194 onError: (error) { 196 onError: (error) {
195 Expect.isTrue(error is FormatException); 197 Expect.isTrue(error is FormatException);
196 }); 198 });
197 199
198 } 200 }
OLDNEW
« no previous file with comments | « tests/standalone/io/stdin_sync_test.dart ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698