blob: 85b641858a6d3a766a8e545db98b8aa0b52c2507 [file] [log] [blame]
40 columns |
### Test how multiple block argument candidates are handled.
>>> Multiple function expressions prevent block formatting.
function(() { one; }, () { two; });
<<<
function(
() {
one;
},
() {
two;
},
);
>>> Empty and non-empty function expressions.
function(() {}, () { body; }, () {});
<<<
function(() {}, () {
body;
}, () {});
>>> Function expression takes precedence over other kinds of block arguments.
### The function is block formatted but the other arguments aren't.
function([1, 2], () { body; }, {3, 4});
<<<
function([1, 2], () {
body;
}, {3, 4});
>>> Immediately invoked function takes precedence over other kinds of block arguments.
function([1, 2], () { body; }(), {3, 4});
<<<
function([1, 2], () {
body;
}(), {3, 4});
>>> Multiple collections prevent block formatting.
function([element, element], {key: value});
<<<
function(
[element, element],
{key: value},
);
>>> Empty and non-empty collections.
function([], [element, element], <String>{});
<<<
function([], [
element,
element,
], <String>{});
>>> Can't block format a function call with any preceding arguments.
function(arg, innerFunction(veryLongArgumentExpression));
<<<
function(
arg,
innerFunction(
veryLongArgumentExpression,
),
);
>>> Can't block format a function call with any subsequent arguments.
function(innerFunction(veryLongArgumentExpression), arg);
<<<
function(
innerFunction(
veryLongArgumentExpression,
),
arg,
);
>>> Can't block format a method call with any preceding arguments.
function(arg, target.inner(veryLongArgumentExpression));
<<<
function(
arg,
target.inner(
veryLongArgumentExpression,
),
);
>>> Can't block format a method call with any subsequent arguments.
function(target.inner(veryLongArgumentExpression), arg);
<<<
function(
target.inner(
veryLongArgumentExpression,
),
arg,
);
>>> Can't block format an instance creation with any preceding arguments.
function(arg, new SomeClass(veryLongArgumentExpression));
<<<
function(
arg,
new SomeClass(
veryLongArgumentExpression,
),
);
>>> Can't block format an instance creation with any subsequent arguments.
function(new SomeClass(veryLongArgumentExpression), arg);
<<<
function(
new SomeClass(
veryLongArgumentExpression,
),
arg,
);
>>> List literal with other non-block arguments.
function(before, [veryLongElement, anotherLongElement], after);
<<<
function(before, [
veryLongElement,
anotherLongElement,
], after);
>>> Map literal with other non-block arguments.
function(before, {1: veryLongElement, 2: anotherLongElement}, after);
<<<
function(before, {
1: veryLongElement,
2: anotherLongElement,
}, after);
>>> Set literal with other non-block arguments.
function(before, {veryLongElement, anotherLongElement}, after);
<<<
function(before, {
veryLongElement,
anotherLongElement,
}, after);
>>> Record literal with other non-block arguments.
function(before, (veryLongElement, anotherLongElement), after);
<<<
function(before, (
veryLongElement,
anotherLongElement,
), after);
>>> Switch expression with other non-block arguments.
function(before, switch (n) {1 => veryLongElement, 2 => anotherLongElement}, after);
<<<
function(before, switch (n) {
1 => veryLongElement,
2 => anotherLongElement,
}, after);
>>> Multiple switches prevent block formatting.
function(switch (a) { 1 => 2 }, switch (b) { 1 => 2 });
<<<
function(
switch (a) {
1 => 2,
},
switch (b) {
1 => 2,
},
);
>>> Empty and non-empty switches.
function(switch (a) {}, switch (b) { 1 => 2 }, switch (c) {});
<<<
function(switch (a) {}, switch (b) {
1 => 2,
}, switch (c) {});
>>> Collection and multi-line string prevents block formatting.
function([element, element], '''multiple
lines''');
<<<
function(
[element, element],
'''multiple
lines''',
);
>>> Adjacent strings preceding a function expression doesn't prevent block formatting.
test('First adjacent string' 'second adjacent string'
'third adjacent string', () async {
;
});
<<<
test('First adjacent string'
'second adjacent string'
'third adjacent string', () async {
;
});
>>> Don't block format a function with a preceding adjacent string if it doesn't fit.
test('First adjacent string' 'second long adjacent string', () async {
;
});
<<<
test(
'First adjacent string'
'second long adjacent string',
() async {
;
},
);
>>> Don't block format adjacent strings preceding a non-function block argument.
test('First adjacent string'
'second adjacent string'
'third adjacent string', [
element1,
element2,
element3,
element4,
]);
<<<
test(
'First adjacent string'
'second adjacent string'
'third adjacent string',
[
element1,
element2,
element3,
element4,
],
);
>>> Other string arguments don't prevent block formatting.
test('First string line 1' 'first string line 2', () {
;
}, 'Another simple string');
<<<
test('First string line 1'
'first string line 2', () {
;
}, 'Another simple string');
>>> Other adjacent string arguments prevent block formatting.
test('First string line 1' 'first string line 2', () {
;
}, 'Another adjacent' 'string argument');
<<<
test(
'First string line 1'
'first string line 2',
() {
;
},
'Another adjacent'
'string argument',
);