diff --git a/src/test/java/org/checkerframework/specimin/UnusedImportsTest.java b/src/test/java/org/checkerframework/specimin/UnusedImportsTest.java new file mode 100644 index 000000000..43ea549cb --- /dev/null +++ b/src/test/java/org/checkerframework/specimin/UnusedImportsTest.java @@ -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()"}); + } +} diff --git a/src/test/resources/unusedimports/expected/com/example/ManyImports.java b/src/test/resources/unusedimports/expected/com/example/ManyImports.java new file mode 100644 index 000000000..9aa3a03aa --- /dev/null +++ b/src/test/resources/unusedimports/expected/com/example/ManyImports.java @@ -0,0 +1,4 @@ +package com.example; + +public class ManyImports { +} diff --git a/src/test/resources/unusedimports/expected/com/example/Simple.java b/src/test/resources/unusedimports/expected/com/example/Simple.java new file mode 100644 index 000000000..c0b859517 --- /dev/null +++ b/src/test/resources/unusedimports/expected/com/example/Simple.java @@ -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> x; + sqrt(PI); + File file; + return null; + } +} diff --git a/src/test/resources/unusedimports/input/com/example/ManyImports.java b/src/test/resources/unusedimports/input/com/example/ManyImports.java new file mode 100644 index 000000000..b28d59d75 --- /dev/null +++ b/src/test/resources/unusedimports/input/com/example/ManyImports.java @@ -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> x; + sqrt(PI); + File file; + } +} diff --git a/src/test/resources/unusedimports/input/com/example/Simple.java b/src/test/resources/unusedimports/input/com/example/Simple.java new file mode 100644 index 000000000..7c47315f1 --- /dev/null +++ b/src/test/resources/unusedimports/input/com/example/Simple.java @@ -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> x; + sqrt(PI); + File file; + return null; + } +}