mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 06:39:38 +07:00
light DataFlowInspectionFixtureTest
This commit is contained in:
@@ -1,160 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.NullableNotNullManager;
|
||||
import com.intellij.codeInspection.dataFlow.DataFlowInspection;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.testFramework.builders.JavaModuleFixtureBuilder;
|
||||
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class DataFlowInspectionFixtureTest extends JavaCodeInsightFixtureTestCase {
|
||||
@Override
|
||||
protected void tuneFixture(JavaModuleFixtureBuilder moduleBuilder) {
|
||||
moduleBuilder.setLanguageLevel(LanguageLevel.HIGHEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return JavaTestUtil.getJavaTestDataPath() + "/inspection/dataFlow/fixture/";
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
final DataFlowInspection inspection = new DataFlowInspection();
|
||||
inspection.SUGGEST_NULLABLE_ANNOTATIONS = true;
|
||||
myFixture.enableInspections(inspection);
|
||||
myFixture.testHighlighting(true, false, true, getTestName(false) + ".java");
|
||||
}
|
||||
|
||||
public void testTryInAnonymous() throws Throwable { doTest(); }
|
||||
public void testNullableAnonymousMethod() throws Throwable { doTest(); }
|
||||
public void testNullableAnonymousParameter() throws Throwable { doTest(); }
|
||||
public void testNullableAnonymousVolatile() throws Throwable { doTest(); }
|
||||
public void testNullableAnonymousVolatileNotNull() throws Throwable { doTest(); }
|
||||
public void testLocalClass() throws Throwable { doTest(); }
|
||||
|
||||
public void testFieldInAnonymous() throws Throwable { doTest(); }
|
||||
public void testFieldInitializerInAnonymous() throws Throwable { doTest(); }
|
||||
public void testNullableField() throws Throwable { doTest(); }
|
||||
public void testCanBeNullDoesntImplyIsNull() throws Throwable { doTest(); }
|
||||
public void testAnnReport() throws Throwable { doTest(); }
|
||||
|
||||
public void testBigMethodNotComplex() throws Throwable { doTest(); }
|
||||
public void testBuildRegexpNotComplex() throws Throwable { doTest(); }
|
||||
public void testTernaryInWhileNotComplex() throws Throwable { doTest(); }
|
||||
public void testTryCatchInForNotComplex() throws Throwable { doTest(); }
|
||||
public void testFieldChangedBetweenSynchronizedBlocks() throws Throwable { doTest(); }
|
||||
|
||||
public void testGeneratedEquals() throws Throwable { doTest(); }
|
||||
|
||||
public void testIDEA84489() throws Throwable { doTest(); }
|
||||
public void testComparingToNotNullShouldNotAffectNullity() throws Throwable { doTest(); }
|
||||
public void testStringTernaryAlwaysTrue() throws Throwable { doTest(); }
|
||||
|
||||
public void testBoxing128() throws Throwable { doTest(); }
|
||||
public void testFinalFieldsInitializedByAnnotatedParameters() throws Throwable { doTest(); }
|
||||
public void testMultiCatch() throws Throwable { doTest(); }
|
||||
public void testContinueFlushesLoopVariable() throws Throwable { doTest(); }
|
||||
|
||||
public void testEqualsNotNull() throws Throwable { doTest(); }
|
||||
public void testVisitFinallyOnce() throws Throwable { doTest(); }
|
||||
public void testNotEqualsDoesntImplyNotNullity() throws Throwable { doTest(); }
|
||||
public void testEqualsEnumConstant() throws Throwable { doTest(); }
|
||||
public void testEqualsConstant() throws Throwable { doTest(); }
|
||||
public void testFinalLoopVariableInstanceof() throws Throwable { doTest(); }
|
||||
public void testGreaterIsNotEquals() throws Throwable { doTest(); }
|
||||
public void testNotGreaterIsNotEquals() throws Throwable { doTest(); }
|
||||
|
||||
public void testChainedFinalFieldsDfa() throws Throwable { doTest(); }
|
||||
public void testFinalFieldsDifferentInstances() throws Throwable { doTest(); }
|
||||
public void testThisFieldGetters() throws Throwable { doTest(); }
|
||||
public void testChainedFinalFieldAccessorsDfa() throws Throwable { doTest(); }
|
||||
|
||||
public void testAssigningUnknownToNullable() throws Throwable { doTest(); }
|
||||
public void testAssigningClassLiteralToNullable() throws Throwable { doTest(); }
|
||||
|
||||
public void testSynchronizingOnNullable() throws Throwable { doTest(); }
|
||||
public void testReturningNullFromVoidMethod() throws Throwable { doTest(); }
|
||||
|
||||
public void testCatchRuntimeException() throws Throwable { doTest(); }
|
||||
|
||||
public void testAssertFailInCatch() throws Throwable {
|
||||
myFixture.addClass("package org.junit; public class Assert { public static void fail() {}}");
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPreserveNullableOnUncheckedCast() throws Throwable { doTest(); }
|
||||
|
||||
public void testPassingNullableIntoVararg() throws Throwable { doTest(); }
|
||||
public void testEqualsImpliesNotNull() throws Throwable { doTest(); }
|
||||
|
||||
public void testAnnotatedTypeParameters() throws Throwable {
|
||||
setupCustomAnnotations();
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void setupCustomAnnotations() {
|
||||
myFixture.addClass("package foo; public @interface Nullable {}");
|
||||
myFixture.addClass("package foo; public @interface NotNull {}");
|
||||
final NullableNotNullManager nnnManager = NullableNotNullManager.getInstance(getProject());
|
||||
nnnManager.setNotNulls("foo.NotNull");
|
||||
nnnManager.setNullables("foo.Nullable");
|
||||
Disposer.register(myTestRootDisposable, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
nnnManager.setNotNulls();
|
||||
nnnManager.setNullables();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testSkipAssertions() {
|
||||
final DataFlowInspection inspection = new DataFlowInspection();
|
||||
inspection.DONT_REPORT_TRUE_ASSERT_STATEMENTS = true;
|
||||
myFixture.enableInspections(inspection);
|
||||
myFixture.testHighlighting(true, false, true, getTestName(false) + ".java");
|
||||
}
|
||||
|
||||
public void testCheckFieldInitializers() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testConstantDoubleComparisons() { doTest(); }
|
||||
|
||||
public void _testMutableNullableFieldsTreatment() { doTest(); }
|
||||
public void _testMutableVolatileNullableFieldsTreatment() { doTest(); }
|
||||
public void testMutableNotAnnotatedFieldsTreatment() { doTest(); }
|
||||
|
||||
public void testMethodCallFlushesField() { doTest(); }
|
||||
public void testUnknownFloatMayBeNaN() { doTest(); }
|
||||
public void testLastConstantConditionInAnd() { doTest(); }
|
||||
|
||||
public void testTransientFinalField() { doTest(); }
|
||||
public void _testSymmetricUncheckedCast() { doTest(); }
|
||||
public void testNullCheckDoesntAffectUncheckedCast() { doTest(); }
|
||||
|
||||
public void testNullableForeachVariable() {
|
||||
setupCustomAnnotations();
|
||||
doTest();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,22 +15,143 @@
|
||||
*/
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.NullableNotNullManager;
|
||||
import com.intellij.codeInspection.dataFlow.DataFlowInspection;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
|
||||
public class DataFlowInspectionTest extends LightDaemonAnalyzerTestCase {
|
||||
@NonNls static final String BASE_PATH = "/inspection/dataFlow";
|
||||
|
||||
private void doTest() {
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", true, false);
|
||||
}
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
|
||||
|
||||
@Override
|
||||
protected LocalInspectionTool[] configureLocalInspectionTools() {
|
||||
return new LocalInspectionTool[]{new DataFlowInspection()};
|
||||
protected String getTestDataPath() {
|
||||
return JavaTestUtil.getJavaTestDataPath() + "/inspection/dataFlow/fixture/";
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
final DataFlowInspection inspection = new DataFlowInspection();
|
||||
inspection.SUGGEST_NULLABLE_ANNOTATIONS = true;
|
||||
myFixture.enableInspections(inspection);
|
||||
myFixture.testHighlighting(true, false, true, getTestName(false) + ".java");
|
||||
}
|
||||
|
||||
public void testTryInAnonymous() throws Throwable { doTest(); }
|
||||
public void testNullableAnonymousMethod() throws Throwable { doTest(); }
|
||||
public void testNullableAnonymousParameter() throws Throwable { doTest(); }
|
||||
public void testNullableAnonymousVolatile() throws Throwable { doTest(); }
|
||||
public void testNullableAnonymousVolatileNotNull() throws Throwable { doTest(); }
|
||||
public void testLocalClass() throws Throwable { doTest(); }
|
||||
|
||||
public void testFieldInAnonymous() throws Throwable { doTest(); }
|
||||
public void testFieldInitializerInAnonymous() throws Throwable { doTest(); }
|
||||
public void testNullableField() throws Throwable { doTest(); }
|
||||
public void testCanBeNullDoesntImplyIsNull() throws Throwable { doTest(); }
|
||||
public void testAnnReport() throws Throwable { doTest(); }
|
||||
|
||||
public void testBigMethodNotComplex() throws Throwable { doTest(); }
|
||||
public void testBuildRegexpNotComplex() throws Throwable { doTest(); }
|
||||
public void testTernaryInWhileNotComplex() throws Throwable { doTest(); }
|
||||
public void testTryCatchInForNotComplex() throws Throwable { doTest(); }
|
||||
public void testFieldChangedBetweenSynchronizedBlocks() throws Throwable { doTest(); }
|
||||
|
||||
public void testGeneratedEquals() throws Throwable { doTest(); }
|
||||
|
||||
public void testIDEA84489() throws Throwable { doTest(); }
|
||||
public void testComparingToNotNullShouldNotAffectNullity() throws Throwable { doTest(); }
|
||||
public void testStringTernaryAlwaysTrue() throws Throwable { doTest(); }
|
||||
|
||||
public void testBoxing128() throws Throwable { doTest(); }
|
||||
public void testFinalFieldsInitializedByAnnotatedParameters() throws Throwable { doTest(); }
|
||||
public void testMultiCatch() throws Throwable { doTest(); }
|
||||
public void testContinueFlushesLoopVariable() throws Throwable { doTest(); }
|
||||
|
||||
public void testEqualsNotNull() throws Throwable { doTest(); }
|
||||
public void testVisitFinallyOnce() throws Throwable { doTest(); }
|
||||
public void testNotEqualsDoesntImplyNotNullity() throws Throwable { doTest(); }
|
||||
public void testEqualsEnumConstant() throws Throwable { doTest(); }
|
||||
public void testEqualsConstant() throws Throwable { doTest(); }
|
||||
public void testFinalLoopVariableInstanceof() throws Throwable { doTest(); }
|
||||
public void testGreaterIsNotEquals() throws Throwable { doTest(); }
|
||||
public void testNotGreaterIsNotEquals() throws Throwable { doTest(); }
|
||||
|
||||
public void testChainedFinalFieldsDfa() throws Throwable { doTest(); }
|
||||
public void testFinalFieldsDifferentInstances() throws Throwable { doTest(); }
|
||||
public void testThisFieldGetters() throws Throwable { doTest(); }
|
||||
public void testChainedFinalFieldAccessorsDfa() throws Throwable { doTest(); }
|
||||
|
||||
public void testAssigningUnknownToNullable() throws Throwable { doTest(); }
|
||||
public void testAssigningClassLiteralToNullable() throws Throwable { doTest(); }
|
||||
|
||||
public void testSynchronizingOnNullable() throws Throwable { doTest(); }
|
||||
public void testReturningNullFromVoidMethod() throws Throwable { doTest(); }
|
||||
|
||||
public void testCatchRuntimeException() throws Throwable { doTest(); }
|
||||
|
||||
public void testAssertFailInCatch() throws Throwable {
|
||||
myFixture.addClass("package org.junit; public class Assert { public static void fail() {}}");
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPreserveNullableOnUncheckedCast() throws Throwable { doTest(); }
|
||||
|
||||
public void testPassingNullableIntoVararg() throws Throwable { doTest(); }
|
||||
public void testEqualsImpliesNotNull() throws Throwable { doTest(); }
|
||||
|
||||
public void testAnnotatedTypeParameters() throws Throwable {
|
||||
setupCustomAnnotations();
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void setupCustomAnnotations() {
|
||||
myFixture.addClass("package foo; public @interface Nullable {}");
|
||||
myFixture.addClass("package foo; public @interface NotNull {}");
|
||||
final NullableNotNullManager nnnManager = NullableNotNullManager.getInstance(getProject());
|
||||
nnnManager.setNotNulls("foo.NotNull");
|
||||
nnnManager.setNullables("foo.Nullable");
|
||||
Disposer.register(myTestRootDisposable, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
nnnManager.setNotNulls();
|
||||
nnnManager.setNullables();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testSkipAssertions() {
|
||||
final DataFlowInspection inspection = new DataFlowInspection();
|
||||
inspection.DONT_REPORT_TRUE_ASSERT_STATEMENTS = true;
|
||||
myFixture.enableInspections(inspection);
|
||||
myFixture.testHighlighting(true, false, true, getTestName(false) + ".java");
|
||||
}
|
||||
|
||||
public void testCheckFieldInitializers() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testConstantDoubleComparisons() { doTest(); }
|
||||
|
||||
public void _testMutableNullableFieldsTreatment() { doTest(); }
|
||||
public void _testMutableVolatileNullableFieldsTreatment() { doTest(); }
|
||||
public void testMutableNotAnnotatedFieldsTreatment() { doTest(); }
|
||||
|
||||
public void testMethodCallFlushesField() { doTest(); }
|
||||
public void testUnknownFloatMayBeNaN() { doTest(); }
|
||||
public void testLastConstantConditionInAnd() { doTest(); }
|
||||
|
||||
public void testTransientFinalField() { doTest(); }
|
||||
public void _testSymmetricUncheckedCast() { doTest(); }
|
||||
public void testNullCheckDoesntAffectUncheckedCast() { doTest(); }
|
||||
|
||||
public void testNullableForeachVariable() {
|
||||
setupCustomAnnotations();
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testTryWithResourcesNullability() { doTest(); }
|
||||
public void testTryWithResourcesInstanceOf() { doTest(); }
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ public class DataFlowInspectionTestSuite {
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite();
|
||||
suite.addTestSuite(DataFlowInspectionTest.class);
|
||||
suite.addTestSuite(DataFlowInspectionFixtureTest.class);
|
||||
suite.addTestSuite(DataFlowInspectionAncientTest.class);
|
||||
suite.addTestSuite(SliceTreeTest.class);
|
||||
return suite;
|
||||
|
||||
Reference in New Issue
Block a user