| 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(); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 Expect.equals('d', | 229 Expect.equals('d', |
| 230 new Path('a/b/f/../c/d').relativeTo(new Path('a/e/../b/c')).toString()); | 230 new Path('a/b/f/../c/d').relativeTo(new Path('a/e/../b/c')).toString()); |
| 231 Expect.equals('..', | 231 Expect.equals('..', |
| 232 new Path('a/b/f/../c').relativeTo(new Path('a/e/../b/c/e/')).toString()); | 232 new Path('a/b/f/../c').relativeTo(new Path('a/e/../b/c/e/')).toString()); |
| 233 Expect.equals('../..', | 233 Expect.equals('../..', |
| 234 new Path('').relativeTo(new Path('a/b/')).toString()); | 234 new Path('').relativeTo(new Path('a/b/')).toString()); |
| 235 Expect.equals('../../..', | 235 Expect.equals('../../..', |
| 236 new Path('..').relativeTo(new Path('a/b')).toString()); | 236 new Path('..').relativeTo(new Path('a/b')).toString()); |
| 237 Expect.equals('../b/c/d/', | 237 Expect.equals('../b/c/d/', |
| 238 new Path('b/c/d/').relativeTo(new Path('a/')).toString()); | 238 new Path('b/c/d/').relativeTo(new Path('a/')).toString()); |
| 239 Expect.equals('../a/b/c', |
| 240 new Path('x/y/a//b/./f/../c').relativeTo(new Path('x//y/z')).toString()); |
| 241 |
| 242 // Case where base is a substring of relative: |
| 243 Expect.equals('a/b', |
| 244 new Path('/x/y//a/b').relativeTo(new Path('/x/y/')).toString()); |
| 245 Expect.equals('a/b', |
| 246 new Path('x/y//a/b').relativeTo(new Path('x/y/')).toString()); |
| 247 Expect.equals('../ya/b', |
| 248 new Path('/x/ya/b').relativeTo(new Path('/x/y')).toString()); |
| 249 Expect.equals('../ya/b', |
| 250 new Path('x/ya/b').relativeTo(new Path('x/y')).toString()); |
| 251 Expect.equals('../b', |
| 252 new Path('x/y/../b').relativeTo(new Path('x/y/.')).toString()); |
| 253 Expect.equals('a/b/c', |
| 254 new Path('x/y/a//b/./f/../c').relativeTo(new Path('x/y')).toString()); |
| 255 Expect.equals('.', |
| 256 new Path('/x/y//').relativeTo(new Path('/x/y/')).toString()); |
| 257 Expect.equals('.', |
| 258 new Path('/x/y/').relativeTo(new Path('/x/y')).toString()); |
| 239 | 259 |
| 240 // Should always throw - no relative path can be constructed. | 260 // Should always throw - no relative path can be constructed. |
| 241 Expect.throws(() => | 261 Expect.throws(() => |
| 242 new Path('a/b').relativeTo(new Path('../../d'))); | 262 new Path('a/b').relativeTo(new Path('../../d'))); |
| 243 // Should always throw - relative and absolute paths are compared. | 263 // Should always throw - relative and absolute paths are compared. |
| 244 Expect.throws(() => | 264 Expect.throws(() => |
| 245 new Path('/a/b').relativeTo(new Path('c/d'))); | 265 new Path('/a/b').relativeTo(new Path('c/d'))); |
| 246 | 266 |
| 247 Expect.throws(() => | 267 Expect.throws(() => |
| 248 new Path('a/b').relativeTo(new Path('/a/b'))); | 268 new Path('a/b').relativeTo(new Path('/a/b'))); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 274 Expect.isTrue(canonical.toString().startsWith('/share/a')); | 294 Expect.isTrue(canonical.toString().startsWith('/share/a')); |
| 275 Expect.isTrue(canonical.toNativePath().startsWith(r'\\share\a')); | 295 Expect.isTrue(canonical.toNativePath().startsWith(r'\\share\a')); |
| 276 Expect.listEquals(['share', 'a', 'c'], canonical.segments()); | 296 Expect.listEquals(['share', 'a', 'c'], canonical.segments()); |
| 277 var appended = canonical.append('d'); | 297 var appended = canonical.append('d'); |
| 278 Expect.isTrue(appended.isAbsolute); | 298 Expect.isTrue(appended.isAbsolute); |
| 279 Expect.isTrue(appended.isWindowsShare); | 299 Expect.isTrue(appended.isWindowsShare); |
| 280 var directoryPath = canonical.directoryPath; | 300 var directoryPath = canonical.directoryPath; |
| 281 Expect.isTrue(directoryPath.isAbsolute); | 301 Expect.isTrue(directoryPath.isAbsolute); |
| 282 Expect.isTrue(directoryPath.isWindowsShare); | 302 Expect.isTrue(directoryPath.isWindowsShare); |
| 283 } | 303 } |
| OLD | NEW |