Test empty strings arguments to path.join().

BUG=https://code.google.com/p/dart/issues/detail?id=11819
R=nweiz@google.com, whesse@google.com

Review URL: https://codereview.chromium.org//19219002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/path@25033 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/lib/path.dart b/lib/path.dart
index b425124..25ce0e6 100644
--- a/lib/path.dart
+++ b/lib/path.dart
@@ -525,7 +525,7 @@
     var needsSeparator = false;
     var isAbsoluteAndNotRootRelative = false;
 
-    for (var part in parts) {
+    for (var part in parts.where((part) => part != '')) {
       if (this.isRootRelative(part) && isAbsoluteAndNotRootRelative) {
         // If the new part is root-relative, it preserves the previous root but
         // replaces the path after it.
diff --git a/test/posix_test.dart b/test/posix_test.dart
index f3232bc..c26a5ba 100644
--- a/test/posix_test.dart
+++ b/test/posix_test.dart
@@ -153,6 +153,14 @@
       expect(builder.join('a', 'b', 'c', null, null), equals('a/b/c'));
     });
 
+    test('ignores empty strings', () {
+      expect(builder.join(''), '');
+      expect(builder.join('', ''), '');
+      expect(builder.join('', 'a'), 'a');
+      expect(builder.join('a', '', 'b', '', '', '', 'c'), 'a/b/c');
+      expect(builder.join('a', 'b', ''), 'a/b');
+    });
+
     test('disallows intermediate nulls', () {
       expect(() => builder.join('a', null, 'b'), throwsArgumentError);
       expect(() => builder.join(null, 'a'), throwsArgumentError);
diff --git a/test/url_test.dart b/test/url_test.dart
index 3e03d50..d040a59 100644
--- a/test/url_test.dart
+++ b/test/url_test.dart
@@ -223,6 +223,14 @@
       expect(builder.join('a', 'b', 'c', null, null), equals('a/b/c'));
     });
 
+    test('ignores empty strings', () {
+      expect(builder.join(''), '');
+      expect(builder.join('', ''), '');
+      expect(builder.join('', 'a'), 'a');
+      expect(builder.join('a', '', 'b', '', '', '', 'c'), 'a/b/c');
+      expect(builder.join('a', 'b', ''), 'a/b');
+    });
+
     test('disallows intermediate nulls', () {
       expect(() => builder.join('a', null, 'b'), throwsArgumentError);
       expect(() => builder.join(null, 'a'), throwsArgumentError);
diff --git a/test/windows_test.dart b/test/windows_test.dart
index 7b3cf60..7409439 100644
--- a/test/windows_test.dart
+++ b/test/windows_test.dart
@@ -172,6 +172,14 @@
       expect(builder.join('a', 'b', 'c', null, null), equals(r'a\b\c'));
     });
 
+    test('ignores empty strings', () {
+      expect(builder.join(''), '');
+      expect(builder.join('', ''), '');
+      expect(builder.join('', 'a'), 'a');
+      expect(builder.join('a', '', 'b', '', '', '', 'c'), r'a\b\c');
+      expect(builder.join('a', 'b', ''), r'a\b');
+    });
+
     test('disallows intermediate nulls', () {
       expect(() => builder.join('a', null, 'b'), throwsArgumentError);
       expect(() => builder.join(null, 'a'), throwsArgumentError);