review: test: add regression test for toString() with complex comments#6727
Open
MartinWitt wants to merge 3 commits into
Open
review: test: add regression test for toString() with complex comments#6727MartinWitt wants to merge 3 commits into
MartinWitt wants to merge 3 commits into
Conversation
Collaborator
Author
|
Had some claude tokens left and the test package seems really off before |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds/relocates a regression test intended to ensure CtType#toString() does not crash when pretty-printing sources containing complex comment patterns.
Changes:
- Added a new JUnit/
@ModelTest-based regression testToStringCommentTestthat loads two Java fixtures and callstoString()on all parsed types. - Added two new Java fixture sources under
src/test/resources/spoon/test/prettyprinter/toStringCommentTest. - Removed the previous
spoon.toStringBugTest.ToStringBugTestregression test.
Reviewed changes
Copilot reviewed 2 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/test/resources/spoon/test/prettyprinter/toStringCommentTest/TestClass2.java | Adds a large Java fixture intended to reproduce complex comment handling during toString() pretty-printing. |
| src/test/resources/spoon/test/prettyprinter/toStringCommentTest/TestClass.java | Adds a second Java fixture used by the regression test. |
| src/test/java/spoon/toStringBugTest/ToStringBugTest.java | Removes the previous regression test for issue #3382. |
| src/test/java/spoon/test/prettyprinter/ToStringCommentTest.java | Introduces the new regression test using @ModelTest to build a model from the fixtures and invoke toString(). |
Comments suppressed due to low confidence (1)
src/test/java/spoon/test/prettyprinter/ToStringCommentTest.java:38
- The current assertion only checks that
type.toString()is non-null (which is unlikely to add value) and the custom fail message won’t be used iftoString()throws. Prefer an assertion that explicitly verifiestoString()does not throw (and optionally that the result is non-empty) so the regression intent is enforced and failures identify the offending type.
var types = launcher.getFactory().Class().getAll();
assertThat(types).withFailMessage("Should load test resources").isNotEmpty();
for (CtType<?> type : types) {
assertThat(type.toString()).withFailMessage("toString() should not return null for type: " + type.getQualifiedName()).isNotNull();
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cleanup and package move