| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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:async"; | 5 import "dart:async"; |
| 6 import "dart:io"; | 6 import "dart:io"; |
| 7 | 7 |
| 8 import "package:async_helper/async_helper.dart"; | 8 import "package:async_helper/async_helper.dart"; |
| 9 import "package:expect/expect.dart"; | 9 import "package:expect/expect.dart"; |
| 10 | 10 |
| 11 | 11 |
| 12 class FutureExpect { | 12 class FutureExpect { |
| 13 static Future isTrue(Future<bool> result) => | 13 static Future isTrue(Future<bool> result) => |
| 14 result.then((value) => Expect.isTrue(value)); | 14 result.then((value) => Expect.isTrue(value)); |
| 15 static Future isFalse(Future<bool> result) => | 15 static Future isFalse(Future<bool> result) => |
| 16 result.then((value) => Expect.isFalse(value)); | 16 result.then((value) => Expect.isFalse(value)); |
| 17 static Future equals(expected, Future result) => | 17 static Future equals(expected, Future result) => |
| 18 result.then((value) => Expect.equals(expected, value)); | 18 result.then((value) => Expect.equals(expected, value)); |
| 19 static Future listEquals(expected, Future result) => | 19 static Future listEquals(expected, Future result) => |
| 20 result.then((value) => Expect.listEquals(expected, value)); | 20 result.then((value) => Expect.listEquals(expected, value)); |
| 21 static Future throws(Future result) => | 21 static Future throws(Future result) => |
| 22 result.then((value) { | 22 result.then((value) { |
| 23 throw new ExpectException( | 23 throw new ExpectException( |
| 24 "FutureExpect.throws received $value instead of an exception"); | 24 "FutureExpect.throws received $value instead of an exception"); |
| 25 }, onError: (_) => null); | 25 }, onError: (_) => null); |
| 26 } | 26 } |
| 27 | 27 |
| 28 | 28 |
| 29 Future testJunctionTypeDelete() { | 29 Future testJunctionTypeDelete() { |
| 30 return new Directory('').createTemp().then((temp) { | 30 return Directory.systemTemp |
| 31 .createTemp('dart_windows_file_system_async_links') |
| 32 .then((temp) { |
| 31 var x = '${temp.path}${Platform.pathSeparator}x'; | 33 var x = '${temp.path}${Platform.pathSeparator}x'; |
| 32 var y = '${temp.path}${Platform.pathSeparator}y'; | 34 var y = '${temp.path}${Platform.pathSeparator}y'; |
| 33 return new Directory(x).create() | 35 return new Directory(x).create() |
| 34 .then((_) => new Link(y).create(x)) | 36 .then((_) => new Link(y).create(x)) |
| 35 .then((_) => FutureExpect.isTrue(new Directory(y).exists())) | 37 .then((_) => FutureExpect.isTrue(new Directory(y).exists())) |
| 36 .then((_) => FutureExpect.isTrue(new Directory(x).exists())) | 38 .then((_) => FutureExpect.isTrue(new Directory(x).exists())) |
| 37 .then((_) => FutureExpect.isTrue(FileSystemEntity.isLink(y))) | 39 .then((_) => FutureExpect.isTrue(FileSystemEntity.isLink(y))) |
| 38 .then((_) => FutureExpect.isFalse(FileSystemEntity.isLink(x))) | 40 .then((_) => FutureExpect.isFalse(FileSystemEntity.isLink(x))) |
| 39 .then((_) => FutureExpect.isTrue(FileSystemEntity.isDirectory(y))) | 41 .then((_) => FutureExpect.isTrue(FileSystemEntity.isDirectory(y))) |
| 40 .then((_) => FutureExpect.isTrue(FileSystemEntity.isDirectory(x))) | 42 .then((_) => FutureExpect.isTrue(FileSystemEntity.isDirectory(x))) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 } | 99 } |
| 98 | 100 |
| 99 | 101 |
| 100 main() { | 102 main() { |
| 101 // Links on other platforms are tested by file_system_[async_]links_test. | 103 // Links on other platforms are tested by file_system_[async_]links_test. |
| 102 if (Platform.operatingSystem == 'windows') { | 104 if (Platform.operatingSystem == 'windows') { |
| 103 asyncStart(); | 105 asyncStart(); |
| 104 testJunctionTypeDelete().then((_) => asyncEnd()); | 106 testJunctionTypeDelete().then((_) => asyncEnd()); |
| 105 } | 107 } |
| 106 } | 108 } |
| OLD | NEW |