OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015, 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 "dart:io"; |
| 7 |
| 8 testFile(String input) { |
| 9 if (Platform.isWindows) { |
| 10 input = input.replaceAll('/', '\\'); |
| 11 } |
| 12 var file = new File(input); |
| 13 var uri = file.uri; |
| 14 var file2 = new File.fromUri(uri); |
| 15 Expect.equals(file.path, file2.path, input); |
| 16 } |
| 17 |
| 18 testDirectory(String input, [String output]) { |
| 19 if (output == null) output = input; |
| 20 if (Platform.isWindows) { |
| 21 input = input.replaceAll('/', '\\'); |
| 22 output = output.replaceAll('/', '\\'); |
| 23 } |
| 24 var dir = new Directory(input); |
| 25 var uri = dir.uri; |
| 26 var dir2 = new Directory.fromUri(uri); |
| 27 Expect.equals(output, dir2.path, input); |
| 28 } |
| 29 |
| 30 void main() { |
| 31 testFile(""); |
| 32 testFile("/"); |
| 33 testFile("foo/bar"); |
| 34 testFile("/foo/bar"); |
| 35 testFile("/foo/bar/"); |
| 36 |
| 37 testDirectory("", "/"); |
| 38 testDirectory("/"); |
| 39 testDirectory("foo/bar", "foo/bar/"); |
| 40 testDirectory("/foo/bar", "/foo/bar/"); |
| 41 testDirectory("/foo/bar/"); |
| 42 } |
OLD | NEW |