mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
MaxLoop test
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import java.util.Collection;
|
||||
|
||||
class X {
|
||||
public Foo test(Collection<Foo> collection) {
|
||||
Foo result = null;
|
||||
int resultWeight = -1;
|
||||
for (Foo foo : collection) {
|
||||
int fooWeight = foo.getWeight();
|
||||
if (result == null || resultWeight <= fooWeight) {
|
||||
result = foo;
|
||||
resultWeight = fooWeight;
|
||||
}
|
||||
}
|
||||
if (result == null) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
interface Foo {
|
||||
int getWeight();
|
||||
}
|
||||
@@ -646,4 +646,5 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase {
|
||||
|
||||
public void testIncompleteArrayAccessInLoop() { doTest(); }
|
||||
public void testSameArguments() { doTest(); }
|
||||
public void testMaxLoop() { doTest(); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user