Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 test('disallows intermediate nulls', () { | |
|
Bob Nystrom
2013/02/21 22:03:27
I think it should disallow trailing nulls too.
nweiz
2013/02/21 22:19:25
I actually meant to remove this test. I don't thin
| |
| 183 expect(() => builder.joinAll(['a', null, 'b']), throwsArgumentError); | |
| 184 expect(() => builder.joinAll([null, 'a']), throwsArgumentError); | |
| 185 }); | |
| 186 }); | |
| 187 | |
| 164 group('split', () { | 188 group('split', () { |
| 165 test('simple cases', () { | 189 test('simple cases', () { |
| 166 expect(builder.split(''), []); | 190 expect(builder.split(''), []); |
| 167 expect(builder.split('.'), ['.']); | 191 expect(builder.split('.'), ['.']); |
| 168 expect(builder.split('..'), ['..']); | 192 expect(builder.split('..'), ['..']); |
| 169 expect(builder.split('foo'), equals(['foo'])); | 193 expect(builder.split('foo'), equals(['foo'])); |
| 170 expect(builder.split('foo/bar.txt'), equals(['foo', 'bar.txt'])); | 194 expect(builder.split('foo/bar.txt'), equals(['foo', 'bar.txt'])); |
| 171 expect(builder.split('foo/bar/baz'), equals(['foo', 'bar', 'baz'])); | 195 expect(builder.split('foo/bar/baz'), equals(['foo', 'bar', 'baz'])); |
| 172 expect(builder.split('foo/../bar/./baz'), | 196 expect(builder.split('foo/../bar/./baz'), |
| 173 equals(['foo', '..', 'bar', '.', 'baz'])); | 197 equals(['foo', '..', 'bar', '.', 'baz'])); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 expect(builder.withoutExtension('a/.'), 'a/.'); | 388 expect(builder.withoutExtension('a/.'), 'a/.'); |
| 365 expect(builder.withoutExtension('a/.b'), 'a/.b'); | 389 expect(builder.withoutExtension('a/.b'), 'a/.b'); |
| 366 expect(builder.withoutExtension('a.b/c'), 'a.b/c'); | 390 expect(builder.withoutExtension('a.b/c'), 'a.b/c'); |
| 367 expect(builder.withoutExtension(r'a.b\c'), r'a'); | 391 expect(builder.withoutExtension(r'a.b\c'), r'a'); |
| 368 expect(builder.withoutExtension(r'a/b\c'), r'a/b\c'); | 392 expect(builder.withoutExtension(r'a/b\c'), r'a/b\c'); |
| 369 expect(builder.withoutExtension(r'a/b\c.d'), r'a/b\c'); | 393 expect(builder.withoutExtension(r'a/b\c.d'), r'a/b\c'); |
| 370 expect(builder.withoutExtension('a/b.c/'), 'a/b/'); | 394 expect(builder.withoutExtension('a/b.c/'), 'a/b/'); |
| 371 expect(builder.withoutExtension('a/b.c//'), 'a/b//'); | 395 expect(builder.withoutExtension('a/b.c//'), 'a/b//'); |
| 372 }); | 396 }); |
| 373 } | 397 } |
| OLD | NEW |