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

Side by Side Diff: pkg/path/test/relative_test.dart

Issue 59483008: Add isWithin to pkg/path. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 7 years, 1 month 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 | « pkg/path/test/posix_test.dart ('k') | pkg/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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "relative" on all styles of path.Builder, on all platforms. 5 // Test "relative" on all styles of path.Builder, on all platforms.
6 6
7 import "package:unittest/unittest.dart"; 7 import "package:unittest/unittest.dart";
8 import "package:path/path.dart" as path; 8 import "package:path/path.dart" as path;
9 9
10 import "utils.dart";
11
10 void main() { 12 void main() {
11 test("test relative", () { 13 test("test relative", () {
12 relativeTest(new path.Builder(style: path.Style.posix, root: '.'), '/'); 14 relativeTest(new path.Builder(style: path.Style.posix, root: '.'), '/');
13 relativeTest(new path.Builder(style: path.Style.posix, root: '/'), '/'); 15 relativeTest(new path.Builder(style: path.Style.posix, root: '/'), '/');
14 relativeTest(new path.Builder(style: path.Style.windows, root: r'd:\'), 16 relativeTest(new path.Builder(style: path.Style.windows, root: r'd:\'),
15 r'c:\'); 17 r'c:\');
16 relativeTest(new path.Builder(style: path.Style.windows, root: '.'), 18 relativeTest(new path.Builder(style: path.Style.windows, root: '.'),
17 r'c:\'); 19 r'c:\');
18 relativeTest(new path.Builder(style: path.Style.url, root: 'file:///'), 20 relativeTest(new path.Builder(style: path.Style.url, root: 'file:///'),
19 'http://myserver/'); 21 'http://myserver/');
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 expectRelative('a/b', 'x/y//a/b', 'x/y/'); 70 expectRelative('a/b', 'x/y//a/b', 'x/y/');
69 expectRelative('../ya/b', '${prefix}x/ya/b', '${prefix}x/y'); 71 expectRelative('../ya/b', '${prefix}x/ya/b', '${prefix}x/y');
70 expectRelative('../ya/b', 'x/ya/b', 'x/y'); 72 expectRelative('../ya/b', 'x/ya/b', 'x/y');
71 expectRelative('../b', 'x/y/../b', 'x/y/.'); 73 expectRelative('../b', 'x/y/../b', 'x/y/.');
72 expectRelative('a/b/c', 'x/y/a//b/./f/../c', 'x/y'); 74 expectRelative('a/b/c', 'x/y/a//b/./f/../c', 'x/y');
73 expectRelative('.', '${prefix}x/y//', '${prefix}x/y/'); 75 expectRelative('.', '${prefix}x/y//', '${prefix}x/y/');
74 expectRelative('.', '${prefix}x/y/', '${prefix}x/y'); 76 expectRelative('.', '${prefix}x/y/', '${prefix}x/y');
75 77
76 // Should always throw - no relative path can be constructed. 78 // Should always throw - no relative path can be constructed.
77 if (isRelative) { 79 if (isRelative) {
78 expect(() => builder.relative('.', from: '..'), throwsArgumentError); 80 expect(() => builder.relative('.', from: '..'), throwsPathException);
79 expect(() => builder.relative('a/b', from: '../../d'), 81 expect(() => builder.relative('a/b', from: '../../d'),
80 throwsArgumentError); 82 throwsPathException);
81 expect(() => builder.relative('a/b', from: '${prefix}a/b'), 83 expect(() => builder.relative('a/b', from: '${prefix}a/b'),
82 throwsArgumentError); 84 throwsPathException);
83 // An absolute path relative from a relative path returns the absolute path. 85 // An absolute path relative from a relative path returns the absolute path.
84 expectRelative('${prefix}a/b', '${prefix}a/b', 'c/d'); 86 expectRelative('${prefix}a/b', '${prefix}a/b', 'c/d');
85 } 87 }
86 } 88 }
OLDNEW
« no previous file with comments | « pkg/path/test/posix_test.dart ('k') | pkg/path/test/url_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698