mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
infer contracts from comparisons with non-null value
This commit is contained in:
+11
-2
@@ -415,11 +415,20 @@ class ContractInferenceFromSourceTest extends LightCodeInsightFixtureTestCase {
|
||||
|
||||
public void "test compare with string literal"() {
|
||||
def c = inferContracts("""
|
||||
String cast(String s) {
|
||||
String s(String s) {
|
||||
return s == "a" ? "b" : null;
|
||||
}
|
||||
""")
|
||||
assert c == []
|
||||
assert c == ['null -> null']
|
||||
}
|
||||
|
||||
public void "test negative compare with string literal"() {
|
||||
def c = inferContracts("""
|
||||
String s(String s) {
|
||||
return s != "a" ? "b" : null;
|
||||
}
|
||||
""")
|
||||
assert c == ['null -> !null']
|
||||
}
|
||||
|
||||
public void "test return after if without else"() {
|
||||
|
||||
Reference in New Issue
Block a user