Skip to content

Commit e66ee55

Browse files
committed
Move the tests of unused import removal into case files
RemoveUnusedImportsTest was a table inherited from google-java-format: each row an array of input lines and one of output lines, joined with \n and run through RemoveUnusedImports alone. 19 of its 23 rows are now cases under test-cases/imports, one file each, named after what it checks, and so is the one test of RemoveUnusedImportsCaseLabelsTest. A case runs the whole formatter, so its after block is the row's expected output, formatted: for every row the formatted input and the formatted expectation are the same text, and a second run changes nothing. One row's input was formatted already, so its case lays the same code out another way and has something to format. Four rows stay in RemoveUnusedImportsTest, as plain tests with text blocks. The three of #37 cannot be cases: a case fixes the imports before it formats, and formatting takes a doubled blank line away by itself, while the command line formats first. The module import parses from JDK 23 on, and the cases run on JDK 21 as well. With the RemoveUnusedImports of 21.X.X, the same four cases fail as the rows did: the ones with a used import from java.lang. Tests on JDK 21: FormatterCasesTest 887 -> 907, RemoveUnusedImportsTest 23 -> 4 (the module import skipped), RemoveUnusedImportsCaseLabelsTest 1 -> gone; 1413 tests in the module, as before. On JDK 25 the four tests of RemoveUnusedImportsTest all run, and the 907 cases pass.
1 parent bff74a0 commit e66ee55

22 files changed

Lines changed: 406 additions & 462 deletions