blob: a3524cdfe1300015256a4a6d77f81bcb9b7c5962 [file] [log] [blame]
40 columns |
### Test which kinds of expressions are candidates to be block-formatted.
>>> Non-empty block-bodied function expression.
function(() { body; });
<<<
function(() {
body;
});
>>> Empty block-bodied function expression with a block comment.
function(() { /* fairly long comment */ });
<<<
function(() {
/* fairly long comment */
});
>>> Empty block-bodied function expression with a line comment.
function(() { // comment
});
<<<
function(() {
// comment
});
>>> Block-bodied function expression with parameters.
function((parameter) { body; });
<<<
function((parameter) {
body;
});
>>> Empty block-bodied function expression with parameters is not a block argument.
function((parameter, anotherParameter) {});
<<<
function(
(parameter, anotherParameter) {},
);
>>> Expression-bodied function expression with parameters is not a block argument.
function((parameter, anotherParameter) => body);
<<<
function(
(parameter, anotherParameter) => body,
);
>>> Expression-bodied function expression with many parameters is not a block argument.
function((parameter, anotherParameter, thirdParameter) => body);
<<<
function(
(
parameter,
anotherParameter,
thirdParameter,
) => body,
);
>>> An empty block-bodied function expression is not a block argument.
function_________________________(() {});
<<<
function_________________________(
() {},
);
>>> A zero-parameter expression-bodied function is not a block argument.
function_______________________(() => null);
<<<
function_______________________(
() => null,
);
>>> Function call.
function(innerFunction(veryLongArgumentExpression));
<<<
function(innerFunction(
veryLongArgumentExpression,
));
>>> Zero-argument function call with block comment.
function(innerFunction(/* long comment */));
<<<
function(innerFunction(
/* long comment */
));
>>> Zero-argument function call with line comment.
function(innerFunction(// comment
));
<<<
function(innerFunction(
// comment
));
>>> A zero-argument function call is not a block argument.
function_______________________(inner());
<<<
function_______________________(
inner(),
);
>>> Method call.
function(target.inner(veryLongArgumentExpression));
<<<
function(target.inner(
veryLongArgumentExpression,
));
>>> Zero-argument method call with block comment.
function(target.inner(/* long comment */));
<<<
function(target.inner(
/* long comment */
));
>>> Zero-argument method call with line comment.
function(target.inner(// comment
));
<<<
function(target.inner(
// comment
));
>>> A zero-argument method call is not a block argument.
function________________(target.inner());
<<<
function________________(
target.inner(),
);
>>> Instance creation expression.
function(new SomeClass(veryLongArgumentExpression));
<<<
function(new SomeClass(
veryLongArgumentExpression,
));
>>> Zero-argument instance creation expression with block comment.
function(new SomeClass(/* long comment */));
<<<
function(new SomeClass(
/* long comment */
));
>>> Zero-argument instance creation expression with line comment.
function(new SomeClass(// comment
));
<<<
function(new SomeClass(
// comment
));
>>> A zero-argument instance creation expression is not a block argument.
function________________(new SomeClass());
<<<
function________________(
new SomeClass(),
);
>>> Immediately invoked function.
function(() { body; }());
<<<
function(() {
body;
}());
>>> Empty immediately invoked function with a block comment.
function(() { /* fairly long comment */ }());
<<<
function(() {
/* fairly long comment */
}());
>>> Empty immediately invoked function with a line comment.
function(() { // comment
}());
<<<
function(() {
// comment
}());
>>> Immediately invoked function with parameters and arguments.
function((p, r) { body; }(a, b));
<<<
function((p, r) {
body;
}(a, b));
>>> Immediately invoked empty function with parameters is not a block argument.
function((parameter, anotherParameter) {}());
<<<
function(
(parameter, anotherParameter) {}(),
);
>>> An empty immediately invoked function is not a block argument.
function_________________________(() {}());
<<<
function_________________________(
() {}(),
);
>>> Function expression call.
function((expression)(veryLongArgumentExpression));
<<<
function((expression)(
veryLongArgumentExpression,
));
>>> Zero-argument function expression call with block comment.
function((expression)(/* long comment */));
<<<
function((expression)(
/* long comment */
));
>>> Zero-argument function expression call with line comment.
function((expression)(// comment
));
<<<
function((expression)(
// comment
));
>>> A zero-argument function expression call is not a block argument.
function_______________________((expr)());
<<<
function_______________________(
(expr)(),
);
>>> Parenthesized expression where inner expression is a block argument.
function((innerFunction(veryLongArgumentExpression)));
<<<
function((innerFunction(
veryLongArgumentExpression,
)));
>>> List literal.
function([veryLongElement, anotherLongElement]);
<<<
function([
veryLongElement,
anotherLongElement,
]);
>>> Empty list literal with block comment.
function([/* a very long block comment */]);
<<<
function([
/* a very long block comment */
]);
>>> Empty list literal with line comment.
function([// comment
]);
<<<
function([
// comment
]);
>>> An empty list is not a block argument.
function_____________________________([]);
<<<
function_____________________________(
[],
);
>>> Map literal.
function({1: veryLongElement, 2: anotherLongElement});
<<<
function({
1: veryLongElement,
2: anotherLongElement,
});
>>> Set literal.
function({veryLongElement, anotherLongElement});
<<<
function({
veryLongElement,
anotherLongElement,
});
>>> Empty set/map literal with block comment.
function({/* a very long block comment */});
<<<
function({
/* a very long block comment */
});
>>> Empty set/map literal with line comment.
function({// comment
});
<<<
function({
// comment
});
>>> An empty map/set is not a block argument.
function_____________________________({});
<<<
function_____________________________(
{},
);
>>> Record literal.
function((veryLongElement, anotherLongElement));
<<<
function((
veryLongElement,
anotherLongElement,
));
>>> Empty record literal with block comment.
function((/* a very long block comment */));
<<<
function((
/* a very long block comment */
));
>>> Empty record literal with line comment.
function((// comment
));
<<<
function((
// comment
));
>>> An empty record is not a block argument.
function_____________________________(());
<<<
function_____________________________(
(),
);
>>> Switch expression.
function(switch (n) {1 => veryLongElement, 2 => anotherLongElement});
<<<
function(switch (n) {
1 => veryLongElement,
2 => anotherLongElement,
});
>>> Empty switch expression with block comment.
function(switch (n) {/* long comment */});
<<<
function(switch (n) {
/* long comment */
});
>>> Empty switch expression with line comment.
function(switch (n) {// comment
});
<<<
function(switch (n) {
// comment
});
>>> An empty switch expression is not a block argument.
function___________________(switch (n) {});
<<<
function___________________(
switch (n) {},
);