-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue #368 , issue #370 , and issue #361 . Tests have been added. One existing test(Issue103) fails, but it was already failing in the main branch.
- Loading branch information
Showing
16 changed files
with
213 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/test/java/org/checkerframework/specimin/BuiltinEnumTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 is able to process Java builtin enum classes. Issue #361 */ | ||
public class BuiltinEnumTest { | ||
@Test | ||
public void runTest() throws IOException { | ||
SpeciminTestExecutor.runTestWithoutJarPaths( | ||
"enumbuiltin", | ||
new String[] {"com/example/Scheduler.java"}, | ||
new String[] {"com.example.Scheduler#schedule(Runnable, int)"}); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/test/java/org/checkerframework/specimin/DefaultPackageTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.checkerframework.specimin; | ||
|
||
import java.io.IOException; | ||
import org.junit.Test; | ||
|
||
/** | ||
* This test checks if Specimin correctly preserves things that are used as arguments to enum | ||
* constants. | ||
*/ | ||
public class DefaultPackageTest { | ||
@Test | ||
public void runTest() throws IOException { | ||
SpeciminTestExecutor.runTestWithoutJarPaths( | ||
"defaultpackage", new String[] {"A.java"}, new String[] {"A#schedule(Runnable, int)"}); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/test/java/org/checkerframework/specimin/Issue368Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.checkerframework.specimin; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.StandardCopyOption; | ||
import org.junit.Test; | ||
|
||
/** | ||
* This test is the test described in <a | ||
* href="https://github.com/njit-jerse/specimin/issues/368">...</a>. The issue caused the original | ||
* source file A.java to be deleted, and in addition not appear in the output. | ||
*/ | ||
public class Issue368Test { | ||
@Test | ||
public void runTest() throws IOException { | ||
Path fileASource = Path.of("src/test/resources/issue368/A_code.java"); | ||
Path fileAPath = Path.of("src/test/resources/issue368/input/com/example/A.java"); | ||
Files.copy(fileASource, fileAPath, StandardCopyOption.REPLACE_EXISTING); | ||
String fileACode = Files.readString(fileAPath); | ||
SpeciminTestExecutor.runTestWithoutJarPaths( | ||
"issue368", new String[] {"com/example/B.java"}, new String[] {"com.example.B#test()"}); | ||
|
||
try { | ||
assertTrue(Files.exists(fileAPath)); | ||
} finally { | ||
Files.writeString(fileAPath, fileACode); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
public class A { | ||
|
||
public static void schedule(Runnable task, int millis) { | ||
System.out.println(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
public class A{//no package declaration | ||
public static void schedule(Runnable task, int millis) { | ||
System.out.println(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/test/resources/enumbuiltin/expected/com/example/Scheduler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.example; | ||
|
||
import java.util.concurrent.ScheduledExecutorService; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
public class Scheduler { | ||
|
||
public static final ScheduledExecutorService ses = null; | ||
|
||
public static void schedule(Runnable task, int millis) { | ||
ses.schedule(task, millis, TimeUnit.MILLISECONDS); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/test/resources/enumbuiltin/input/com/example/Scheduler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.example; | ||
import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor; | ||
|
||
import java.util.concurrent.ScheduledExecutorService; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
public class Scheduler{ | ||
private Scheduler() {} | ||
public static final ScheduledExecutorService ses=newSingleThreadScheduledExecutor(r->new Thread(r,"Scheduler thread")); | ||
|
||
public static void schedule(Runnable task, int millis) { | ||
ses.schedule(task,millis,TimeUnit.MILLISECONDS); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.example; | ||
import java.io.IOException; | ||
import java.net.InetAddress; | ||
import java.net.InetSocketAddress; | ||
import java.nio.channels.AsynchronousSocketChannel; | ||
|
||
public class A{ | ||
public AsynchronousSocketChannel client; | ||
public A(AsynchronousSocketChannel client){ | ||
this.client=client; | ||
} | ||
public InetAddress test(){//target method | ||
try { | ||
if(client.getRemoteAddress() instanceof InetSocketAddress isa) | ||
return isa.getAddress(); | ||
} catch (IOException e) { | ||
|
||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.example; | ||
|
||
import java.net.InetAddress; | ||
|
||
public class A { | ||
|
||
public InetAddress test() { | ||
throw new Error(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.example; | ||
|
||
import java.net.InetAddress; | ||
|
||
public class B extends A { | ||
|
||
public InetAddress test() { | ||
return super.test(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.example; | ||
import java.io.IOException; | ||
import java.net.InetAddress; | ||
import java.net.InetSocketAddress; | ||
import java.nio.channels.AsynchronousSocketChannel; | ||
|
||
public class A{ | ||
public AsynchronousSocketChannel client; | ||
public A(AsynchronousSocketChannel client){ | ||
this.client=client; | ||
} | ||
public InetAddress test(){//target method | ||
try { | ||
if(client.getRemoteAddress() instanceof InetSocketAddress isa) | ||
return isa.getAddress(); | ||
} catch (IOException e) { | ||
|
||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.example; | ||
import java.io.IOException; | ||
import java.net.InetAddress; | ||
|
||
public class B extends A { | ||
|
||
@Override | ||
public InetAddress test(){ | ||
return super.test(); | ||
} | ||
} |