-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Moves method verification after extensions have had the chance to consume properties. #299
Changes from 3 commits
bfcdcde
8860489
55683c3
b0df868
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
import static com.google.common.truth.Truth.assertAbout; | ||
import static com.google.testing.compile.JavaSourceSubjectFactory.javaSource; | ||
import static com.google.testing.compile.JavaSourcesSubjectFactory.javaSources; | ||
|
||
import com.google.auto.value.extension.AutoValueExtension; | ||
import com.google.common.collect.ImmutableList; | ||
|
@@ -120,12 +121,49 @@ public void testExtensionConsumesProperties() throws Exception { | |
); | ||
assertAbout(javaSource()) | ||
.that(javaFileObject) | ||
.processedWith( | ||
new AutoValueProcessor(ImmutableList.<AutoValueExtension>of(new FooExtension()))) | ||
.processedWith(new AutoValueProcessor(ImmutableList.of(new FooExtension()))) | ||
.compilesWithoutError() | ||
.and().generatesSources(expectedExtensionOutput); | ||
} | ||
|
||
public void testDoesntRaiseWarningOnConsumedProperties() { | ||
JavaFileObject impl = JavaFileObjects.forSourceLines("foo.bar.Baz", | ||
"package foo.bar;", | ||
"import com.google.auto.value.AutoValue;", | ||
"@AutoValue public abstract class Baz {", | ||
" abstract String foo();", | ||
" abstract String dizzle();", | ||
"}"); | ||
assertAbout(javaSource()) | ||
.that(impl) | ||
.processedWith(new AutoValueProcessor(ImmutableList.of(new FooExtension()))) | ||
.compilesWithoutError() | ||
// expected warnings: @AutoValue and @Generated annotations not consumed | ||
.withWarningCount(2); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've had success passing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would expect that would pass since you're suppressing all processor warnings. The point of this test is to ensure that those two expected warnings, and no others, are thrown. In the error case, a warning is thrown for every property, but There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Er, no, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ahh, yes, good point. My misunderstanding. |
||
} | ||
|
||
public void testExtensionWithoutConsumedPropertiesFails() throws Exception { | ||
JavaFileObject javaFileObject = JavaFileObjects.forSourceLines( | ||
"foo.bar.Baz", | ||
"package foo.bar;", | ||
"", | ||
"import com.google.auto.value.AutoValue;", | ||
"", | ||
"@AutoValue", | ||
"public abstract class Baz {", | ||
" abstract String foo();", | ||
" abstract String dizzle();", | ||
" abstract Double[] bad();", | ||
"}"); | ||
assertAbout(javaSource()) | ||
.that(javaFileObject) | ||
.processedWith( | ||
new AutoValueProcessor(ImmutableList.<AutoValueExtension>of(new FooExtension()))) | ||
.failsToCompile() | ||
.withErrorContaining("An @AutoValue class cannot define an array-valued property unless " | ||
+ "it is a primitive array"); | ||
} | ||
|
||
public void testExtensionWithBuilderCompilation() throws Exception { | ||
|
||
JavaFileObject javaFileObject = JavaFileObjects.forSourceLines( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not seeing the purpose of these
{@link}
rewrites. The previous versions work for me. Is there a context where they don't?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm not sure why those got in there. Works fine for me, too. I've reverted them.