File tree Expand file tree Collapse file tree
src/test/java/org/openrewrite/staticanalysis Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -103,6 +103,46 @@ List<String> testLambda(List<String> names) {
103103 );
104104 }
105105
106+ @ Test
107+ void inlineSwitch () {
108+ rewriteRun (
109+ //language=java
110+ java (
111+ """
112+ import java.util.List;
113+ import java.util.stream.Collectors;
114+
115+ class Test {
116+ String test(int n) {
117+ String s = switch (n) {
118+ case 1 -> "one";
119+ case 2 -> "two";
120+ case 3 -> "three";
121+ default -> "unknown";
122+ };
123+ return s;
124+ }
125+ }
126+ """ ,
127+ """
128+ import java.util.List;
129+ import java.util.stream.Collectors;
130+
131+ class Test {
132+ String test(int n) {
133+ return switch (n) {
134+ case 1 -> "one";
135+ case 2 -> "two";
136+ case 3 -> "three";
137+ default -> "unknown";
138+ };
139+ }
140+ }
141+ """
142+ )
143+ );
144+ }
145+
106146 @ SuppressWarnings ("UnnecessaryLocalVariable" )
107147 @ Test
108148 void preserveComments () {
You can’t perform that action at this time.
0 commit comments