| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 expect(builder.join('a', null), equals('a')); | 173 expect(builder.join('a', null), equals('a')); |
| 174 expect(builder.join('a', 'b', 'c', null, null), equals(r'a\b\c')); | 174 expect(builder.join('a', 'b', 'c', null, null), equals(r'a\b\c')); |
| 175 }); | 175 }); |
| 176 | 176 |
| 177 test('disallows intermediate nulls', () { | 177 test('disallows intermediate nulls', () { |
| 178 expect(() => builder.join('a', null, 'b'), throwsArgumentError); | 178 expect(() => builder.join('a', null, 'b'), throwsArgumentError); |
| 179 expect(() => builder.join(null, 'a'), throwsArgumentError); | 179 expect(() => builder.join(null, 'a'), throwsArgumentError); |
| 180 }); | 180 }); |
| 181 }); | 181 }); |
| 182 | 182 |
| 183 group('joinAll', () { |
| 184 test('allows more than eight parts', () { |
| 185 expect(builder.joinAll(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']), |
| 186 r'a\b\c\d\e\f\g\h\i'); |
| 187 }); |
| 188 |
| 189 test('does not add separator if a part ends or begins in one', () { |
| 190 expect(builder.joinAll([r'a\', 'b', r'c\', 'd']), r'a\b\c\d'); |
| 191 expect(builder.joinAll(['a/', 'b']), r'a/b'); |
| 192 expect(builder.joinAll(['a', '/b']), 'a/b'); |
| 193 expect(builder.joinAll(['a', r'\b']), r'a\b'); |
| 194 }); |
| 195 |
| 196 test('ignores parts before an absolute path', () { |
| 197 expect(builder.joinAll(['a', '/b', '/c', 'd']), r'a/b/c\d'); |
| 198 expect(builder.joinAll(['a', r'c:\b', 'c', 'd']), r'c:\b\c\d'); |
| 199 expect(builder.joinAll(['a', r'\\b', r'\\c', 'd']), r'\\c\d'); |
| 200 }); |
| 201 |
| 202 test('disallows intermediate nulls', () { |
| 203 expect(() => builder.joinAll(['a', null, 'b']), throwsArgumentError); |
| 204 expect(() => builder.joinAll([null, 'a']), throwsArgumentError); |
| 205 }); |
| 206 }); |
| 207 |
| 183 group('split', () { | 208 group('split', () { |
| 184 test('simple cases', () { | 209 test('simple cases', () { |
| 185 expect(builder.split(''), []); | 210 expect(builder.split(''), []); |
| 186 expect(builder.split('.'), ['.']); | 211 expect(builder.split('.'), ['.']); |
| 187 expect(builder.split('..'), ['..']); | 212 expect(builder.split('..'), ['..']); |
| 188 expect(builder.split('foo'), equals(['foo'])); | 213 expect(builder.split('foo'), equals(['foo'])); |
| 189 expect(builder.split(r'foo\bar.txt'), equals(['foo', 'bar.txt'])); | 214 expect(builder.split(r'foo\bar.txt'), equals(['foo', 'bar.txt'])); |
| 190 expect(builder.split(r'foo\bar/baz'), equals(['foo', 'bar', 'baz'])); | 215 expect(builder.split(r'foo\bar/baz'), equals(['foo', 'bar', 'baz'])); |
| 191 expect(builder.split(r'foo\..\bar\.\baz'), | 216 expect(builder.split(r'foo\..\bar\.\baz'), |
| 192 equals(['foo', '..', 'bar', '.', 'baz'])); | 217 equals(['foo', '..', 'bar', '.', 'baz'])); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 expect(builder.withoutExtension(r'a\.'), r'a\.'); | 430 expect(builder.withoutExtension(r'a\.'), r'a\.'); |
| 406 expect(builder.withoutExtension(r'a\.b'), r'a\.b'); | 431 expect(builder.withoutExtension(r'a\.b'), r'a\.b'); |
| 407 expect(builder.withoutExtension(r'a.b\c'), r'a.b\c'); | 432 expect(builder.withoutExtension(r'a.b\c'), r'a.b\c'); |
| 408 expect(builder.withoutExtension(r'a/b.c/d'), r'a/b.c/d'); | 433 expect(builder.withoutExtension(r'a/b.c/d'), r'a/b.c/d'); |
| 409 expect(builder.withoutExtension(r'a\b/c'), r'a\b/c'); | 434 expect(builder.withoutExtension(r'a\b/c'), r'a\b/c'); |
| 410 expect(builder.withoutExtension(r'a\b/c.d'), r'a\b/c'); | 435 expect(builder.withoutExtension(r'a\b/c.d'), r'a\b/c'); |
| 411 expect(builder.withoutExtension(r'a.b/c'), r'a.b/c'); | 436 expect(builder.withoutExtension(r'a.b/c'), r'a.b/c'); |
| 412 expect(builder.withoutExtension(r'a\b.c\'), r'a\b\'); | 437 expect(builder.withoutExtension(r'a\b.c\'), r'a\b\'); |
| 413 }); | 438 }); |
| 414 } | 439 } |
| OLD | NEW |