mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
fix contracts for junit5 assertions
This commit is contained in:
@@ -8,4 +8,20 @@ class Contracts {
|
||||
String s = o.toString();
|
||||
}
|
||||
|
||||
void foo2(@Nullable Object o) {
|
||||
Assertions.assertNotNull(o, "message");
|
||||
String s = o.toString();
|
||||
}
|
||||
|
||||
void foo3(java.util.function.BooleanSupplier o) {
|
||||
Assertions.assertTrue(o, "message");
|
||||
}
|
||||
|
||||
void foo3(boolean b) {
|
||||
Assertions.assertTrue(b, "message");
|
||||
if (<warning descr="Condition '!b' is always 'false'">!<warning descr="Value 'b' is always 'true'">b</warning></warning>) {
|
||||
System.out.println("how?");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,11 +17,18 @@ package com.intellij.java.codeInspection;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInspection.dataFlow.DataFlowInspection;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class HardcodedContractsTest extends DataFlowInspectionTestCase {
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return JAVA_8;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
@@ -110,8 +117,13 @@ public class HardcodedContractsTest extends DataFlowInspectionTestCase {
|
||||
}
|
||||
|
||||
public void testJunit5Assert() {
|
||||
myFixture.addClass("package org.junit.jupiter.api; public class Assertions {\n" +
|
||||
myFixture.addClass("package org.junit.jupiter.api;" +
|
||||
"import java.util.function.BooleanSupplier;" +
|
||||
"public class Assertions {\n" +
|
||||
" public static void assertNotNull(Object actual){}" +
|
||||
" public static void assertNotNull(Object actual, String message){}" +
|
||||
" public static void assertTrue(boolean b, String message){}" +
|
||||
" public static void assertTrue(BooleanSupplier b, String message){}" +
|
||||
"}");
|
||||
checkHighlighting();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user