| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 class DirectoryInvalidArgumentsTest { | 5 class DirectoryInvalidArgumentsTest { |
| 6 static void testFailingList(Directory d, var recursive) { | 6 static void testFailingList(Directory d, var recursive) { |
| 7 int errors = 0; | 7 int errors = 0; |
| 8 d.setErrorHandler((error) { | 8 d.errorHandler = (error) { |
| 9 errors += 1; | 9 errors += 1; |
| 10 }); | 10 }; |
| 11 d.setDoneHandler((completed) { | 11 d.doneHandler = (completed) { |
| 12 Expect.equals(1, errors); | 12 Expect.equals(1, errors); |
| 13 Expect.isFalse(completed); | 13 Expect.isFalse(completed); |
| 14 }); | 14 }; |
| 15 Expect.equals(0, errors); | 15 Expect.equals(0, errors); |
| 16 d.list(recursive); | 16 d.list(recursive); |
| 17 } | 17 } |
| 18 | 18 |
| 19 static void testInvalidArguments() { | 19 static void testInvalidArguments() { |
| 20 Directory d = new Directory(12); | 20 Directory d = new Directory(12); |
| 21 Expect.isFalse(d.exists()); | 21 Expect.isFalse(d.existsSync()); |
| 22 try { | 22 try { |
| 23 d.delete(); | 23 d.deleteSync(); |
| 24 Expect.fail("No exception thrown"); | 24 Expect.fail("No exception thrown"); |
| 25 } catch (var e) { | 25 } catch (var e) { |
| 26 Expect.isTrue(e is DirectoryException); | 26 Expect.isTrue(e is DirectoryException); |
| 27 } | 27 } |
| 28 try { | 28 try { |
| 29 d.create(); | 29 d.createSync(); |
| 30 Expect.fail("No exception thrown"); | 30 Expect.fail("No exception thrown"); |
| 31 } catch (var e) { | 31 } catch (var e) { |
| 32 Expect.isTrue(e is DirectoryException); | 32 Expect.isTrue(e is DirectoryException); |
| 33 } | 33 } |
| 34 testFailingList(d, false); | 34 testFailingList(d, false); |
| 35 d = new Directory("."); | 35 d = new Directory("."); |
| 36 testFailingList(d, 1); | 36 testFailingList(d, 1); |
| 37 } | 37 } |
| 38 | 38 |
| 39 static void testMain() { | 39 static void testMain() { |
| 40 testInvalidArguments(); | 40 testInvalidArguments(); |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 | 43 |
| 44 main() { | 44 main() { |
| 45 DirectoryInvalidArgumentsTest.testMain(); | 45 DirectoryInvalidArgumentsTest.testMain(); |
| 46 } | 46 } |
| OLD | NEW |