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 // Test the Path class in dart:io. | 5 // Test the Path class in dart:io. |
6 | 6 |
7 import "dart:io"; | 7 import "dart:io"; |
8 | 8 |
9 void main() { | 9 void main() { |
10 testBaseFunctions(); | 10 testBaseFunctions(); |
11 testRaw(); | 11 testRaw(); |
| 12 testToNativePath(); |
12 testCanonicalize(); | 13 testCanonicalize(); |
13 testJoinAppend(); | 14 testJoinAppend(); |
14 testRelativeTo(); | 15 testRelativeTo(); |
15 testWindowsShare(); | 16 testWindowsShare(); |
16 testWindowsDrive(); | 17 testWindowsDrive(); |
17 } | 18 } |
18 | 19 |
19 void testBaseFunctions() { | 20 void testBaseFunctions() { |
20 testGetters(new Path("/foo/bar/fisk.hest"), | 21 testGetters(new Path("/foo/bar/fisk.hest"), |
21 ['/foo/bar', 'fisk.hest', 'fisk', 'hest'], | 22 ['/foo/bar', 'fisk.hest', 'fisk', 'hest'], |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 Expect.equals(path.isAbsolute, properties.contains('absolute')); | 109 Expect.equals(path.isAbsolute, properties.contains('absolute')); |
109 Expect.equals(path.hasTrailingSeparator, properties.contains('trailing')); | 110 Expect.equals(path.hasTrailingSeparator, properties.contains('trailing')); |
110 } | 111 } |
111 | 112 |
112 void testRaw() { | 113 void testRaw() { |
113 Expect.equals(new Path.raw('c:\\foo/bar bad').toString(), 'c:\\foo/bar bad'); | 114 Expect.equals(new Path.raw('c:\\foo/bar bad').toString(), 'c:\\foo/bar bad'); |
114 Expect.equals(new Path.raw('').toString(), ''); | 115 Expect.equals(new Path.raw('').toString(), ''); |
115 Expect.equals(new Path.raw('\\bar\u2603\n.').toString(), '\\bar\u2603\n.'); | 116 Expect.equals(new Path.raw('\\bar\u2603\n.').toString(), '\\bar\u2603\n.'); |
116 } | 117 } |
117 | 118 |
| 119 void testToNativePath() { |
| 120 Expect.equals('.', new Path('').toNativePath()); |
| 121 Expect.equals('.', new Path('.').toNativePath()); |
| 122 Expect.equals('.', new Path('a_file').directoryPath.toNativePath()); |
| 123 } |
| 124 |
118 void testCanonicalize() { | 125 void testCanonicalize() { |
119 Function t = (input, canonicalized) { | 126 Function t = (input, canonicalized) { |
120 Expect.equals(canonicalized, new Path(input).canonicalize().toString()); | 127 Expect.equals(canonicalized, new Path(input).canonicalize().toString()); |
121 }; | 128 }; |
122 | 129 |
123 t('.', '.'); | 130 t('.', '.'); |
124 t('./.', '.'); | 131 t('./.', '.'); |
125 t('foo/..', '.'); | 132 t('foo/..', '.'); |
126 t('../foo', '../foo'); | 133 t('../foo', '../foo'); |
127 t('/../foo', '/foo'); | 134 t('/../foo', '/foo'); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 Expect.equals('../../c', CPath.relativeTo(cPath).toString()); | 331 Expect.equals('../../c', CPath.relativeTo(cPath).toString()); |
325 Expect.equals('../b/d', cPath.relativeTo(CPath).toString()); | 332 Expect.equals('../b/d', cPath.relativeTo(CPath).toString()); |
326 Expect.equals('.', DPath.relativeTo(DPath).toString()); | 333 Expect.equals('.', DPath.relativeTo(DPath).toString()); |
327 Expect.equals('.', NoPath.relativeTo(NoPath).toString()); | 334 Expect.equals('.', NoPath.relativeTo(NoPath).toString()); |
328 Expect.equals('.', C2Path.relativeTo(cPath).toString()); | 335 Expect.equals('.', C2Path.relativeTo(cPath).toString()); |
329 Expect.equals('..', C3Path.relativeTo(cPath).toString()); | 336 Expect.equals('..', C3Path.relativeTo(cPath).toString()); |
330 Expect.equals('d', cPath.relativeTo(C3Path).toString()); | 337 Expect.equals('d', cPath.relativeTo(C3Path).toString()); |
331 Expect.equals('a/b/d', cPath.relativeTo(C4Path).toString()); | 338 Expect.equals('a/b/d', cPath.relativeTo(C4Path).toString()); |
332 Expect.equals('../../../', C4Path.relativeTo(cPath).toString()); | 339 Expect.equals('../../../', C4Path.relativeTo(cPath).toString()); |
333 } | 340 } |
OLD | NEW |