From 75e9ec318a721264172d910aba1cedcb01c80be8 Mon Sep 17 00:00:00 2001 From: Theron Wang Date: Tue, 13 Aug 2024 14:03:54 -0400 Subject: [PATCH] add test case --- .../specimin/UnusedImportsTest.java | 15 +++++++++++++++ .../expected/com/example/ManyImports.java | 4 ++++ .../expected/com/example/Simple.java | 17 +++++++++++++++++ .../input/com/example/ManyImports.java | 15 +++++++++++++++ .../unusedimports/input/com/example/Simple.java | 16 ++++++++++++++++ 5 files changed, 67 insertions(+) create mode 100644 src/test/java/org/checkerframework/specimin/UnusedImportsTest.java create mode 100644 src/test/resources/unusedimports/expected/com/example/ManyImports.java create mode 100644 src/test/resources/unusedimports/expected/com/example/Simple.java create mode 100644 src/test/resources/unusedimports/input/com/example/ManyImports.java create mode 100644 src/test/resources/unusedimports/input/com/example/Simple.java 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 00000000..43ea549c --- /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 00000000..9aa3a03a --- /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 00000000..c0b85951 --- /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 00000000..b28d59d7 --- /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 00000000..7c47315f --- /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; + } +}