Skip to content

Commit

Permalink
Move ignored tests to the bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricioaniche committed Sep 25, 2024
1 parent 1bf794c commit c471082
Showing 1 changed file with 87 additions and 85 deletions.
172 changes: 87 additions & 85 deletions nullaway/src/test/java/com/uber/nullaway/EnsuresNonNullIfTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,35 +91,6 @@ public void ensuresNonNullMethodWithMoreDataComplexFlow() {
.doTest();
}

@Test
@Ignore // fails as both stores in the Return data flow mark the field as nullable
public void ensuresNonNullMethodWithMoreDataComplexFlow_2() {
defaultCompilationHelper
.addSourceLines(
"Foo.java",
"package com.uber;",
"import javax.annotation.Nullable;",
"import com.uber.nullaway.annotations.EnsuresNonNullIf;",
"class Foo {",
" @Nullable Item nullableItem;",
" @EnsuresNonNullIf(\"nullableItem\")",
" public boolean hasNullableItem() {",
" var x = (nullableItem != null);",
" return x;",
" }",
" public int runOk() {",
" if(!hasNullableItem()) {",
" return 1;",
" }",
" nullableItem.call();",
" return 0;",
" }",
"}")
.addSourceLines(
"Item.java", "package com.uber;", "class Item {", " public void call() { }", "}")
.doTest();
}

@Test
public void catchesWrongReturnFlows() {
defaultCompilationHelper
Expand Down Expand Up @@ -341,62 +312,6 @@ public void ensuresNonNullMethodUsingThis() {
.doTest();
}

@Test
@Ignore
public void ensuresNonNullMethodResultStoredInVariable() {
defaultCompilationHelper
.addSourceLines(
"Foo.java",
"package com.uber;",
"import javax.annotation.Nullable;",
"import com.uber.nullaway.annotations.EnsuresNonNullIf;",
"class Foo {",
" @Nullable Item nullableItem;",
" @EnsuresNonNullIf(\"nullableItem\")",
" public boolean hasNullableItem() {",
" return nullableItem != null;",
" }",
" public void runOk() {",
" boolean check = hasNullableItem();",
" if(!check) {",
" return;",
" }",
" nullableItem.call();",
" }",
"}")
.addSourceLines(
"Item.java", "package com.uber;", "class Item {", " public void call() { }", "}")
.doTest();
}

@Test
@Ignore
public void ensuresNonNullMethodResultStoredInVariableInverse() {
defaultCompilationHelper
.addSourceLines(
"Foo.java",
"package com.uber;",
"import javax.annotation.Nullable;",
"import com.uber.nullaway.annotations.EnsuresNonNullIf;",
"class Foo {",
" @Nullable Item nullableItem;",
" @EnsuresNonNullIf(\"nullableItem\")",
" public boolean hasNullableItem() {",
" return nullableItem != null;",
" }",
" public void runOk() {",
" boolean check = !hasNullableItem();",
" if(check) {",
" return;",
" }",
" nullableItem.call();",
" }",
"}")
.addSourceLines(
"Item.java", "package com.uber;", "class Item {", " public void call() { }", "}")
.doTest();
}

@Test
public void ensuresNonNullMethodNotCalled() {
defaultCompilationHelper
Expand Down Expand Up @@ -610,4 +525,91 @@ public void setTrueIfNonNullToFalseMultipleElements_deferenceFound() {
"Item.java", "package com.uber;", "class Item {", " public void call() { }", "}")
.doTest();
}

// These tests are ignored because currently NullAway doesn't support data-flow of local variables

@Test
@Ignore // fails as both stores in the Return data flow mark the field as nullable
public void ensuresNonNullMethodWithMoreDataComplexFlow_2() {
defaultCompilationHelper
.addSourceLines(
"Foo.java",
"package com.uber;",
"import javax.annotation.Nullable;",
"import com.uber.nullaway.annotations.EnsuresNonNullIf;",
"class Foo {",
" @Nullable Item nullableItem;",
" @EnsuresNonNullIf(\"nullableItem\")",
" public boolean hasNullableItem() {",
" var x = (nullableItem != null);",
" return x;",
" }",
" public int runOk() {",
" if(!hasNullableItem()) {",
" return 1;",
" }",
" nullableItem.call();",
" return 0;",
" }",
"}")
.addSourceLines(
"Item.java", "package com.uber;", "class Item {", " public void call() { }", "}")
.doTest();
}

@Test
@Ignore
public void ensuresNonNullMethodResultStoredInVariable() {
defaultCompilationHelper
.addSourceLines(
"Foo.java",
"package com.uber;",
"import javax.annotation.Nullable;",
"import com.uber.nullaway.annotations.EnsuresNonNullIf;",
"class Foo {",
" @Nullable Item nullableItem;",
" @EnsuresNonNullIf(\"nullableItem\")",
" public boolean hasNullableItem() {",
" return nullableItem != null;",
" }",
" public void runOk() {",
" boolean check = hasNullableItem();",
" if(!check) {",
" return;",
" }",
" nullableItem.call();",
" }",
"}")
.addSourceLines(
"Item.java", "package com.uber;", "class Item {", " public void call() { }", "}")
.doTest();
}

@Test
@Ignore
public void ensuresNonNullMethodResultStoredInVariableInverse() {
defaultCompilationHelper
.addSourceLines(
"Foo.java",
"package com.uber;",
"import javax.annotation.Nullable;",
"import com.uber.nullaway.annotations.EnsuresNonNullIf;",
"class Foo {",
" @Nullable Item nullableItem;",
" @EnsuresNonNullIf(\"nullableItem\")",
" public boolean hasNullableItem() {",
" return nullableItem != null;",
" }",
" public void runOk() {",
" boolean check = !hasNullableItem();",
" if(check) {",
" return;",
" }",
" nullableItem.call();",
" }",
"}")
.addSourceLines(
"Item.java", "package com.uber;", "class Item {", " public void call() { }", "}")
.doTest();
}
}

0 comments on commit c471082

Please sign in to comment.