Index: utils/tests/pub/path/path_posix_test.dart |
diff --git a/utils/tests/pub/path/path_posix_test.dart b/utils/tests/pub/path/path_posix_test.dart |
index a34c32d57c2c2802e481b4a0c88cef8b52563a84..c71b670c4377352890735e8793e83288d8b18c26 100644 |
--- a/utils/tests/pub/path/path_posix_test.dart |
+++ b/utils/tests/pub/path/path_posix_test.dart |
@@ -33,6 +33,25 @@ main() { |
expect(builder.extension(r'a.b\c'), r'.b\c'); |
}); |
+ test('rootOf', () { |
+ expect(builder.rootOf(''), null); |
+ expect(builder.rootOf('a'), null); |
+ expect(builder.rootOf('a/b'), null); |
Bob Nystrom
2012/12/12 00:01:20
I think these should return empty strings.
nweiz
2012/12/12 00:50:37
See other reply.
|
+ expect(builder.rootOf('/a/c'), '/'); |
+ expect(builder.rootOf('/'), '/'); |
+ }); |
+ |
+ test('dirname', () { |
+ expect(builder.dirname(''), '.'); |
+ expect(builder.dirname('a'), '.'); |
+ expect(builder.dirname('a/b'), 'a'); |
+ expect(builder.dirname('a/b/c'), 'a/b'); |
+ expect(builder.dirname('a/b.c'), 'a'); |
+ expect(builder.dirname('a/'), 'a'); |
+ expect(builder.dirname('a/.'), 'a'); |
+ expect(builder.dirname(r'a\b/c'), r'a\b'); |
Bob Nystrom
2012/12/12 00:01:20
Can you add tests for:
/ -> /
a/b/ -> a/b/ (subj
nweiz
2012/12/12 00:50:37
Done.
|
+ }); |
+ |
test('basename', () { |
expect(builder.basename(''), ''); |
expect(builder.basename('a'), 'a'); |
@@ -104,10 +123,38 @@ main() { |
}); |
test('ignores parts before an absolute path', () { |
+ expect(builder.join('a', '/', 'b', 'c'), '/b/c'); |
expect(builder.join('a', '/b', '/c', 'd'), '/c/d'); |
expect(builder.join('a', r'c:\b', 'c', 'd'), r'a/c:\b/c/d'); |
expect(builder.join('a', r'\\b', 'c', 'd'), r'a/\\b/c/d'); |
}); |
+ |
+ test('ignores trailing nulls', () { |
+ expect(builder.join('a', null), equals('a')); |
Bob Nystrom
2012/12/12 00:01:20
Do we want to allow join() with no arguments? It c
Bob Nystrom
2012/12/12 00:01:20
Everything else doesn't use explicit equals() here
nweiz
2012/12/12 00:50:37
I don't think so. Given that we don't have a way t
nweiz
2012/12/12 00:50:37
Every other test in Dart (not to mention Pub) uses
Bob Nystrom
2012/12/12 01:02:13
This will get pulled out of pub before too long, s
nweiz
2012/12/12 02:45:57
In everything else we stick with the Dart project
Bob Nystrom
2012/12/12 04:52:33
Sure, if it matters that much to you. In that case
|
+ expect(builder.join('a', 'b', 'c', null, null), equals('a/b/c')); |
+ }); |
+ |
+ test('disallows intermediate nulls', () { |
+ expect(() => builder.join('a', null, 'b'), throwsArgumentError); |
+ expect(() => builder.join(null, 'a'), throwsArgumentError); |
+ }); |
+ }); |
+ |
+ group('split', () { |
+ test('simple cases', () { |
+ expect(builder.split('foo'), equals(['foo'])); |
+ expect(builder.split('foo/bar'), equals(['foo', 'bar'])); |
+ expect(builder.split('foo/bar/baz'), equals(['foo', 'bar', 'baz'])); |
+ expect(builder.split('foo/../bar/./baz'), |
+ equals(['foo', '..', 'bar', '.', 'baz'])); |
+ expect(builder.split('foo//bar///baz'), equals(['foo', 'bar', 'baz'])); |
+ expect(builder.split('foo/\\/baz'), equals(['foo', '\\', 'baz'])); |
Bob Nystrom
2012/12/12 00:01:20
Also tests for:
. -> .
'' -> []
foo/ -> [foo]
//
nweiz
2012/12/12 00:50:37
Done.
|
+ }); |
+ |
+ test('includes the root for absolute paths', () { |
+ expect(builder.split('/foo/bar/baz'), equals(['/', 'foo', 'bar', 'baz'])); |
+ expect(builder.split('/'), equals(['/'])); |
+ }); |
}); |
group('normalize', () { |
@@ -238,6 +285,10 @@ main() { |
var r = new path.Builder(style: path.Style.posix, root: '/dir.ext'); |
expect(r.relative('/dir.ext/file'), 'file'); |
}); |
+ |
+ test('with a root parameter', () { |
+ expect(builder.relative('/foo/bar/baz', to: '/foo/bar'), equals('baz')); |
Bob Nystrom
2012/12/12 00:01:20
This is confusing. Does "to" mean "from" here? Isn
nweiz
2012/12/12 00:50:37
Changed "to" to "base".
|
+ }); |
}); |
group('resolve', () { |