| 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"; |
| 6 |
| 7 import "package:async_helper/async_helper.dart"; |
| 5 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 6 import "dart:io"; | |
| 7 import "dart:isolate"; | |
| 8 | 9 |
| 9 void testFailingList(Directory d, var recursive) { | 10 void testFailingList(Directory d, var recursive) { |
| 10 var port = new ReceivePort(); | 11 asyncStart(); |
| 11 int errors = 0; | 12 int errors = 0; |
| 12 d.list(recursive: recursive).listen( | 13 d.list(recursive: recursive).listen( |
| 13 () => Expect.fail("Unexpected listing result"), | 14 () => Expect.fail("Unexpected listing result"), |
| 14 onError: (error) { | 15 onError: (error) { |
| 15 errors += 1; | 16 errors += 1; |
| 16 }, | 17 }, |
| 17 onDone: () { | 18 onDone: () { |
| 18 port.close(); | |
| 19 Expect.equals(1, errors); | 19 Expect.equals(1, errors); |
| 20 asyncEnd(); |
| 20 }); | 21 }); |
| 21 Expect.equals(0, errors); | 22 Expect.equals(0, errors); |
| 22 } | 23 } |
| 23 | 24 |
| 24 void testInvalidArguments() { | 25 void testInvalidArguments() { |
| 25 try { | 26 try { |
| 26 Directory d = new Directory(12); | 27 Directory d = new Directory(12); |
| 27 Expect.fail("No exception thrown"); | 28 Expect.fail("No exception thrown"); |
| 28 } catch (e) { | 29 } catch (e) { |
| 29 Expect.isTrue(e is ArgumentError); | 30 Expect.isTrue(e is ArgumentError); |
| 30 } | 31 } |
| 31 Directory d = new Directory("."); | 32 Directory d = new Directory("."); |
| 32 testFailingList(d, 1); | 33 testFailingList(d, 1); |
| 33 Expect.throws(() => d.listSync(recursive: 1), | 34 Expect.throws(() => d.listSync(recursive: 1), |
| 34 (e) => e is ArgumentError); | 35 (e) => e is ArgumentError); |
| 35 } | 36 } |
| 36 | 37 |
| 37 main() { | 38 main() { |
| 38 testInvalidArguments(); | 39 testInvalidArguments(); |
| 39 } | 40 } |
| OLD | NEW |