summaryrefslogtreecommitdiff
path: root/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java')
-rw-r--r--java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java38
1 files changed, 36 insertions, 2 deletions
diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
index 4cba2ab918a7..33eb32eb0ec6 100644
--- a/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInspection/DataFlowInspectionTest.java
@@ -18,6 +18,7 @@ package com.intellij.codeInspection;
import com.intellij.JavaTestUtil;
import com.intellij.codeInspection.dataFlow.DataFlowInspection;
import com.intellij.testFramework.LightProjectDescriptor;
+import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture;
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
import org.jetbrains.annotations.NotNull;
@@ -251,15 +252,17 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
public void testRootThrowableCause() { doTest(); }
public void testUseInferredContracts() { doTest(); }
+ public void testContractWithNoArgs() { doTest(); }
public void testContractInferenceBewareOverriding() { doTest(); }
public void testNumberComparisonsWhenValueIsKnown() { doTest(); }
+ public void testFloatComparisons() { doTest(); }
public void testAccessingSameArrayElements() { doTest(); }
public void testParametersAreNonnullByDefault() {
- myFixture.addClass("package javax.annotation; public @interface ParametersAreNonnullByDefault {}");
- myFixture.addClass("package javax.annotation; public @interface ParametersAreNullableByDefault {}");
+ addJavaxNullabilityAnnotations(myFixture);
+ addJavaxDefaultNullabilityAnnotations(myFixture);
myFixture.addClass("package foo; public class AnotherPackageNotNull { public static void foo(String s) {}}");
myFixture.addFileToProject("foo/package-info.java", "@javax.annotation.ParametersAreNonnullByDefault package foo;");
@@ -267,6 +270,37 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
doTest();
}
+ public static void addJavaxDefaultNullabilityAnnotations(final JavaCodeInsightTestFixture fixture) {
+ fixture.addClass("package javax.annotation;" +
+ "@javax.annotation.meta.TypeQualifierDefault(java.lang.annotation.ElementType.PARAMETER) @javax.annotation.Nonnull " +
+ "public @interface ParametersAreNonnullByDefault {}");
+ fixture.addClass("package javax.annotation;" +
+ "@javax.annotation.meta.TypeQualifierDefault(java.lang.annotation.ElementType.PARAMETER) @javax.annotation.Nullable " +
+ "public @interface ParametersAreNullableByDefault {}");
+ }
+
+ public static void addJavaxNullabilityAnnotations(final JavaCodeInsightTestFixture fixture) {
+ fixture.addClass("package javax.annotation;" +
+ "public @interface Nonnull {}");
+ fixture.addClass("package javax.annotation;" +
+ "public @interface Nullable {}");
+ fixture.addClass("package javax.annotation.meta;" +
+ "public @interface TypeQualifierDefault { java.lang.annotation.ElementType[] value() default {};}");
+ }
+
+ public void testCustomTypeQualifierDefault() {
+ addJavaxNullabilityAnnotations(myFixture);
+ myFixture.addClass("package bar;" +
+ "@javax.annotation.meta.TypeQualifierDefault(java.lang.annotation.ElementType.METHOD) @javax.annotation.Nonnull " +
+ "public @interface MethodsAreNotNullByDefault {}");
+
+ myFixture.addClass("package foo; public class AnotherPackageNotNull { public static native Object foo(String s); }");
+ myFixture.addFileToProject("foo/package-info.java", "@bar.MethodsAreNotNullByDefault package foo;");
+
+ myFixture.enableInspections(new DataFlowInspection());
+ myFixture.testHighlighting(true, false, true, getTestName(false) + ".java");
+ }
+
public void testTrueOrEqualsSomething() {
doTest();
myFixture.launchAction(myFixture.findSingleIntention("Remove redundant assignment"));