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

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

Issue 12314047: Add path.joinAll. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/path/lib/path.dart ('k') | pkg/path/test/path_windows_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) 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 library path_test; 5 library path_test;
6 6
7 import 'dart:io' as io; 7 import 'dart:io' as io;
8 8
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 import 'package:path/path.dart' as path; 10 import 'package:path/path.dart' as path;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 expect(builder.join('a', null), equals('a')); 154 expect(builder.join('a', null), equals('a'));
155 expect(builder.join('a', 'b', 'c', null, null), equals('a/b/c')); 155 expect(builder.join('a', 'b', 'c', null, null), equals('a/b/c'));
156 }); 156 });
157 157
158 test('disallows intermediate nulls', () { 158 test('disallows intermediate nulls', () {
159 expect(() => builder.join('a', null, 'b'), throwsArgumentError); 159 expect(() => builder.join('a', null, 'b'), throwsArgumentError);
160 expect(() => builder.join(null, 'a'), throwsArgumentError); 160 expect(() => builder.join(null, 'a'), throwsArgumentError);
161 }); 161 });
162 }); 162 });
163 163
164 group('joinAll', () {
165 test('allows more than eight parts', () {
166 expect(builder.joinAll(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']),
167 'a/b/c/d/e/f/g/h/i');
168 });
169
170 test('does not add separator if a part ends in one', () {
171 expect(builder.joinAll(['a/', 'b', 'c/', 'd']), 'a/b/c/d');
172 expect(builder.joinAll(['a\\', 'b']), r'a\/b');
173 });
174
175 test('ignores parts before an absolute path', () {
176 expect(builder.joinAll(['a', '/', 'b', 'c']), '/b/c');
177 expect(builder.joinAll(['a', '/b', '/c', 'd']), '/c/d');
178 expect(builder.joinAll(['a', r'c:\b', 'c', 'd']), r'a/c:\b/c/d');
179 expect(builder.joinAll(['a', r'\\b', 'c', 'd']), r'a/\\b/c/d');
180 });
181 });
182
164 group('split', () { 183 group('split', () {
165 test('simple cases', () { 184 test('simple cases', () {
166 expect(builder.split(''), []); 185 expect(builder.split(''), []);
167 expect(builder.split('.'), ['.']); 186 expect(builder.split('.'), ['.']);
168 expect(builder.split('..'), ['..']); 187 expect(builder.split('..'), ['..']);
169 expect(builder.split('foo'), equals(['foo'])); 188 expect(builder.split('foo'), equals(['foo']));
170 expect(builder.split('foo/bar.txt'), equals(['foo', 'bar.txt'])); 189 expect(builder.split('foo/bar.txt'), equals(['foo', 'bar.txt']));
171 expect(builder.split('foo/bar/baz'), equals(['foo', 'bar', 'baz'])); 190 expect(builder.split('foo/bar/baz'), equals(['foo', 'bar', 'baz']));
172 expect(builder.split('foo/../bar/./baz'), 191 expect(builder.split('foo/../bar/./baz'),
173 equals(['foo', '..', 'bar', '.', 'baz'])); 192 equals(['foo', '..', 'bar', '.', 'baz']));
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 expect(builder.withoutExtension('a/.'), 'a/.'); 383 expect(builder.withoutExtension('a/.'), 'a/.');
365 expect(builder.withoutExtension('a/.b'), 'a/.b'); 384 expect(builder.withoutExtension('a/.b'), 'a/.b');
366 expect(builder.withoutExtension('a.b/c'), 'a.b/c'); 385 expect(builder.withoutExtension('a.b/c'), 'a.b/c');
367 expect(builder.withoutExtension(r'a.b\c'), r'a'); 386 expect(builder.withoutExtension(r'a.b\c'), r'a');
368 expect(builder.withoutExtension(r'a/b\c'), r'a/b\c'); 387 expect(builder.withoutExtension(r'a/b\c'), r'a/b\c');
369 expect(builder.withoutExtension(r'a/b\c.d'), r'a/b\c'); 388 expect(builder.withoutExtension(r'a/b\c.d'), r'a/b\c');
370 expect(builder.withoutExtension('a/b.c/'), 'a/b/'); 389 expect(builder.withoutExtension('a/b.c/'), 'a/b/');
371 expect(builder.withoutExtension('a/b.c//'), 'a/b//'); 390 expect(builder.withoutExtension('a/b.c//'), 'a/b//');
372 }); 391 });
373 } 392 }
OLDNEW
« no previous file with comments | « pkg/path/lib/path.dart ('k') | pkg/path/test/path_windows_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698