Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tkindy committed Jun 14, 2024
1 parent f3cb292 commit d9daedd
Showing 1 changed file with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.google.auto.value.processor.AutoValueProcessor;
import com.google.errorprone.CompilationTestHelper;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand Down Expand Up @@ -309,4 +310,63 @@ public void nonNestedSubclass() {
"class B extends A {}")
.doTest();
}

@Test
public void simpleSubclassMethodReference() {
testHelper
.addSourceLines(
"Foo.java",
"import java.util.function.Supplier;",
"class A {",
" static Supplier<B> supplier = B::new;",
"}",
"class B extends A {}")
.doTest();
}

@Test
public void compoundSubclassMethodReference() {
testHelper
.addSourceLines(
"Foo.java",
"import java.util.Comparator;",
"class A {",
" static Comparator<B> comparator = Comparator.comparing(B::value);",
"}",
"class B extends A {",
" int value;",
" int value() {",
" return value;",
" }",
"}")
.doTest();
}

@Test
public void lambda() {
testHelper
.addSourceLines(
"Foo.java",
"import java.util.function.Supplier;",
"class A {",
" static Supplier<B> supplier = () -> new B();",
"}",
"class B extends A {}")
.doTest();
}

@Test
public void subclassStaticMethod() {
testHelper
.addSourceLines(
"Foo.java",
"class A {",
" // BUG: Diagnostic contains:",
" static int value = B.value(); ",
"}",
"class B extends A {",
" static int value() { return 0; }",
"}")
.doTest();
}
}

0 comments on commit d9daedd

Please sign in to comment.