OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import "package:expect/expect.dart"; |
| 6 import "package:async_helper/async_helper.dart"; |
| 7 import 'dart:io'; |
| 8 |
| 9 void testReadAsString() { |
| 10 var tmp = new Directory('').createTempSync(); |
| 11 |
| 12 var file = new File('${tmp.path}/file'); |
| 13 file.createSync(); |
| 14 |
| 15 file.writeAsBytesSync([0xb0]); |
| 16 |
| 17 Expect.throws(file.readAsStringSync, (e) => e is FileException); |
| 18 |
| 19 asyncStart(); |
| 20 file.readAsString().then((_) { |
| 21 Expect.fail("expected exception"); |
| 22 }).catchError((e) { |
| 23 tmp.deleteSync(recursive: true); |
| 24 asyncEnd(); |
| 25 }, test: (e) => e is FileException); |
| 26 } |
| 27 |
| 28 void testReadAsLines() { |
| 29 var tmp = new Directory('').createTempSync(); |
| 30 |
| 31 var file = new File('${tmp.path}/file'); |
| 32 file.createSync(); |
| 33 |
| 34 file.writeAsBytesSync([0xb0]); |
| 35 |
| 36 Expect.throws(file.readAsLinesSync, (e) => e is FileException); |
| 37 |
| 38 asyncStart(); |
| 39 file.readAsLines().then((_) { |
| 40 Expect.fail("expected exception"); |
| 41 }).catchError((e) { |
| 42 tmp.deleteSync(recursive: true); |
| 43 asyncEnd(); |
| 44 }, test: (e) => e is FileException); |
| 45 } |
| 46 |
| 47 void main() { |
| 48 testReadAsString(); |
| 49 testReadAsLines(); |
| 50 } |
OLD | NEW |