blob: ca1ed11511f67c321455344f31a5c9ecedd9aec0 [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.
function((parameter, anotherParameter) {});
<<<
function((
parameter,
anotherParameter,
) {});
>>> Expression-bodied function expression with parameters.
function((parameter, anotherParameter) => body);
<<<
function((
parameter,
anotherParameter,
) => body);
>>> Block-bodied function expression with block comment in the parameters.
function((/* very long block comment */) {});
<<<
function((
/* very long block comment */
) {});
>>> Block-bodied function expression with line comment in the parameters.
function((// comment
) {});
<<<
function((
// comment
) {});
>>> Expression-bodied function expression with block comment in the parameters.
function((/* very long block comment */) => body);
<<<
function((
/* very long block comment */
) => body);
>>> Expression-bodied function expression with line comment in the parameters.
function((// comment
) => body);
<<<
function((
// comment
) => 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
});
>>> 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(),
);
>>> 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) {},
);