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

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

Issue 1521693002: Roll Observatory deps (charted -> ^0.3.0) (Closed) Base URL: https://chromium.googlesource.com/external/github.com/dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years 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/test/relative_test.dart ('k') | packages/path/test/utils.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 import 'package:unittest/unittest.dart'; 5 import 'package:test/test.dart';
6 import 'package:path/path.dart' as path; 6 import 'package:path/path.dart' as path;
7 7
8 main() { 8 main() {
9 var context = new path.Context( 9 var context = new path.Context(
10 style: path.Style.url, current: 'http://dartlang.org/root/path'); 10 style: path.Style.url, current: 'http://dartlang.org/root/path');
11 11
12 test('separator', () { 12 test('separator', () {
13 expect(context.separator, '/'); 13 expect(context.separator, '/');
14 }); 14 });
15 15
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 'http://dartlang.org', 'http://pub.dartlang.org/foo/bar'), isFalse); 622 'http://dartlang.org', 'http://pub.dartlang.org/foo/bar'), isFalse);
623 expect(context.isWithin('http://dartlang.org', '/foo/bar'), isTrue); 623 expect(context.isWithin('http://dartlang.org', '/foo/bar'), isTrue);
624 expect(context.isWithin('http://dartlang.org/foo', '/foo/bar'), isTrue); 624 expect(context.isWithin('http://dartlang.org/foo', '/foo/bar'), isTrue);
625 expect(context.isWithin('http://dartlang.org/foo', '/bar/baz'), isFalse); 625 expect(context.isWithin('http://dartlang.org/foo', '/bar/baz'), isFalse);
626 expect(context.isWithin('baz', 'http://dartlang.org/root/path/baz/bang'), 626 expect(context.isWithin('baz', 'http://dartlang.org/root/path/baz/bang'),
627 isTrue); 627 isTrue);
628 expect(context.isWithin('baz', 'http://dartlang.org/root/path/bang/baz'), 628 expect(context.isWithin('baz', 'http://dartlang.org/root/path/bang/baz'),
629 isFalse); 629 isFalse);
630 }); 630 });
631 631
632 test('complex cases', () {
633 expect(context.isWithin('foo/./bar', 'foo/bar/baz'), isTrue);
634 expect(context.isWithin('foo//bar', 'foo/bar/baz'), isTrue);
635 expect(context.isWithin('foo/qux/../bar', 'foo/bar/baz'), isTrue);
636 expect(context.isWithin('foo/bar', 'foo/bar/baz/../..'), isFalse);
637 expect(context.isWithin('foo/bar', 'foo/bar///'), isFalse);
638 expect(context.isWithin('foo/.bar', 'foo/.bar/baz'), isTrue);
639 expect(context.isWithin('foo/./bar', 'foo/.bar/baz'), isFalse);
640 expect(context.isWithin('foo/..bar', 'foo/..bar/baz'), isTrue);
641 expect(context.isWithin('foo/bar', 'foo/bar/baz/..'), isFalse);
642 expect(context.isWithin('foo/bar', 'foo/bar/baz/../qux'), isTrue);
643 expect(context.isWithin('http://example.org/', 'http://example.com/foo'),
644 isFalse);
645 expect(context.isWithin('http://example.org/', 'http://dartlang.org/foo'),
646 isFalse);
647 });
648
649 test('with root-relative paths', () {
650 expect(context.isWithin('/foo', 'http://dartlang.org/foo/bar'), isTrue);
651 expect(context.isWithin('http://dartlang.org/foo', '/foo/bar'), isTrue);
652 expect(context.isWithin('/root', 'foo/bar'), isTrue);
653 expect(context.isWithin('foo', '/root/path/foo/bar'), isTrue);
654 expect(context.isWithin('/foo', '/foo/bar'), isTrue);
655 });
656
632 test('from a relative root', () { 657 test('from a relative root', () {
633 var r = new path.Context(style: path.Style.url, current: 'foo/bar'); 658 var r = new path.Context(style: path.Style.url, current: 'foo/bar');
634 expect(r.isWithin('.', 'a/b/c'), isTrue); 659 expect(r.isWithin('.', 'a/b/c'), isTrue);
635 expect(r.isWithin('.', '../a/b/c'), isFalse); 660 expect(r.isWithin('.', '../a/b/c'), isFalse);
636 expect(r.isWithin('.', '../../a/foo/b/c'), isFalse); 661 expect(r.isWithin('.', '../../a/foo/b/c'), isFalse);
637 expect(r.isWithin('http://dartlang.org/', 'http://dartlang.org/baz/bang'), 662 expect(r.isWithin('http://dartlang.org/', 'http://dartlang.org/baz/bang'),
638 isTrue); 663 isTrue);
639 expect(r.isWithin('.', 'http://dartlang.org/baz/bang'), isFalse); 664 expect(r.isWithin('.', 'http://dartlang.org/baz/bang'), isFalse);
640 }); 665 });
641 }); 666 });
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 782
758 test('with a root-relative URI', () { 783 test('with a root-relative URI', () {
759 expect(context.prettyUri('/a/b'), '/a/b'); 784 expect(context.prettyUri('/a/b'), '/a/b');
760 }); 785 });
761 786
762 test('with a Uri object', () { 787 test('with a Uri object', () {
763 expect(context.prettyUri(Uri.parse('a/b')), 'a/b'); 788 expect(context.prettyUri(Uri.parse('a/b')), 'a/b');
764 }); 789 });
765 }); 790 });
766 } 791 }
OLDNEW
« no previous file with comments | « packages/path/test/relative_test.dart ('k') | packages/path/test/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698