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

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

Issue 12282038: Remove deprecated string features. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge to head 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
« no previous file with comments | « tests/standalone/io/string_decoder_test.dart ('k') | tests/utils/utf_test.dart » ('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 "dart:async"; 5 import "dart:async";
6 import "dart:io"; 6 import "dart:io";
7 import "dart:isolate"; 7 import "dart:isolate";
8 import "dart:utf"; 8 import "dart:utf";
9 9
10 void testUtf8() { 10 void testUtf8() {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 107 }
108 108
109 void streamClosed() { 109 void streamClosed() {
110 Expect.equals(2, stage); 110 Expect.equals(2, stage);
111 } 111 }
112 112
113 stream.listen( 113 stream.listen(
114 stringData, 114 stringData,
115 onDone: streamClosed); 115 onDone: streamClosed);
116 116
117 controller.add("Line".charCodes); 117 controller.add("Line".codeUnits);
118 } 118 }
119 119
120 void testReadLine2() { 120 void testReadLine2() {
121 var controller = new StreamController(); 121 var controller = new StreamController();
122 122
123 var stream = controller.stream 123 var stream = controller.stream
124 .transform(new StringDecoder()) 124 .transform(new StringDecoder())
125 .transform(new LineTransformer()); 125 .transform(new LineTransformer());
126 126
127 var stage = 0; 127 var stage = 0;
128 var subStage = 0; 128 var subStage = 0;
129 stream.listen((line) { 129 stream.listen((line) {
130 if (stage == 0) { 130 if (stage == 0) {
131 if (subStage == 0) { 131 if (subStage == 0) {
132 Expect.equals("Line1", line); 132 Expect.equals("Line1", line);
133 subStage++; 133 subStage++;
134 } else if (subStage == 1) { 134 } else if (subStage == 1) {
135 Expect.equals("Line2", line); 135 Expect.equals("Line2", line);
136 subStage++; 136 subStage++;
137 } else if (subStage == 2) { 137 } else if (subStage == 2) {
138 Expect.equals("Line3", line); 138 Expect.equals("Line3", line);
139 subStage = 0; 139 subStage = 0;
140 stage++; 140 stage++;
141 controller.add("ne4\n".charCodes); 141 controller.add("ne4\n".codeUnits);
142 } else { 142 } else {
143 Expect.fail("Stage 0 failed"); 143 Expect.fail("Stage 0 failed");
144 } 144 }
145 } else if (stage == 1) { 145 } else if (stage == 1) {
146 if (subStage == 0) { 146 if (subStage == 0) {
147 Expect.equals("Line4", line); 147 Expect.equals("Line4", line);
148 subStage = 0; 148 subStage = 0;
149 stage++; 149 stage++;
150 controller.add("\n\n\r\n\r\n\r\r".charCodes); 150 controller.add("\n\n\r\n\r\n\r\r".codeUnits);
151 } else { 151 } else {
152 Expect.fail("Stage 1 failed"); 152 Expect.fail("Stage 1 failed");
153 } 153 }
154 } else if (stage == 2) { 154 } else if (stage == 2) {
155 if (subStage < 4) { 155 if (subStage < 4) {
156 // Expect 5 empty lines. As long as the stream is not closed the 156 // Expect 5 empty lines. As long as the stream is not closed the
157 // final \r cannot be interpreted as a end of line. 157 // final \r cannot be interpreted as a end of line.
158 Expect.equals("", line); 158 Expect.equals("", line);
159 subStage++; 159 subStage++;
160 } else if (subStage == 4) { 160 } else if (subStage == 4) {
(...skipping 10 matching lines...) Expand all
171 stage++; 171 stage++;
172 } else { 172 } else {
173 Expect.fail("Stage 3 failed"); 173 Expect.fail("Stage 3 failed");
174 } 174 }
175 } 175 }
176 }, onDone: () { 176 }, onDone: () {
177 Expect.equals(4, stage); 177 Expect.equals(4, stage);
178 Expect.equals(0, subStage); 178 Expect.equals(0, subStage);
179 }); 179 });
180 180
181 controller.add("Line1\nLine2\r\nLine3\rLi".charCodes); 181 controller.add("Line1\nLine2\r\nLine3\rLi".codeUnits);
182 } 182 }
183 183
184 class TestException implements Exception { 184 class TestException implements Exception {
185 TestException(); 185 TestException();
186 } 186 }
187 187
188 testErrorHandler() { 188 testErrorHandler() {
189 var controller = new StreamController(); 189 var controller = new StreamController();
190 var errors = 0; 190 var errors = 0;
191 var stream = controller.stream 191 var stream = controller.stream
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 229
230 main() { 230 main() {
231 testUtf8(); 231 testUtf8();
232 testLatin1(); 232 testLatin1();
233 testAscii(); 233 testAscii();
234 testReadLine1(); 234 testReadLine1();
235 testReadLine2(); 235 testReadLine2();
236 testErrorHandler(); 236 testErrorHandler();
237 testLatin1EncoderError(); 237 testLatin1EncoderError();
238 } 238 }
OLDNEW
« no previous file with comments | « tests/standalone/io/string_decoder_test.dart ('k') | tests/utils/utf_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698