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

Unified Diff: tests/standalone/io/path_test.dart

Issue 10986078: Adding more relative path support. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Incorporating review feedback (removing debugging output). Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/path_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/path_test.dart
diff --git a/tests/standalone/io/path_test.dart b/tests/standalone/io/path_test.dart
index b448c9a379ed0fc54dd4854d65ff15df42a97a7b..a2b39a603dbbdbb3b5baf3a200e31d5b1ca87791 100644
--- a/tests/standalone/io/path_test.dart
+++ b/tests/standalone/io/path_test.dart
@@ -10,6 +10,7 @@ void main() {
testBaseFunctions();
testCanonicalize();
testJoinAppend();
+ testRelativeTo();
}
void testBaseFunctions() {
@@ -163,8 +164,9 @@ void testJoinAppend() {
// .join can only join a relative path to a path.
// It cannot join an absolute path to a path.
Expect.throws(() => new Path('/a/b/').join(new Path('/c/d')));
+}
- // Test Path.relativeTo.
+void testRelativeTo() {
Expect.equals('c/d',
new Path('/a/b/c/d').relativeTo(new Path('/a/b')).toString());
Expect.equals('c/d',
@@ -172,6 +174,19 @@ void testJoinAppend() {
Expect.equals('.',
new Path('/a').relativeTo(new Path('/a')).toString());
+ // Trailing / in base path represents directory
+ Expect.equals('../../z/x/y',
+ new Path('/a/b/z/x/y').relativeTo(new Path('/a/b/c/d/')).toString());
+ Expect.equals('../z/x/y',
+ new Path('/a/b/z/x/y').relativeTo(new Path('/a/b/c/d')).toString());
+ Expect.equals('../z/x/y/',
+ new Path('/a/b/z/x/y/').relativeTo(new Path('/a/b/c/d')).toString());
+
+ Expect.equals('../../z/x/y',
+ new Path('/z/x/y').relativeTo(new Path('/a/b/c')).toString());
+ Expect.equals('../../../z/x/y',
+ new Path('/z/x/y').relativeTo(new Path('/a/b/c/')).toString());
+
// Not implemented yet. Should return new Path('../b/c/d/').
Expect.throws(() =>
new Path('b/c/d/').relativeTo(new Path('a/')));
« no previous file with comments | « runtime/bin/path_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698