Skip to content

Commit 3325148

Browse files
committed
More test cases
1 parent 411156e commit 3325148

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

src/test/java/org/openrewrite/staticanalysis/UnnecessaryReturnAsLastStatementTest.java

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,69 @@ int world(int i) {
120120
"""));
121121
}
122122

123+
@Test
124+
void notChangingLambdas() {
125+
//language=java
126+
rewriteRun(
127+
java(
128+
"""
129+
class Hello {
130+
java.util.function.Consumer<Integer> c = i -> {
131+
return;
132+
};
133+
}
134+
"""));
135+
}
136+
137+
@Test
138+
void notChangingLoops() {
139+
//language=java
140+
rewriteRun(
141+
java(
142+
"""
143+
class Main {
144+
public static void main(String[] argv) {
145+
while (true) {
146+
return;
147+
}
148+
}
149+
}
150+
"""));
151+
}
152+
153+
@Test
154+
void newClass() {
155+
//language=java
156+
rewriteRun(
157+
java(
158+
"""
159+
import java.util.concurrent.Callable;
160+
class Hello {
161+
Callable<String> callable = new Callable<>() {
162+
@Override
163+
public String call() throws Exception {
164+
otherMethod();
165+
return "success";
166+
}
167+
private void otherMethod() {
168+
return;
169+
}
170+
};
171+
}
172+
""",
173+
"""
174+
import java.util.concurrent.Callable;
175+
class Hello {
176+
Callable<String> callable = new Callable<>() {
177+
@Override
178+
public String call() throws Exception {
179+
otherMethod();
180+
return "success";
181+
}
182+
private void otherMethod() {
183+
}
184+
};
185+
}
186+
"""));
187+
}
123188
}

0 commit comments

Comments
 (0)