Skip to content

Commit

Permalink
dart format
Browse files Browse the repository at this point in the history
  • Loading branch information
hellohuanlin committed Nov 11, 2022
1 parent 7960aa2 commit 17e7246
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 37 deletions.
3 changes: 2 additions & 1 deletion lib/path.dart
Expand Up @@ -131,7 +131,8 @@ String absolute(String part1,
String? part13,
String? part14,
String? part15]) =>
context.absolute(part1, part2, part3, part4, part5, part6, part7, part8, part9, part10, part11, part12, part13, part14, part15);
context.absolute(part1, part2, part3, part4, part5, part6, part7, part8,
part9, part10, part11, part12, part13, part14, part15);

/// Gets the part of [path] after the last separator.
///
Expand Down
19 changes: 17 additions & 2 deletions lib/src/context.dart
Expand Up @@ -89,8 +89,23 @@ class Context {
String? part13,
String? part14,
String? part15]) {
_validateArgList(
'absolute', [part1, part2, part3, part4, part5, part6, part7, part8, part9, part10, part11, part12, part13, part14, part15]);
_validateArgList('absolute', [
part1,
part2,
part3,
part4,
part5,
part6,
part7,
part8,
part9,
part10,
part11,
part12,
part13,
part14,
part15
]);

// If there's a single absolute path, just return it. This is a lot faster
// for the common case of `p.absolute(path)`.
Expand Down
64 changes: 52 additions & 12 deletions test/posix_test.dart
Expand Up @@ -156,17 +156,28 @@ void main() {
'a/b/c/d/e/f/g/h/i');
expect(context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'),
'a/b/c/d/e/f/g/h/i/j');
expect(context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'),
expect(
context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'),
'a/b/c/d/e/f/g/h/i/j/k');
expect(context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'),
expect(
context.join(
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'),
'a/b/c/d/e/f/g/h/i/j/k/l');
expect(context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'),
expect(
context.join(
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'),
'a/b/c/d/e/f/g/h/i/j/k/l/m');
expect(context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'),
expect(
context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
'l', 'm', 'n'),
'a/b/c/d/e/f/g/h/i/j/k/l/m/n');
expect(context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'),
expect(
context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
'l', 'm', 'n', 'o'),
'a/b/c/d/e/f/g/h/i/j/k/l/m/n/o');
expect(context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'),
expect(
context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
'l', 'm', 'n', 'o', 'p'),
'a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p');
});

Expand Down Expand Up @@ -210,7 +221,26 @@ void main() {

group('joinAll', () {
test('allows more than sixteen parts', () {
expect(context.joinAll(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q']),
expect(
context.joinAll([
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
'p',
'q'
]),
'a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q');
});

Expand Down Expand Up @@ -525,15 +555,25 @@ void main() {
'/root/path/a/b/c/d/e/f/g/h/i');
expect(context.absolute('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'),
'/root/path/a/b/c/d/e/f/g/h/i/j');
expect(context.absolute('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'),
expect(
context.absolute(
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'),
'/root/path/a/b/c/d/e/f/g/h/i/j/k');
expect(context.absolute('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'),
expect(
context.absolute(
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'),
'/root/path/a/b/c/d/e/f/g/h/i/j/k/l');
expect(context.absolute('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'),
expect(
context.absolute(
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'),
'/root/path/a/b/c/d/e/f/g/h/i/j/k/l/m');
expect(context.absolute('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'),
expect(
context.absolute('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
'k', 'l', 'm', 'n'),
'/root/path/a/b/c/d/e/f/g/h/i/j/k/l/m/n');
expect(context.absolute('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'),
expect(
context.absolute('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
'k', 'l', 'm', 'n', 'o'),
'/root/path/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o');
});

Expand Down
60 changes: 49 additions & 11 deletions test/url_test.dart
Expand Up @@ -209,17 +209,28 @@ void main() {
'a/b/c/d/e/f/g/h/i');
expect(context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'),
'a/b/c/d/e/f/g/h/i/j');
expect(context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'),
expect(
context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'),
'a/b/c/d/e/f/g/h/i/j/k');
expect(context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'),
expect(
context.join(
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'),
'a/b/c/d/e/f/g/h/i/j/k/l');
expect(context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'),
expect(
context.join(
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'),
'a/b/c/d/e/f/g/h/i/j/k/l/m');
expect(context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'),
expect(
context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
'l', 'm', 'n'),
'a/b/c/d/e/f/g/h/i/j/k/l/m/n');
expect(context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'),
expect(
context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
'l', 'm', 'n', 'o'),
'a/b/c/d/e/f/g/h/i/j/k/l/m/n/o');
expect(context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'),
expect(
context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
'l', 'm', 'n', 'o', 'p'),
'a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p');
});

Expand Down Expand Up @@ -302,7 +313,26 @@ void main() {

group('joinAll', () {
test('allows more than sixteen parts', () {
expect(context.joinAll(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q']),
expect(
context.joinAll([
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
'p',
'q'
]),
'a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q');
});

Expand Down Expand Up @@ -800,13 +830,21 @@ void main() {
'https://dart.dev/root/path/a/b/c/d/e/f/g/h/j');
expect(context.absolute('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k'),
'https://dart.dev/root/path/a/b/c/d/e/f/g/h/j/k');
expect(context.absolute('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'l'),
expect(
context.absolute(
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'l'),
'https://dart.dev/root/path/a/b/c/d/e/f/g/h/j/k/l');
expect(context.absolute('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'l', 'm'),
expect(
context.absolute(
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'l', 'm'),
'https://dart.dev/root/path/a/b/c/d/e/f/g/h/j/k/l/m');
expect(context.absolute('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n'),
expect(
context.absolute(
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n'),
'https://dart.dev/root/path/a/b/c/d/e/f/g/h/j/k/l/m/n');
expect(context.absolute('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'o'),
expect(
context.absolute('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k',
'l', 'm', 'n', 'o'),
'https://dart.dev/root/path/a/b/c/d/e/f/g/h/j/k/l/m/n/o');
});

Expand Down
60 changes: 49 additions & 11 deletions test/windows_test.dart
Expand Up @@ -219,17 +219,28 @@ void main() {
r'a\b\c\d\e\f\g\h\i');
expect(context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'),
r'a\b\c\d\e\f\g\h\i\j');
expect(context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'),
expect(
context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'),
r'a\b\c\d\e\f\g\h\i\j\k');
expect(context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'),
expect(
context.join(
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'),
r'a\b\c\d\e\f\g\h\i\j\k\l');
expect(context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'),
expect(
context.join(
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'),
r'a\b\c\d\e\f\g\h\i\j\k\l\m');
expect(context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'),
expect(
context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
'l', 'm', 'n'),
r'a\b\c\d\e\f\g\h\i\j\k\l\m\n');
expect(context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'),
expect(
context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
'l', 'm', 'n', 'o'),
r'a\b\c\d\e\f\g\h\i\j\k\l\m\n\o');
expect(context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'),
expect(
context.join('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
'l', 'm', 'n', 'o', 'p'),
r'a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p');
});

Expand Down Expand Up @@ -275,7 +286,26 @@ void main() {

group('joinAll', () {
test('allows more than sixteen parts', () {
expect(context.joinAll(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q']),
expect(
context.joinAll([
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
'p',
'q'
]),
r'a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q');
});

Expand Down Expand Up @@ -679,13 +709,21 @@ void main() {
r'C:\root\path\a\b\c\d\e\f\g\h\j');
expect(context.absolute('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k'),
r'C:\root\path\a\b\c\d\e\f\g\h\j\k');
expect(context.absolute('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'l'),
expect(
context.absolute(
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'l'),
r'C:\root\path\a\b\c\d\e\f\g\h\j\k\l');
expect(context.absolute('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'l', 'm'),
expect(
context.absolute(
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'l', 'm'),
r'C:\root\path\a\b\c\d\e\f\g\h\j\k\l\m');
expect(context.absolute('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n'),
expect(
context.absolute(
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n'),
r'C:\root\path\a\b\c\d\e\f\g\h\j\k\l\m\n');
expect(context.absolute('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'o'),
expect(
context.absolute('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k',
'l', 'm', 'n', 'o'),
r'C:\root\path\a\b\c\d\e\f\g\h\j\k\l\m\n\o');
});

Expand Down

0 comments on commit 17e7246

Please sign in to comment.