blob: a144b83ad7c7f9d1f0654b77d9631434926d7438 [file] [log] [blame]
40 columns |
>>> Empty.
e = switch(y) {};
<<<
e = switch (y) {};
>>> Always split cases even if they would fit.
e = switch (c) { 0 => a, 1 => b };
<<<
e = switch (c) {
0 => a,
1 => b,
};
>>> One case per line.
e = switch (c) { 0 => first, 1 => second };
<<<
e = switch (c) {
0 => first,
1 => second,
};
>>> Split some cases at "=>" but not all.
e = switch (c) {
first => a,
second => veryLongExpression + thatSplits,
third => c
};
<<<
e = switch (c) {
first => a,
second =>
veryLongExpression + thatSplits,
third => c,
};
>>> Remove blank lines before first and last case. Preserve one between.
e = switch (obj) {
0 => a,
1 => b,
2 => c
};
<<<
e = switch (obj) {
0 => a,
1 => b,
2 => c,
};
>>> Don't split at parentheses.
e = switch ("a long string that must wrap") {
0 => "ok"
};
<<<
e = switch ("a long string that must wrap") {
0 => "ok",
};
>>> Split in delimited value expression.
e = switch ([veryLongElement,veryLongElement,veryLongElement,]) {
0 => "ok"
};
<<<
e = switch ([
veryLongElement,
veryLongElement,
veryLongElement,
]) {
0 => "ok",
};
>>> Split in case expression.
e = switch (obj) {
1 => veryLongExpression + thatStillMustSplit
};
<<<
e = switch (obj) {
1 =>
veryLongExpression +
thatStillMustSplit,
};
>>> Prefer to split after "=>" instead of body.
e = switch (obj) {
longConstant => longExpression + thatMustSplit
};
<<<
e = switch (obj) {
longConstant =>
longExpression + thatMustSplit,
};
>>> Split after "=>" and in body.
e = switch (obj) {
longConstant => veryLongLongExpression + thatMustSplit
};
<<<
e = switch (obj) {
longConstant =>
veryLongLongExpression +
thatMustSplit,
};
>>> Expression split in pattern.
e = switch (obj) {
veryVeryLongPattern && reallyMustSplit => body
};
<<<
e = switch (obj) {
veryVeryLongPattern &&
reallyMustSplit =>
body,
};
>>> Outermost logic-or patterns are indented like parallel cases.
e = switch (obj) {
oneConstant || twoConstant || threeConstant => body
};
<<<
e = switch (obj) {
oneConstant ||
twoConstant ||
threeConstant =>
body,
};
>>> Nested logic-or operands are indented.
e = switch (obj) {
[oneConstant || twoConstant || threeConstant] => body
};
<<<
e = switch (obj) {
[
oneConstant ||
twoConstant ||
threeConstant,
] =>
body,
};
>>> Block split in pattern.
e = switch (obj) {
[veryLongElement,veryLongElement,veryLongElement,] => body
};
<<<
e = switch (obj) {
[
veryLongElement,
veryLongElement,
veryLongElement,
] =>
body,
};
>>> Unsplit pattern with trailing block split body.
e = switch (obj) {
pattern => function(veryLongElement,veryLongElement,veryLongElement)
};
<<<
e = switch (obj) {
pattern => function(
veryLongElement,
veryLongElement,
veryLongElement,
),
};
>>> Split pattern with block split body.
e = switch (obj) {
pattern && anotherPattern && aThirdOne => function(veryLongElement,veryLongElement,veryLongElement)
};
<<<
e = switch (obj) {
pattern &&
anotherPattern &&
aThirdOne =>
function(
veryLongElement,
veryLongElement,
veryLongElement,
),
};