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

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

Issue 11345027: Do error propagation for decoder errors in string stream. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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 | « lib/io/string_stream.dart ('k') | no next file » | 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:io"); 5 #import("dart:io");
6 #import("dart:isolate");
6 7
7 void testUtf8() { 8 void testUtf8() {
8 List<int> data = [0x01, 9 List<int> data = [0x01,
9 0x7f, 10 0x7f,
10 0xc2, 0x80, 11 0xc2, 0x80,
11 0xdf, 0xbf, 12 0xdf, 0xbf,
12 0xe0, 0xa0, 0x80, 13 0xe0, 0xa0, 0x80,
13 0xef, 0xbf, 0xbf]; 14 0xef, 0xbf, 0xbf];
14 ListInputStream s = new ListInputStream(); 15 ListInputStream s = new ListInputStream();
15 s.write(data); 16 s.write(data);
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 testErrorHandler() { 292 testErrorHandler() {
292 var errors = 0; 293 var errors = 0;
293 var stream = new StringInputStream(new ErrorInputStream()); 294 var stream = new StringInputStream(new ErrorInputStream());
294 stream.onError = (e) { 295 stream.onError = (e) {
295 errors++; 296 errors++;
296 Expect.isTrue(e is TestException); 297 Expect.isTrue(e is TestException);
297 }; 298 };
298 Expect.equals(1, errors); 299 Expect.equals(1, errors);
299 } 300 }
300 301
302 testEncodingErrorWithHandler() {
303 var port = new ReceivePort();
304 var errors = 0;
305 var expected = [206, 187, 120, 46, 32, 120, 10];
306 ListInputStream input = new ListInputStream();
307 input.write(expected);
308 var stringStream = new StringInputStream(input, Encoding.ASCII);
309 stringStream.onData = () {
310 Expect.fail("We should not get any data");
311 };
312 stringStream.onError = (e) {
313 port.close();
314 Expect.isTrue(e is Exception);
315 };
316 }
317
318
301 main() { 319 main() {
302 testUtf8(); 320 testUtf8();
303 testLatin1(); 321 testLatin1();
304 testAscii(); 322 testAscii();
305 testReadLine1(); 323 testReadLine1();
306 testReadLine2(); 324 testReadLine2();
307 testReadChunks(); 325 testReadChunks();
308 testReadMixed(); 326 testReadMixed();
309 testErrorHandler(); 327 testErrorHandler();
328 testEncodingErrorWithHandler();
310 } 329 }
OLDNEW
« no previous file with comments | « lib/io/string_stream.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698