Skip to content

Commit

Permalink
another test
Browse files Browse the repository at this point in the history
  • Loading branch information
msridhar committed Oct 2, 2023
1 parent cdf83ce commit b8c9fd0
Showing 1 changed file with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,15 @@ public void recordEqualsNull() {
}

@Test
public void recordDeconstructionPattern() {
public void recordDeconstructionPatternInstanceOf() {
defaultCompilationHelper
.addSourceLines(
"Records.java",
"package com.uber;",
"import javax.annotation.Nullable;",
"class Records {",
" record Rec(Object first, @Nullable Object second) { }",
" void recordDeconstruction(Object obj) {",
" void recordDeconstructionInstanceOf(Object obj) {",
" if (obj instanceof Rec(Object f, @Nullable Object s)) {",
" f.toString();",
" // TODO: NullAway should report a warning here!",
Expand All @@ -230,4 +230,23 @@ public void recordDeconstructionPattern() {
"}")
.doTest();
}

@Test
public void recordDeconstructionPatternSwitchCase() {
defaultCompilationHelper
.addSourceLines(
"Records.java",
"package com.uber;",
"import javax.annotation.Nullable;",
"class Records {",
" record Rec(Object first, @Nullable Object second) { }",
" int recordDeconstructionSwitchCase(Object obj) {",
" return switch (obj) {",
" case Rec(Object f, @Nullable Object s) -> s.toString().length();",
" default -> 0;",
" };",
" }",
"}")
.doTest();
}
}

0 comments on commit b8c9fd0

Please sign in to comment.