Skip to content

Commit 522fab5

Browse files
committed
Keep an input in the old shape in the switch expression golden
The upstream commit rewrote the input of test1 into the new shape, so both inputs of the golden that declare a variable with a switch expression already started from the target form, and the golden checked re-indentation and stability only. Nothing started from "=", a line break and the switch, which is what the change moves. test1's input goes back to that shape, as it was before; its expected output does not change. A field initialized with a switch expression, written in the same old shape, is added as well, since no golden covered a field.
1 parent 610278d commit 522fab5

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

‎open-java-format/src/test/resources/com/palantir/javaformat/java/testdata/ExpressionSwitch.input‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ class ExpressionSwitch {
2323
return val;
2424
}
2525

26+
static final int FIELD =
27+
switch (KIND) {
28+
case 0 -> 1;
29+
case 1 -> 2;
30+
default -> throw new IllegalStateException();
31+
};
32+
2633
int wrapping(Wrapping w) {
2734
switch (w) {
2835
case THIS_IS_A_VERY_LONG_ENUM_VALUE_ONE,
@@ -43,11 +50,12 @@ class ExpressionSwitch {
4350
}
4451

4552
public void test1(int y) {
46-
int x = switch (y) {
47-
case 1 -> 1;
48-
case 2 -> throw new IllegalArgumentException();
49-
default -> throw new IllegalStateException();
50-
};
53+
int x =
54+
switch (y) {
55+
case 1 -> 1;
56+
case 2 -> throw new IllegalArgumentException();
57+
default -> throw new IllegalStateException();
58+
};
5159
}
5260

5361
public void test2(int y) {

‎open-java-format/src/test/resources/com/palantir/javaformat/java/testdata/ExpressionSwitch.output‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ class ExpressionSwitch {
2828
return val;
2929
}
3030

31+
static final int FIELD = switch (KIND) {
32+
case 0 -> 1;
33+
case 1 -> 2;
34+
default -> throw new IllegalStateException();
35+
};
36+
3137
int wrapping(Wrapping w) {
3238
switch (w) {
3339
case THIS_IS_A_VERY_LONG_ENUM_VALUE_ONE,

0 commit comments

Comments
 (0)