Skip to content

review: test: add regression test for toString() with complex comments#6727

Open
MartinWitt wants to merge 3 commits into
masterfrom
fix/tostringbugtest
Open

review: test: add regression test for toString() with complex comments#6727
MartinWitt wants to merge 3 commits into
masterfrom
fix/tostringbugtest

Conversation

@MartinWitt
Copy link
Copy Markdown
Collaborator

@MartinWitt MartinWitt commented May 16, 2026

Cleanup and package move

Copilot AI review requested due to automatic review settings May 16, 2026 12:41
@MartinWitt
Copy link
Copy Markdown
Collaborator Author

Had some claude tokens left and the test package seems really off before

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 test ToStringCommentTest that loads two Java fixtures and calls toString() on all parsed types.
  • Added two new Java fixture sources under src/test/resources/spoon/test/prettyprinter/toStringCommentTest.
  • Removed the previous spoon.toStringBugTest.ToStringBugTest regression 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 if toString() throws. Prefer an assertion that explicitly verifies toString() 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.

Comment thread src/test/java/spoon/test/prettyprinter/ToStringCommentTest.java Outdated
@MartinWitt MartinWitt changed the title test: add regression test for toString() with complex comments review: test: add regression test for toString() with complex comments May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants