Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(670)

Side by Side Diff: tests/standalone/io/path_test.dart

Issue 11959011: Fix Path.relativeTo in special case where base is a substring of this. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed another bug - added tests for it. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/io/path_impl.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « sdk/lib/io/path_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698