| OLD | NEW |
| 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 | 6 |
| 7 void testUtf8() { | 7 void testUtf8() { |
| 8 List<int> data = [0x01, | 8 List<int> data = [0x01, |
| 9 0x7f, | 9 0x7f, |
| 10 0xc2, 0x80, | 10 0xc2, 0x80, |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 271 |
| 272 class TestException implements Exception { | 272 class TestException implements Exception { |
| 273 TestException(); | 273 TestException(); |
| 274 } | 274 } |
| 275 | 275 |
| 276 class ErrorInputStream implements InputStream { | 276 class ErrorInputStream implements InputStream { |
| 277 ErrorInputStream(); | 277 ErrorInputStream(); |
| 278 List<int> read([int len]) => null; | 278 List<int> read([int len]) => null; |
| 279 int readInto(List<int> buffer, [int offset, int len]) => 0; | 279 int readInto(List<int> buffer, [int offset, int len]) => 0; |
| 280 int available() => 0; | 280 int available() => 0; |
| 281 void pipe(OutputStream output, [bool close]){ } | 281 void pipe(OutputStream output, {bool close: true}){ } |
| 282 void close() { } | 282 void close() { } |
| 283 bool get closed => true; | 283 bool get closed => true; |
| 284 void set onData(void callback()) { } | 284 void set onData(void callback()) { } |
| 285 void set onClosed(void callback()) { } | 285 void set onClosed(void callback()) { } |
| 286 void set onError(void callback(Exception e)) { | 286 void set onError(void callback(Exception e)) { |
| 287 callback(new TestException()); | 287 callback(new TestException()); |
| 288 } | 288 } |
| 289 } | 289 } |
| 290 | 290 |
| 291 testErrorHandler() { | 291 testErrorHandler() { |
| 292 var errors = 0; | 292 var errors = 0; |
| 293 var stream = new StringInputStream(new ErrorInputStream()); | 293 var stream = new StringInputStream(new ErrorInputStream()); |
| 294 stream.onError = (e) { | 294 stream.onError = (e) { |
| 295 errors++; | 295 errors++; |
| 296 Expect.isTrue(e is TestException); | 296 Expect.isTrue(e is TestException); |
| 297 }; | 297 }; |
| 298 Expect.equals(1, errors); | 298 Expect.equals(1, errors); |
| 299 } | 299 } |
| 300 | 300 |
| 301 main() { | 301 main() { |
| 302 testUtf8(); | 302 testUtf8(); |
| 303 testLatin1(); | 303 testLatin1(); |
| 304 testAscii(); | 304 testAscii(); |
| 305 testReadLine1(); | 305 testReadLine1(); |
| 306 testReadLine2(); | 306 testReadLine2(); |
| 307 testReadChunks(); | 307 testReadChunks(); |
| 308 testReadMixed(); | 308 testReadMixed(); |
| 309 testErrorHandler(); | 309 testErrorHandler(); |
| 310 } | 310 } |
| OLD | NEW |