Skip to content

Commit

Permalink
Tests for changes in addImports function
Browse files Browse the repository at this point in the history
Signed-off-by: Subhash Arabhi <subhashsubbu636@gmail.com>
  • Loading branch information
subhash-arabhi committed Aug 27, 2024
1 parent dbe587a commit 2a25bb2
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,18 @@ public void validate(CompilationInfo info) {
}, false);
}

public void testAddImports14() throws Exception {
performTest("test/Process.java", "package test;\nimport java.util.Collections;\npublic class Process {\npublic static void main(String... args) {\n" +
"Collections.singleton(Process.class).forEach(System.out::println);\n}\n}", "1.5", new AddImportsTask("test.Process"), new Validator() {
public void validate(CompilationInfo info) {
assertEquals(0, info.getDiagnostics().size());
List<? extends ImportTree> imports = info.getCompilationUnit().getImports();
assertEquals(1, imports.size());
assertEquals("java.util.Collections", imports.get(0).getQualifiedIdentifier().toString());
}
}, false);
}

public void testAddImportsIncrementallyWithStatic_JIRA3019() throws Exception {
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
performTest("package test;\npublic class Test { public static final String CONST = null; }\n", "11", new AddImportsTask(true, "test.Test.CONST", "java.util.List"), new Validator() {
Expand Down

0 comments on commit 2a25bb2

Please sign in to comment.