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

Side by Side Diff: packages/path/test/posix_test.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 4 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
« no previous file with comments | « packages/path/pubspec.yaml ('k') | packages/path/test/url_test.dart » ('j') | 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 library path.test.posix_test;
6
7 import 'package:test/test.dart'; 5 import 'package:test/test.dart';
8 import 'package:path/path.dart' as path; 6 import 'package:path/path.dart' as path;
9 7
10 import 'utils.dart'; 8 import 'utils.dart';
11 9
12 main() { 10 main() {
13 var context = 11 var context =
14 new path.Context(style: path.Style.posix, current: '/root/path'); 12 new path.Context(style: path.Style.posix, current: '/root/path');
15 13
16 test('separator', () { 14 test('separator', () {
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 }); 310 });
313 311
314 test('removes trailing separators', () { 312 test('removes trailing separators', () {
315 expect(context.normalize('./'), '.'); 313 expect(context.normalize('./'), '.');
316 expect(context.normalize('.//'), '.'); 314 expect(context.normalize('.//'), '.');
317 expect(context.normalize('a/'), 'a'); 315 expect(context.normalize('a/'), 'a');
318 expect(context.normalize('a/b/'), 'a/b'); 316 expect(context.normalize('a/b/'), 'a/b');
319 expect(context.normalize(r'a/b\'), r'a/b\'); 317 expect(context.normalize(r'a/b\'), r'a/b\');
320 expect(context.normalize('a/b///'), 'a/b'); 318 expect(context.normalize('a/b///'), 'a/b');
321 }); 319 });
320
321 test('when canonicalizing', () {
322 expect(context.canonicalize('.'), '/root/path');
323 expect(context.canonicalize('foo/bar'), '/root/path/foo/bar');
324 expect(context.canonicalize('FoO'), '/root/path/FoO');
325 });
322 }); 326 });
323 327
324 group('relative', () { 328 group('relative', () {
325 group('from absolute root', () { 329 group('from absolute root', () {
326 test('given absolute path in root', () { 330 test('given absolute path in root', () {
327 expect(context.relative('/'), '../..'); 331 expect(context.relative('/'), '../..');
328 expect(context.relative('/root'), '..'); 332 expect(context.relative('/root'), '..');
329 expect(context.relative('/root/path'), '.'); 333 expect(context.relative('/root/path'), '.');
330 expect(context.relative('/root/path/a'), 'a'); 334 expect(context.relative('/root/path/a'), 'a');
331 expect(context.relative('/root/path/a/b.txt'), 'a/b.txt'); 335 expect(context.relative('/root/path/a/b.txt'), 'a/b.txt');
(...skipping 11 matching lines...) Expand all
343 // The path is considered relative to the root, so it basically just 347 // The path is considered relative to the root, so it basically just
344 // normalizes. 348 // normalizes.
345 expect(context.relative(''), '.'); 349 expect(context.relative(''), '.');
346 expect(context.relative('.'), '.'); 350 expect(context.relative('.'), '.');
347 expect(context.relative('a'), 'a'); 351 expect(context.relative('a'), 'a');
348 expect(context.relative('a/b.txt'), 'a/b.txt'); 352 expect(context.relative('a/b.txt'), 'a/b.txt');
349 expect(context.relative('../a/b.txt'), '../a/b.txt'); 353 expect(context.relative('../a/b.txt'), '../a/b.txt');
350 expect(context.relative('a/./b/../c.txt'), 'a/c.txt'); 354 expect(context.relative('a/./b/../c.txt'), 'a/c.txt');
351 }); 355 });
352 356
357 test('is case-sensitive', () {
358 expect(context.relative('/RoOt'), '../../RoOt');
359 expect(context.relative('/rOoT/pAtH/a'), '../../rOoT/pAtH/a');
360 });
361
353 // Regression 362 // Regression
354 test('from root-only path', () { 363 test('from root-only path', () {
355 expect(context.relative('/', from: '/'), '.'); 364 expect(context.relative('/', from: '/'), '.');
356 expect(context.relative('/root/path', from: '/'), 'root/path'); 365 expect(context.relative('/root/path', from: '/'), 'root/path');
357 }); 366 });
358 }); 367 });
359 368
360 group('from relative root', () { 369 group('from relative root', () {
361 var r = new path.Context(style: path.Style.posix, current: 'foo/bar'); 370 var r = new path.Context(style: path.Style.posix, current: 'foo/bar');
362 371
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 test('from a relative root', () { 444 test('from a relative root', () {
436 var r = new path.Context(style: path.Style.posix, current: 'foo/bar'); 445 var r = new path.Context(style: path.Style.posix, current: 'foo/bar');
437 expect(r.isWithin('.', 'a/b/c'), isTrue); 446 expect(r.isWithin('.', 'a/b/c'), isTrue);
438 expect(r.isWithin('.', '../a/b/c'), isFalse); 447 expect(r.isWithin('.', '../a/b/c'), isFalse);
439 expect(r.isWithin('.', '../../a/foo/b/c'), isFalse); 448 expect(r.isWithin('.', '../../a/foo/b/c'), isFalse);
440 expect(r.isWithin('/', '/baz/bang'), isTrue); 449 expect(r.isWithin('/', '/baz/bang'), isTrue);
441 expect(r.isWithin('.', '/baz/bang'), isFalse); 450 expect(r.isWithin('.', '/baz/bang'), isFalse);
442 }); 451 });
443 }); 452 });
444 453
454 group('equals and hash', () {
455 test('simple cases', () {
456 expectEquals(context, 'foo/bar', 'foo/bar');
457 expectNotEquals(context, 'foo/bar', 'foo/bar/baz');
458 expectNotEquals(context, 'foo/bar', 'foo');
459 expectNotEquals(context, 'foo/bar', 'foo/baz');
460 expectEquals(context, 'foo/bar', '../path/foo/bar');
461 expectEquals(context, '/', '/');
462 expectEquals(context, '/', '../..');
463 expectEquals(context, 'baz', '/root/path/baz');
464 });
465
466 test('complex cases', () {
467 expectEquals(context, 'foo/./bar', 'foo/bar');
468 expectEquals(context, 'foo//bar', 'foo/bar');
469 expectEquals(context, 'foo/qux/../bar', 'foo/bar');
470 expectNotEquals(context, 'foo/qux/../bar', 'foo/qux');
471 expectNotEquals(context, 'foo/bar', 'foo/bar/baz/../..');
472 expectEquals(context, 'foo/bar', 'foo/bar///');
473 expectEquals(context, 'foo/.bar', 'foo/.bar');
474 expectNotEquals(context, 'foo/./bar', 'foo/.bar');
475 expectEquals(context, 'foo/..bar', 'foo/..bar');
476 expectNotEquals(context, 'foo/../bar', 'foo/..bar');
477 expectEquals(context, 'foo/bar', 'foo/bar/baz/..');
478 expectNotEquals(context, 'FoO/bAr', 'foo/bar');
479 });
480
481 test('from a relative root', () {
482 var r = new path.Context(style: path.Style.posix, current: 'foo/bar');
483 expectEquals(r, 'a/b', 'a/b');
484 expectNotEquals(r, '.', 'foo/bar');
485 expectNotEquals(r, '.', '../a/b');
486 expectEquals(r, '.', '../bar');
487 expectEquals(r, '/baz/bang', '/baz/bang');
488 expectNotEquals(r, 'baz/bang', '/baz/bang');
489 });
490 });
491
445 group('absolute', () { 492 group('absolute', () {
446 test('allows up to seven parts', () { 493 test('allows up to seven parts', () {
447 expect(context.absolute('a'), '/root/path/a'); 494 expect(context.absolute('a'), '/root/path/a');
448 expect(context.absolute('a', 'b'), '/root/path/a/b'); 495 expect(context.absolute('a', 'b'), '/root/path/a/b');
449 expect(context.absolute('a', 'b', 'c'), '/root/path/a/b/c'); 496 expect(context.absolute('a', 'b', 'c'), '/root/path/a/b/c');
450 expect(context.absolute('a', 'b', 'c', 'd'), '/root/path/a/b/c/d'); 497 expect(context.absolute('a', 'b', 'c', 'd'), '/root/path/a/b/c/d');
451 expect(context.absolute('a', 'b', 'c', 'd', 'e'), '/root/path/a/b/c/d/e'); 498 expect(context.absolute('a', 'b', 'c', 'd', 'e'), '/root/path/a/b/c/d/e');
452 expect(context.absolute('a', 'b', 'c', 'd', 'e', 'f'), 499 expect(context.absolute('a', 'b', 'c', 'd', 'e', 'f'),
453 '/root/path/a/b/c/d/e/f'); 500 '/root/path/a/b/c/d/e/f');
454 expect(context.absolute('a', 'b', 'c', 'd', 'e', 'f', 'g'), 501 expect(context.absolute('a', 'b', 'c', 'd', 'e', 'f', 'g'),
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 589
543 test('with a root-relative URI', () { 590 test('with a root-relative URI', () {
544 expect(context.prettyUri('/a/b'), '/a/b'); 591 expect(context.prettyUri('/a/b'), '/a/b');
545 }); 592 });
546 593
547 test('with a Uri object', () { 594 test('with a Uri object', () {
548 expect(context.prettyUri(Uri.parse('a/b')), 'a/b'); 595 expect(context.prettyUri(Uri.parse('a/b')), 'a/b');
549 }); 596 });
550 }); 597 });
551 } 598 }
OLDNEW
« no previous file with comments | « packages/path/pubspec.yaml ('k') | packages/path/test/url_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698