Skip to content

Commit

Permalink
Fix Unit Tests
Browse files Browse the repository at this point in the history
Minor changes and better documentation
  • Loading branch information
armughan11 committed Oct 19, 2023
1 parent 4bdd570 commit 06e816e
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void ArrayTypeAnnotationDereference() {
"class Test {",
" static @Nullable Integer [] fizz = {1};",
" static void foo() {",
" // Ok since @Nullable annotations on type are ignored currently.",
" // OK: @Nullable annotations on type are ignored currently.",
" // however, this should report an error eventually.",
" int bar = fizz.length;",
" }",
Expand Down Expand Up @@ -53,14 +53,16 @@ public void ArrayElementAnnotationDereference() {
"class Test {",
" static String @Nullable [] fizz = {\"1\"};",
" static void foo() {",
" // This currently reports an error since fizz is @Nullable,",
" // but it should eventually report due to fizz[0] being @Nullable",
" // BUG: Diagnostic contains: dereferenced expression fizz is @Nullable",
" int bar = fizz[0].length();",
" }",
"}")
.doTest();
}

@Ignore("We do not support annotations on array currently")
@Ignore("We do not support annotations on array elements currently")
@Test
public void ArrayElementAnnotationAssignment() {
makeHelper()
Expand All @@ -70,11 +72,12 @@ public void ArrayElementAnnotationAssignment() {
"import org.jspecify.annotations.Nullable;",
"class Test {",
" Object fizz = new Object();",
" void m( @Nullable Integer [] foo) {",
" // BUG: Diagnostic contains: dereferenced expression arr[0] is @Nullable",
" int bar = foo[0];",
" //valid assignment",
" fizz = foo;",
" Object bar = new Object();",
" void m( Integer @Nullable [] foo) {",
" // BUG: assigning @Nullable expression to @NonNull field",
" fizz = foo[0];",
" // OK: valid assignment since only elements can be null",
" bar = foo;",
" }",
"}")
.doTest();
Expand Down

0 comments on commit 06e816e

Please sign in to comment.