Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
theron-wang committed Aug 13, 2024
1 parent 646c415 commit 75e9ec3
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/test/java/org/checkerframework/specimin/UnusedImportsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.checkerframework.specimin;

import java.io.IOException;
import org.junit.Test;

/** This test checks if Specimin can properly remove unused imports. */
public class UnusedImportsTest {
@Test
public void runTest() throws IOException {
SpeciminTestExecutor.runTestWithoutJarPaths(
"unusedimports",
new String[] {"com/example/Simple.java"},
new String[] {"com.example.Simple#shouldNotBeRemoved()"});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.example;

public class ManyImports {
}
17 changes: 17 additions & 0 deletions src/test/resources/unusedimports/expected/com/example/Simple.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.example;

import java.util.List;
import java.io.*;
import static java.util.Map.*;
import static java.lang.Math.sqrt;
import static java.lang.Math.PI;

public class Simple {

public ManyImports shouldNotBeRemoved() {
List<Entry<Object, Object>> x;
sqrt(PI);
File file;
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.example;

import java.util.List;
import java.io.*;
import static java.util.Map.*;
import static java.lang.Math.sqrt;
import static java.lang.Math.PI;

public class ManyImports {
public void shouldBeRemoved() {
List<Entry<Object, Object>> x;
sqrt(PI);
File file;
}
}
16 changes: 16 additions & 0 deletions src/test/resources/unusedimports/input/com/example/Simple.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.example;

import java.util.List;
import java.io.*;
import static java.util.Map.*;
import static java.lang.Math.sqrt;
import static java.lang.Math.PI;

public class Simple {
public ManyImports shouldNotBeRemoved() {
List<Entry<Object, Object>> x;
sqrt(PI);
File file;
return null;
}
}

0 comments on commit 75e9ec3

Please sign in to comment.