[java] test cases for IDEA-155836

This commit is contained in:
Roman Shevchenko
2016-06-29 11:00:20 +03:00
parent e12a796d09
commit 399201e00d
3 changed files with 34 additions and 0 deletions
@@ -0,0 +1,15 @@
class TryWithFinally {
static class Resource implements AutoCloseable {
public void close() throws Exception { }
boolean find() { throw new UnsupportedOperationException(); }
}
void test() throws Exception {
boolean found = <warning descr="Variable 'found' initializer 'false' is redundant">false</warning>;
try (Resource r = new Resource()) {
found = r.find();
}
finally { }
System.out.println(found);
}
}
@@ -0,0 +1,14 @@
class TryWithoutFinally {
static class Resource implements AutoCloseable {
public void close() throws Exception { }
boolean find() { throw new UnsupportedOperationException(); }
}
void test() throws Exception {
boolean found = <warning descr="Variable 'found' initializer 'false' is redundant">false</warning>;
try (Resource r = new Resource()) {
found = r.find();
}
System.out.println(found);
}
}
@@ -17,8 +17,11 @@ package com.intellij.codeInspection;
import com.intellij.JavaTestUtil;
import com.intellij.codeInspection.defUse.DefUseInspection;
import com.intellij.idea.Bombed;
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
import java.util.Calendar;
public class DefUseTest extends LightCodeInsightFixtureTestCase {
@Override
protected String getBasePath() {
@@ -35,6 +38,8 @@ public class DefUseTest extends LightCodeInsightFixtureTestCase {
public void testUsedInArrayInitializer() { doTest(); }
public void testHang() { doTest(); }
public void testOperatorAssignment() { doTest(); }
@Bombed(user="roman.shevchenko@jetbrains.com", day=1, month=Calendar.AUGUST, year=2017) public void testTryWithFinally() { doTest(); }
public void testTryWithoutFinally() { doTest(); }
private void doTest() {
myFixture.enableInspections(new DefUseInspection());