forked from JavaTX/JavaCompilerCore
Moved test resources to src/test and refactored tests
This commit is contained in:
parent
e3edd0410a
commit
63c5cb8390
@ -1 +0,0 @@
|
||||
|
@ -1,5 +1,4 @@
|
||||
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
@ -25,7 +24,6 @@ public class AllgemeinTest {
|
||||
private static String pathToClassFile;
|
||||
private static Object instanceOfClass;
|
||||
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
// String className = "GenTest";
|
||||
@ -52,17 +50,15 @@ public class AllgemeinTest {
|
||||
String className = "VectorNotObject";
|
||||
// String className = "WildcardCaptureConversionTest";
|
||||
// PL 2019-10-24: genutzt fuer unterschiedliche Tests
|
||||
path = System.getProperty("user.dir")+"/resources/AllgemeinTest/" + className + ".jav";
|
||||
//path = System.getProperty("user.dir")+"/src/test/resources/AllgemeinTest/Overloading_Generics.jav";
|
||||
//path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/mathStrucInteger.jav";
|
||||
//compiler = new JavaTXCompiler(Lists.newArrayList(new File(System.getProperty("user.dir")+"/src/test/resources/AllgemeinTest/Overloading_Generics.jav")));
|
||||
path = System.getProperty("user.dir") + "/src/test/resources/AllgemeinTest/" + className + ".jav";
|
||||
// path = System.getProperty("user.dir")+"/src/test/src/test/resources/AllgemeinTest/Overloading_Generics.jav";
|
||||
// path = System.getProperty("user.dir")+"/src/test/src/test/resources/bytecode/javFiles/mathStrucInteger.jav";
|
||||
// compiler = new JavaTXCompiler(Lists.newArrayList(new File(System.getProperty("user.dir")+"/src/test/src/test/resources/AllgemeinTest/Overloading_Generics.jav")));
|
||||
/// *
|
||||
compiler = new JavaTXCompiler(
|
||||
Lists.newArrayList(new File(path)),
|
||||
Lists.newArrayList(new File(System.getProperty("user.dir")+"/resources/testBytecode/generatedBC/")));
|
||||
compiler = new JavaTXCompiler(Lists.newArrayList(new File(path)), Lists.newArrayList(new File(System.getProperty("user.dir") + "/src/test/resources/testBytecode/generatedBC/")));
|
||||
// */
|
||||
compiler.generateBytecode(System.getProperty("user.dir")+"/resources/testBytecode/generatedBC/");
|
||||
pathToClassFile = System.getProperty("user.dir")+"/resources/testBytecode/generatedBC/";
|
||||
compiler.generateBytecode(System.getProperty("user.dir") + "/src/test/resources/testBytecode/generatedBC/");
|
||||
pathToClassFile = System.getProperty("user.dir") + "/src/test/resources/testBytecode/generatedBC/";
|
||||
loader = new URLClassLoader(new URL[] { new URL("file://" + pathToClassFile) });
|
||||
classToTest = loader.loadClass(className);
|
||||
// classToTest = loader.loadClass("Overloading_Generics");
|
||||
|
@ -12,7 +12,8 @@ import java.net.URLClassLoader;
|
||||
|
||||
public class Bytecode extends TestCase {
|
||||
|
||||
public static final String rootDirectory = System.getProperty("user.dir")+"/resources/javFiles/packageTest/";
|
||||
public static final String rootDirectory = System.getProperty("user.dir") + "/src/test/resources/javFiles/packageTest/";
|
||||
|
||||
@Test
|
||||
public void testSetPackageNameInBytecode() throws Exception {
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory + "de/test/TestClass.jav"));
|
||||
@ -25,7 +26,6 @@ public class Bytecode extends TestCase {
|
||||
f = new File(rootDirectory + "de/test/TestClass.class");
|
||||
assertTrue(f.exists());
|
||||
|
||||
|
||||
URLClassLoader loader = new URLClassLoader(new URL[] { new URL("file://" + rootDirectory) });
|
||||
Class<?> classToTest = loader.loadClass("de.test.TestClass");
|
||||
Object instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
@ -48,5 +48,4 @@ public class Bytecode extends TestCase {
|
||||
Object instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import java.util.Arrays;
|
||||
|
||||
public class CheckPackageFolder extends TestCase {
|
||||
|
||||
public static final String rootDirectory = System.getProperty("user.dir")+"/resources/javFiles/packageTest/de/test/";
|
||||
public static final String rootDirectory = System.getProperty("user.dir") + "/src/test/resources/javFiles/packageTest/de/test/";
|
||||
|
||||
@Test
|
||||
public void testCorrectFolder1FileWithWrongPackageName() throws IOException, ClassNotFoundException {
|
||||
@ -55,26 +55,8 @@ public class CheckPackageFolder extends TestCase {
|
||||
|
||||
/*
|
||||
* Dieser Test wird übersprungen, da der Bytecode-Generator nicht mit zwei Eingabedateien gleichzeitig umgehen kann
|
||||
@Test
|
||||
public void testCorrectFolder2Files() throws IOException, ClassNotFoundException {
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(Arrays.asList(
|
||||
new File(rootDirectory+"subpackage1/Test1.jav"),
|
||||
new File(rootDirectory+"subpackage2/Test2.jav")
|
||||
));
|
||||
compiler.typeInference();
|
||||
File f = new File(rootDirectory + "subpackage1/Test1.class");
|
||||
if(f.exists() && !f.isDirectory()) {
|
||||
f.delete();
|
||||
}
|
||||
File f2 = new File(rootDirectory + "subpackage2/Test2.class");
|
||||
if(f.exists() && !f.isDirectory()) {
|
||||
f.delete();
|
||||
}
|
||||
compiler.generateBytecode();
|
||||
f = new File(rootDirectory + "subpackage1/Test1.class");
|
||||
f2 = new File(rootDirectory + "subpackage2/Test2.class");
|
||||
assertTrue(f.exists());
|
||||
assertTrue(f2.exists());
|
||||
}
|
||||
*
|
||||
* @Test public void testCorrectFolder2Files() throws IOException, ClassNotFoundException { JavaTXCompiler compiler = new JavaTXCompiler(Arrays.asList( new File(rootDirectory+"subpackage1/Test1.jav"), new File(rootDirectory+"subpackage2/Test2.jav") )); compiler.typeInference(); File f = new File(rootDirectory + "subpackage1/Test1.class"); if(f.exists() && !f.isDirectory()) { f.delete(); } File f2 = new File(rootDirectory + "subpackage2/Test2.class"); if(f.exists() && !f.isDirectory()) {
|
||||
* f.delete(); } compiler.generateBytecode(); f = new File(rootDirectory + "subpackage1/Test1.class"); f2 = new File(rootDirectory + "subpackage2/Test2.class"); assertTrue(f.exists()); assertTrue(f2.exists()); }
|
||||
*/
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import java.net.URLClassLoader;
|
||||
|
||||
public class ConsoleInterfaceTest extends TestCase {
|
||||
|
||||
public static final String rootDirectory = System.getProperty("user.dir")+"/resources/javFiles/packageTest/";
|
||||
public static final String rootDirectory = System.getProperty("user.dir") + "/src/test/resources/javFiles/packageTest/";
|
||||
|
||||
@Test
|
||||
public void testCompileSingleJavFile() throws Exception {
|
||||
@ -103,8 +103,7 @@ public class ConsoleInterfaceTest extends TestCase {
|
||||
f.delete();
|
||||
}
|
||||
|
||||
ConsoleInterface.main(new String[]{"-cp", rootDirectory + "de/test/output/:"+rootDirectory+"de",
|
||||
rootDirectory + "de/test/ImportTest.jav"});
|
||||
ConsoleInterface.main(new String[] { "-cp", rootDirectory + "de/test/output/:" + rootDirectory + "de", rootDirectory + "de/test/ImportTest.jav" });
|
||||
|
||||
f = new File(rootDirectory + "de/test/ImportTest.class");
|
||||
assertTrue(f.exists());
|
||||
@ -123,8 +122,7 @@ public class ConsoleInterfaceTest extends TestCase {
|
||||
f.delete();
|
||||
}
|
||||
|
||||
ConsoleInterface.main(new String[]{"-cp", rootDirectory + "de/test/output/",
|
||||
"-d"+rootDirectory + "de/test/output/" ,rootDirectory + "de/test/ImportTest.jav"});
|
||||
ConsoleInterface.main(new String[] { "-cp", rootDirectory + "de/test/output/", "-d" + rootDirectory + "de/test/output/", rootDirectory + "de/test/ImportTest.jav" });
|
||||
|
||||
f = new File(rootDirectory + "de/test/output/de/test/ImportTest.class");
|
||||
assertTrue(f.exists());
|
||||
|
@ -12,12 +12,11 @@ import java.net.URL;
|
||||
|
||||
public class ImportTest extends TestCase {
|
||||
|
||||
public static final String rootDirectory = System.getProperty("user.dir")+"/resources/javFiles/packageTest/de/test/";
|
||||
|
||||
public static final String rootDirectory = System.getProperty("user.dir") + "/src/test/resources/javFiles/packageTest/de/test/";
|
||||
|
||||
public ImportTest() throws ClassNotFoundException, IOException {
|
||||
/*
|
||||
Generate ToImport class in rootDirectory and in output-Directory
|
||||
* Generate ToImport class in rootDirectory and in output-Directory
|
||||
*/
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory + "ToImport.jav"));
|
||||
compiler.typeInference();
|
||||
@ -46,9 +45,7 @@ public class ImportTest extends TestCase {
|
||||
|
||||
@Test
|
||||
public void testSetPackageNameInBytecodeAndOutputFolder() throws IOException, ClassNotFoundException {
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(
|
||||
Lists.newArrayList(new File(rootDirectory+"ImportTest.jav")),
|
||||
Lists.newArrayList(new File(rootDirectory+"output/")));
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(Lists.newArrayList(new File(rootDirectory + "ImportTest.jav")), Lists.newArrayList(new File(rootDirectory + "output/")));
|
||||
compiler.typeInference();
|
||||
File f = new File(rootDirectory + "output/de/test/ImportTest.class");
|
||||
if (f.exists() && !f.isDirectory()) {
|
||||
@ -61,9 +58,7 @@ public class ImportTest extends TestCase {
|
||||
|
||||
@Test
|
||||
public void testSetPackageNameInBytecodeAndStandardOutputFolder() throws IOException, ClassNotFoundException {
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(
|
||||
Lists.newArrayList(new File(rootDirectory+"ImportTest.jav")),
|
||||
Lists.newArrayList(new File(rootDirectory+"output/")));
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(Lists.newArrayList(new File(rootDirectory + "ImportTest.jav")), Lists.newArrayList(new File(rootDirectory + "output/")));
|
||||
compiler.typeInference();
|
||||
File f = new File(rootDirectory + "ImportTest.class");
|
||||
if (f.exists() && !f.isDirectory()) {
|
||||
@ -74,12 +69,9 @@ public class ImportTest extends TestCase {
|
||||
assertTrue(f.exists());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testImportTwoClasses() throws IOException, ClassNotFoundException {
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(
|
||||
Lists.newArrayList(new File(rootDirectory+"ImportTest2.jav")),
|
||||
Lists.newArrayList(new File(rootDirectory+"output/")));
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(Lists.newArrayList(new File(rootDirectory + "ImportTest2.jav")), Lists.newArrayList(new File(rootDirectory + "output/")));
|
||||
compiler.typeInference();
|
||||
File f = new File(rootDirectory + "ImportTest2.class");
|
||||
if (f.exists() && !f.isDirectory()) {
|
||||
@ -92,8 +84,7 @@ public class ImportTest extends TestCase {
|
||||
|
||||
@Test
|
||||
public void testImportDefaultPackage() throws IOException, ClassNotFoundException {
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(
|
||||
Lists.newArrayList(new File(rootDirectory+"ImportTestDefault.jav")));
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(Lists.newArrayList(new File(rootDirectory + "ImportTestDefault.jav")));
|
||||
compiler.typeInference();
|
||||
File f = new File(rootDirectory + "ImportTestDefault.class");
|
||||
if (f.exists() && !f.isDirectory()) {
|
||||
@ -104,5 +95,4 @@ public class ImportTest extends TestCase {
|
||||
assertTrue(f.exists());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import java.net.URLClassLoader;
|
||||
|
||||
public class LoadDefaultPackageClassesTest extends TestCase {
|
||||
|
||||
public static final String rootDirectory = System.getProperty("user.dir") + "/resources/javFiles/packageTest/";
|
||||
public static final String rootDirectory = System.getProperty("user.dir") + "/src/test/resources/javFiles/packageTest/";
|
||||
|
||||
public LoadDefaultPackageClassesTest() throws ClassNotFoundException, IOException {
|
||||
/*
|
||||
@ -35,14 +35,8 @@ public class LoadDefaultPackageClassesTest extends TestCase {
|
||||
cl.loadClass("Gen");
|
||||
}
|
||||
/*
|
||||
* public void testE2E() throws IOException, ClassNotFoundException {
|
||||
* JavaTXCompiler compiler = new JavaTXCompiler(new
|
||||
* File(rootDirectory+"OL.jav")); compiler.typeInference();
|
||||
* compiler.generateBytecode(); File f = new File(rootDirectory + "OL.class");
|
||||
* assertTrue(f.exists());
|
||||
* public void testE2E() throws IOException, ClassNotFoundException { JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+"OL.jav")); compiler.typeInference(); compiler.generateBytecode(); File f = new File(rootDirectory + "OL.class"); assertTrue(f.exists());
|
||||
*
|
||||
* compiler = new JavaTXCompiler(new File(rootDirectory+"OLMain.jav"));
|
||||
* compiler.typeInference(); compiler.generateBytecode(); f = new
|
||||
* File(rootDirectory + "OLMain.class"); assertTrue(f.exists()); }
|
||||
* compiler = new JavaTXCompiler(new File(rootDirectory+"OLMain.jav")); compiler.typeInference(); compiler.generateBytecode(); f = new File(rootDirectory + "OLMain.class"); assertTrue(f.exists()); }
|
||||
*/
|
||||
}
|
||||
|
@ -31,16 +31,14 @@ public class OLOneFileTest {
|
||||
private static Object instanceOfClass1;
|
||||
private static Object instanceOfClass2;
|
||||
|
||||
public static final String rootDirectory = System.getProperty("user.dir")+"/resources/javFiles/packageTest/";
|
||||
public static final String rootDirectory = System.getProperty("user.dir") + "/src/test/resources/javFiles/packageTest/";
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpBeforeClass() throws Exception {
|
||||
path = rootDirectory + "OLOneFile.jav";
|
||||
fileToTest = new File(path);
|
||||
compiler = new JavaTXCompiler(
|
||||
Lists.newArrayList(fileToTest),
|
||||
Lists.newArrayList(new File(rootDirectory+"de/test/output/")));
|
||||
pathToClassFile = System.getProperty("user.dir")+"/resources/javFiles/packageTest/";
|
||||
compiler = new JavaTXCompiler(Lists.newArrayList(fileToTest), Lists.newArrayList(new File(rootDirectory + "de/test/output/")));
|
||||
pathToClassFile = System.getProperty("user.dir") + "/src/test/resources/javFiles/packageTest/";
|
||||
List<ResultSet> typeinferenceResult = compiler.typeInference();
|
||||
// List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(typeinferenceResult);
|
||||
// compiler.generateBytecode(new File(pathToClassFile),typeinferenceResult,simplifyResultsForAllSourceFiles);
|
||||
|
@ -31,7 +31,7 @@ public class OLTest {
|
||||
private static Object instanceOfClass1;
|
||||
private static Object instanceOfClass2;
|
||||
|
||||
public static final String rootDirectory = System.getProperty("user.dir")+"/resources/javFiles/packageTest";
|
||||
public static final String rootDirectory = System.getProperty("user.dir") + "/src/test/resources/javFiles/packageTest";
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpBeforeClass() throws Exception {
|
||||
@ -42,25 +42,21 @@ public class OLTest {
|
||||
classToTest = loader.loadClass("de.test.OL");
|
||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
|
||||
path = System.getProperty("user.dir")+"/resources/javFiles/packageTest/OLextends.jav";
|
||||
path = System.getProperty("user.dir") + "/src/test/resources/javFiles/packageTest/OLextends.jav";
|
||||
fileToTest = new File(path);
|
||||
compiler = new JavaTXCompiler(
|
||||
Lists.newArrayList(new File(rootDirectory+"/OLextends.jav")),
|
||||
Lists.newArrayList(new File(rootDirectory+"/de/test/output/")));
|
||||
compiler = new JavaTXCompiler(Lists.newArrayList(new File(rootDirectory + "/OLextends.jav")), Lists.newArrayList(new File(rootDirectory + "/de/test/output/")));
|
||||
// compiler = new JavaTXCompiler(fileToTest);
|
||||
pathToClassFile = System.getProperty("user.dir")+"/resources/javFiles/packageTest/";
|
||||
pathToClassFile = System.getProperty("user.dir") + "/src/test/resources/javFiles/packageTest/";
|
||||
compiler.generateBytecode(pathToClassFile);
|
||||
loader = new URLClassLoader(new URL[] { new URL("file://" + pathToClassFile), new URL("file://" + rootDirectory + "/de/test/output/") });
|
||||
classToTest1 = loader.loadClass("OLextends");
|
||||
instanceOfClass1 = classToTest1.getDeclaredConstructor().newInstance();
|
||||
|
||||
path = System.getProperty("user.dir")+"/resources/javFiles/packageTest/OLMain.jav";
|
||||
path = System.getProperty("user.dir") + "/src/test/resources/javFiles/packageTest/OLMain.jav";
|
||||
fileToTest = new File(path);
|
||||
compiler = new JavaTXCompiler(
|
||||
Lists.newArrayList(new File(rootDirectory+"/OLMain.jav")),
|
||||
Lists.newArrayList(new File(rootDirectory+"/de/test/output/")));
|
||||
compiler = new JavaTXCompiler(Lists.newArrayList(new File(rootDirectory + "/OLMain.jav")), Lists.newArrayList(new File(rootDirectory + "/de/test/output/")));
|
||||
// compiler = new JavaTXCompiler(fileToTest);
|
||||
pathToClassFile = System.getProperty("user.dir")+"/resources/javFiles/packageTest/";
|
||||
pathToClassFile = System.getProperty("user.dir") + "/src/test/resources/javFiles/packageTest/";
|
||||
compiler.generateBytecode(pathToClassFile);
|
||||
loader = new URLClassLoader(new URL[] { new URL("file://" + pathToClassFile), new URL("file://" + rootDirectory + "/de/test/output/") });
|
||||
classToTest2 = loader.loadClass("OLMain");
|
||||
|
@ -9,7 +9,8 @@ import java.io.IOException;
|
||||
|
||||
public class ParsePackageName {
|
||||
|
||||
public static final String rootDirectory = System.getProperty("user.dir")+"/resources/javFiles/packageTest/de/test/";
|
||||
public static final String rootDirectory = System.getProperty("user.dir") + "/src/test/resources/javFiles/packageTest/de/test/";
|
||||
|
||||
@Test
|
||||
public void parsePackage() throws IOException, ClassNotFoundException {
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory + "TestClass.jav"));
|
||||
|
@ -12,7 +12,7 @@ import java.net.URL;
|
||||
|
||||
public class mathStrucMatrixOPTest extends TestCase {
|
||||
|
||||
public static final String rootDirectory = System.getProperty("user.dir")+"/resources/javFiles/packageTest/de/test/";
|
||||
public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/javFiles/packageTest/de/test/";
|
||||
|
||||
|
||||
public mathStrucMatrixOPTest() throws ClassNotFoundException, IOException {
|
||||
|
@ -12,20 +12,15 @@ import java.net.URL;
|
||||
|
||||
public class mathStrucVectorTest extends TestCase {
|
||||
|
||||
public static final String rootDirectory = System.getProperty("user.dir")+"/resources/javFiles/packageTest/de/test/";
|
||||
|
||||
public static final String rootDirectory = System.getProperty("user.dir") + "/src/test/resources/javFiles/packageTest/de/test/";
|
||||
|
||||
public mathStrucVectorTest() throws ClassNotFoundException, IOException {
|
||||
/*
|
||||
Generate ToImport class in rootDirectory and in output-Directory
|
||||
* Generate ToImport class in rootDirectory and in output-Directory
|
||||
*/
|
||||
|
||||
/* PL 2020-01-07 kann z.Zt. nicht erzeugt werden (siehe Bug 170, http://bugzilla.ba-horb.de/show_bug.cgi?id=170)
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+"mathStruc.jav"));
|
||||
compiler.typeInference();
|
||||
compiler.generateBytecode(rootDirectory + "output/");
|
||||
File f = new File(rootDirectory + "output/de/test/mathStruc.class");
|
||||
assertTrue(f.exists());
|
||||
/*
|
||||
* PL 2020-01-07 kann z.Zt. nicht erzeugt werden (siehe Bug 170, http://bugzilla.ba-horb.de/show_bug.cgi?id=170) JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+"mathStruc.jav")); compiler.typeInference(); compiler.generateBytecode(rootDirectory + "output/"); File f = new File(rootDirectory + "output/de/test/mathStruc.class"); assertTrue(f.exists());
|
||||
*/
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory + "vectorAdd.jav"));
|
||||
compiler.typeInference();
|
||||
@ -37,9 +32,7 @@ public class mathStrucVectorTest extends TestCase {
|
||||
|
||||
@Test
|
||||
public void testSetPackageNameInBytecodeAndOutputFolder() throws IOException, ClassNotFoundException {
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(
|
||||
Lists.newArrayList(new File(rootDirectory+"mathStrucVector.jav")),
|
||||
Lists.newArrayList(new File(rootDirectory+"output/")));
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(Lists.newArrayList(new File(rootDirectory + "mathStrucVector.jav")), Lists.newArrayList(new File(rootDirectory + "output/")));
|
||||
compiler.typeInference();
|
||||
File f = new File(rootDirectory + "output/de/test/mathStrucVector.class");
|
||||
if (f.exists() && !f.isDirectory()) {
|
||||
@ -50,5 +43,4 @@ public class mathStrucVectorTest extends TestCase {
|
||||
assertTrue(f.exists());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -25,8 +25,7 @@ public class ASTToTypedTargetAST {
|
||||
|
||||
@Test
|
||||
public void emptyClass() {
|
||||
ClassOrInterface emptyClass = new ClassOrInterface(0, new JavaClassName("EmptyClass"), new ArrayList<>(), java.util.Optional.empty(), new ArrayList<>(), new ArrayList<>(), new GenericDeclarationList(new ArrayList<>(), new NullToken()),
|
||||
new RefType(new JavaClassName("Object"), new NullToken()), false, new ArrayList<>(), new NullToken());
|
||||
ClassOrInterface emptyClass = new ClassOrInterface(0, new JavaClassName("EmptyClass"), new ArrayList<>(), java.util.Optional.empty(), new ArrayList<>(), new ArrayList<>(), new GenericDeclarationList(new ArrayList<>(), new NullToken()), new RefType(new JavaClassName("Object"), new NullToken()), false, new ArrayList<>(), new NullToken());
|
||||
ResultSet emptyResultSet = new ResultSet(new HashSet<>());
|
||||
TargetClass emptyTargetClass = new ASTToTargetAST(List.of(emptyResultSet)).convert(emptyClass);
|
||||
assert emptyTargetClass.getName().equals("EmptyClass");
|
||||
@ -36,7 +35,7 @@ public class ASTToTypedTargetAST {
|
||||
|
||||
@Test
|
||||
public void overloading() throws Exception {
|
||||
var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Overloading.jav").toFile();
|
||||
var file = Path.of(System.getProperty("user.dir"), "/src/test/resources/bytecode/javFiles/Overloading.jav").toFile();
|
||||
var compiler = new JavaTXCompiler(file);
|
||||
var resultSet = compiler.typeInference();
|
||||
var converter = new ASTToTargetAST(resultSet);
|
||||
@ -58,7 +57,7 @@ public class ASTToTypedTargetAST {
|
||||
|
||||
@Test
|
||||
public void tphsAndGenerics() throws Exception {
|
||||
var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Tph2.jav").toFile();
|
||||
var file = Path.of(System.getProperty("user.dir"), "/src/test/resources/bytecode/javFiles/Tph2.jav").toFile();
|
||||
var compiler = new JavaTXCompiler(file);
|
||||
var resultSet = compiler.typeInference();
|
||||
var converter = new ASTToTargetAST(resultSet);
|
||||
@ -69,7 +68,7 @@ public class ASTToTypedTargetAST {
|
||||
|
||||
@Test
|
||||
public void cycles() throws Exception {
|
||||
var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Cycle.jav").toFile();
|
||||
var file = Path.of(System.getProperty("user.dir"), "/src/test/resources/bytecode/javFiles/Cycle.jav").toFile();
|
||||
var compiler = new JavaTXCompiler(file);
|
||||
var resultSet = compiler.typeInference();
|
||||
var converter = new ASTToTargetAST(resultSet);
|
||||
@ -80,7 +79,7 @@ public class ASTToTypedTargetAST {
|
||||
|
||||
@Test
|
||||
public void infimum() throws Exception {
|
||||
var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Infimum.jav").toFile();
|
||||
var file = Path.of(System.getProperty("user.dir"), "/src/test/resources/bytecode/javFiles/Infimum.jav").toFile();
|
||||
var compiler = new JavaTXCompiler(file);
|
||||
var resultSet = compiler.typeInference();
|
||||
var converter = new ASTToTargetAST(resultSet);
|
||||
@ -91,7 +90,7 @@ public class ASTToTypedTargetAST {
|
||||
|
||||
@Test
|
||||
public void gen() throws Exception {
|
||||
var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Gen.jav").toFile();
|
||||
var file = Path.of(System.getProperty("user.dir"), "/src/test/resources/bytecode/javFiles/Gen.jav").toFile();
|
||||
var compiler = new JavaTXCompiler(file);
|
||||
var resultSet = compiler.typeInference();
|
||||
var converter = new ASTToTargetAST(resultSet);
|
||||
@ -101,12 +100,13 @@ public class ASTToTypedTargetAST {
|
||||
var m = generics.getDeclaredMethod("m", Vector.class);
|
||||
var mReturnType = m.getGenericReturnType();
|
||||
assertEquals(mReturnType, m.getParameters()[0].getParameterizedType());
|
||||
assertEquals(mReturnType, new TypeToken<Vector<Integer>>(){}.getType());
|
||||
assertEquals(mReturnType, new TypeToken<Vector<Integer>>() {
|
||||
}.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void definedGenerics() throws Exception {
|
||||
var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Generics.jav").toFile();
|
||||
var file = Path.of(System.getProperty("user.dir"), "/src/test/resources/bytecode/javFiles/Generics.jav").toFile();
|
||||
var compiler = new JavaTXCompiler(file);
|
||||
var resultSet = compiler.typeInference();
|
||||
var converter = new ASTToTargetAST(resultSet);
|
||||
@ -124,7 +124,7 @@ public class ASTToTypedTargetAST {
|
||||
|
||||
@Test
|
||||
public void definedGenerics2() throws Exception {
|
||||
var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Generics2.jav").toFile();
|
||||
var file = Path.of(System.getProperty("user.dir"), "/src/test/resources/bytecode/javFiles/Generics2.jav").toFile();
|
||||
var compiler = new JavaTXCompiler(file);
|
||||
var resultSet = compiler.typeInference();
|
||||
var converter = new ASTToTargetAST(resultSet);
|
||||
@ -140,7 +140,7 @@ public class ASTToTypedTargetAST {
|
||||
@Test
|
||||
@Ignore("Not implemented")
|
||||
public void definedGenerics3() throws Exception {
|
||||
var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Generics3.jav").toFile();
|
||||
var file = Path.of(System.getProperty("user.dir"), "/src/test/resources/bytecode/javFiles/Generics3.jav").toFile();
|
||||
var compiler = new JavaTXCompiler(file);
|
||||
var resultSet = compiler.typeInference();
|
||||
var converter = new ASTToTargetAST(resultSet);
|
||||
@ -151,7 +151,7 @@ public class ASTToTypedTargetAST {
|
||||
|
||||
@Test
|
||||
public void definedGenerics4() throws Exception {
|
||||
var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Generics4.jav").toFile();
|
||||
var file = Path.of(System.getProperty("user.dir"), "/src/test/resources/bytecode/javFiles/Generics4.jav").toFile();
|
||||
var compiler = new JavaTXCompiler(file);
|
||||
var resultSet = compiler.typeInference();
|
||||
var converter = new ASTToTargetAST(resultSet);
|
||||
|
@ -25,7 +25,6 @@ import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
public class TestCodegen {
|
||||
|
||||
private static void writeClassFile(String name, byte[] code) throws IOException {
|
||||
@ -42,7 +41,7 @@ public class TestCodegen {
|
||||
}
|
||||
|
||||
public static Map<String, ? extends Class<?>> generateClassFiles(String filename, IByteArrayClassLoader classLoader) throws IOException, ClassNotFoundException {
|
||||
var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/", filename).toFile();
|
||||
var file = Path.of(System.getProperty("user.dir"), "/src/test/resources/bytecode/javFiles/", filename).toFile();
|
||||
var compiler = new JavaTXCompiler(List.of(file), List.of(file.getParentFile()));
|
||||
var resultSet = compiler.typeInference();
|
||||
|
||||
@ -76,42 +75,11 @@ public class TestCodegen {
|
||||
public void testArithmetic() throws Exception {
|
||||
var targetClass = new TargetClass(Opcodes.ACC_PUBLIC, "Arithmetic");
|
||||
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "add",
|
||||
List.of(new MethodParameter(TargetType.Integer, "a"), new MethodParameter(TargetType.Integer, "b")),
|
||||
TargetType.Integer,
|
||||
new TargetBlock(List.of(new TargetReturn(
|
||||
new TargetBinaryOp.Add(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "a"), new TargetLocalVar(TargetType.Integer, "b")))
|
||||
))
|
||||
);
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "sub",
|
||||
List.of(new MethodParameter(TargetType.Integer, "a"), new MethodParameter(TargetType.Integer, "b")),
|
||||
TargetType.Integer,
|
||||
new TargetBlock(List.of(new TargetReturn(
|
||||
new TargetBinaryOp.Sub(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "a"), new TargetLocalVar(TargetType.Integer, "b")))
|
||||
))
|
||||
);
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "div",
|
||||
List.of(new MethodParameter(TargetType.Integer, "a"), new MethodParameter(TargetType.Integer, "b")),
|
||||
TargetType.Integer,
|
||||
new TargetBlock(List.of(new TargetReturn(
|
||||
new TargetBinaryOp.Div(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "a"), new TargetLocalVar(TargetType.Integer, "b")))
|
||||
))
|
||||
);
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "mul",
|
||||
List.of(new MethodParameter(TargetType.Integer, "a"), new MethodParameter(TargetType.Integer, "b")),
|
||||
TargetType.Integer,
|
||||
new TargetBlock(List.of(new TargetReturn(
|
||||
new TargetBinaryOp.Mul(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "a"), new TargetLocalVar(TargetType.Integer, "b")))
|
||||
))
|
||||
);
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "rem",
|
||||
List.of(new MethodParameter(TargetType.Integer, "a"), new MethodParameter(TargetType.Integer, "b")),
|
||||
TargetType.Integer,
|
||||
new TargetBlock(List.of(new TargetReturn(
|
||||
new TargetBinaryOp.Rem(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "a"), new TargetLocalVar(TargetType.Integer, "b")))
|
||||
))
|
||||
);
|
||||
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "add", List.of(new MethodParameter(TargetType.Integer, "a"), new MethodParameter(TargetType.Integer, "b")), TargetType.Integer, new TargetBlock(List.of(new TargetReturn(new TargetBinaryOp.Add(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "a"), new TargetLocalVar(TargetType.Integer, "b"))))));
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "sub", List.of(new MethodParameter(TargetType.Integer, "a"), new MethodParameter(TargetType.Integer, "b")), TargetType.Integer, new TargetBlock(List.of(new TargetReturn(new TargetBinaryOp.Sub(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "a"), new TargetLocalVar(TargetType.Integer, "b"))))));
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "div", List.of(new MethodParameter(TargetType.Integer, "a"), new MethodParameter(TargetType.Integer, "b")), TargetType.Integer, new TargetBlock(List.of(new TargetReturn(new TargetBinaryOp.Div(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "a"), new TargetLocalVar(TargetType.Integer, "b"))))));
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "mul", List.of(new MethodParameter(TargetType.Integer, "a"), new MethodParameter(TargetType.Integer, "b")), TargetType.Integer, new TargetBlock(List.of(new TargetReturn(new TargetBinaryOp.Mul(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "a"), new TargetLocalVar(TargetType.Integer, "b"))))));
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "rem", List.of(new MethodParameter(TargetType.Integer, "a"), new MethodParameter(TargetType.Integer, "b")), TargetType.Integer, new TargetBlock(List.of(new TargetReturn(new TargetBinaryOp.Rem(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "a"), new TargetLocalVar(TargetType.Integer, "b"))))));
|
||||
|
||||
var clazz = generateClass(targetClass, new ByteArrayClassLoader());
|
||||
assertEquals(clazz.getDeclaredMethod("add", Integer.class, Integer.class).invoke(null, 10, 10), 20);
|
||||
@ -125,27 +93,9 @@ public class TestCodegen {
|
||||
public void testUnary() throws Exception {
|
||||
var targetClass = new TargetClass(Opcodes.ACC_PUBLIC, "Unary");
|
||||
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "not",
|
||||
List.of(new MethodParameter(TargetType.Integer, "a")),
|
||||
TargetType.Integer,
|
||||
new TargetBlock(List.of(new TargetReturn(
|
||||
new TargetUnaryOp.Not(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "a")))
|
||||
))
|
||||
);
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "neg",
|
||||
List.of(new MethodParameter(TargetType.Integer, "a")),
|
||||
TargetType.Integer,
|
||||
new TargetBlock(List.of(new TargetReturn(
|
||||
new TargetUnaryOp.Negate(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "a")))
|
||||
))
|
||||
);
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "add",
|
||||
List.of(new MethodParameter(TargetType.Integer, "a")),
|
||||
TargetType.Integer,
|
||||
new TargetBlock(List.of(new TargetReturn(
|
||||
new TargetUnaryOp.Add(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "a")))
|
||||
))
|
||||
);
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "not", List.of(new MethodParameter(TargetType.Integer, "a")), TargetType.Integer, new TargetBlock(List.of(new TargetReturn(new TargetUnaryOp.Not(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "a"))))));
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "neg", List.of(new MethodParameter(TargetType.Integer, "a")), TargetType.Integer, new TargetBlock(List.of(new TargetReturn(new TargetUnaryOp.Negate(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "a"))))));
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "add", List.of(new MethodParameter(TargetType.Integer, "a")), TargetType.Integer, new TargetBlock(List.of(new TargetReturn(new TargetUnaryOp.Add(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "a"))))));
|
||||
|
||||
var clazz = generateClass(targetClass, new ByteArrayClassLoader());
|
||||
assertEquals(clazz.getDeclaredMethod("not", Integer.class).invoke(null, 10), -11);
|
||||
@ -158,20 +108,8 @@ public class TestCodegen {
|
||||
public void testConditional() throws Exception {
|
||||
var targetClass = new TargetClass(Opcodes.ACC_PUBLIC, "Conditional");
|
||||
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "and",
|
||||
List.of(new MethodParameter(TargetType.Boolean, "a"), new MethodParameter(TargetType.Boolean, "b")),
|
||||
TargetType.Boolean,
|
||||
new TargetBlock(List.of(new TargetReturn(
|
||||
new TargetBinaryOp.And(TargetType.Boolean, new TargetLocalVar(TargetType.Boolean, "a"), new TargetLocalVar(TargetType.Boolean, "b")))
|
||||
))
|
||||
);
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "or",
|
||||
List.of(new MethodParameter(TargetType.Boolean, "a"), new MethodParameter(TargetType.Boolean, "b")),
|
||||
TargetType.Boolean,
|
||||
new TargetBlock(List.of(new TargetReturn(
|
||||
new TargetBinaryOp.Or(TargetType.Boolean, new TargetLocalVar(TargetType.Boolean, "a"), new TargetLocalVar(TargetType.Boolean, "b")))
|
||||
))
|
||||
);
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "and", List.of(new MethodParameter(TargetType.Boolean, "a"), new MethodParameter(TargetType.Boolean, "b")), TargetType.Boolean, new TargetBlock(List.of(new TargetReturn(new TargetBinaryOp.And(TargetType.Boolean, new TargetLocalVar(TargetType.Boolean, "a"), new TargetLocalVar(TargetType.Boolean, "b"))))));
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "or", List.of(new MethodParameter(TargetType.Boolean, "a"), new MethodParameter(TargetType.Boolean, "b")), TargetType.Boolean, new TargetBlock(List.of(new TargetReturn(new TargetBinaryOp.Or(TargetType.Boolean, new TargetLocalVar(TargetType.Boolean, "a"), new TargetLocalVar(TargetType.Boolean, "b"))))));
|
||||
|
||||
var clazz = generateClass(targetClass, new ByteArrayClassLoader());
|
||||
var and = clazz.getDeclaredMethod("and", Boolean.class, Boolean.class);
|
||||
@ -186,11 +124,7 @@ public class TestCodegen {
|
||||
@Test
|
||||
public void testArithmeticConvert() throws Exception {
|
||||
var targetClass = new TargetClass(Opcodes.ACC_PUBLIC, "ArithmeticConvert");
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "add", List.of(), TargetType.Long,
|
||||
new TargetBlock(List.of(new TargetReturn(
|
||||
new TargetBinaryOp.Add(TargetType.Long, new TargetLiteral.CharLiteral((char)10), new TargetLiteral.LongLiteral((long)20))
|
||||
)))
|
||||
);
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "add", List.of(), TargetType.Long, new TargetBlock(List.of(new TargetReturn(new TargetBinaryOp.Add(TargetType.Long, new TargetLiteral.CharLiteral((char) 10), new TargetLiteral.LongLiteral((long) 20))))));
|
||||
var clazz = generateClass(targetClass, new ByteArrayClassLoader());
|
||||
assertEquals(clazz.getDeclaredMethod("add").invoke(null), (long) 30);
|
||||
}
|
||||
@ -198,21 +132,7 @@ public class TestCodegen {
|
||||
@Test
|
||||
public void testMethodCall() throws Exception {
|
||||
var targetClass = new TargetClass(Opcodes.ACC_PUBLIC, "HelloWorld");
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "helloWorld", List.of(), null,
|
||||
new TargetBlock(List.of(new TargetMethodCall(null,
|
||||
new TargetFieldVar(
|
||||
new TargetRefType("java.io.PrintStream"),
|
||||
new TargetRefType("java.lang.System"),
|
||||
true,
|
||||
new TargetClassName(new TargetRefType("java.lang.System")),
|
||||
"out"
|
||||
),
|
||||
List.of(new TargetLiteral.StringLiteral("Hello World!")),
|
||||
new TargetRefType("java.io.PrintStream"),
|
||||
"println",
|
||||
false, false
|
||||
)))
|
||||
);
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "helloWorld", List.of(), null, new TargetBlock(List.of(new TargetMethodCall(null, new TargetFieldVar(new TargetRefType("java.io.PrintStream"), new TargetRefType("java.lang.System"), true, new TargetClassName(new TargetRefType("java.lang.System")), "out"), List.of(new TargetLiteral.StringLiteral("Hello World!")), new TargetRefType("java.io.PrintStream"), "println", false, false))));
|
||||
|
||||
var clazz = generateClass(targetClass, new ByteArrayClassLoader());
|
||||
clazz.getDeclaredMethod("helloWorld").invoke(null);
|
||||
@ -221,19 +141,7 @@ public class TestCodegen {
|
||||
@Test
|
||||
public void testIfStatement() throws Exception {
|
||||
var targetClass = new TargetClass(Opcodes.ACC_PUBLIC, "IfStmt");
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "ifStmt",
|
||||
List.of(new MethodParameter(TargetType.Integer, "val")),
|
||||
TargetType.Integer,
|
||||
new TargetBlock(List.of(new TargetIf(
|
||||
new TargetBinaryOp.Equal(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "val"), new TargetLiteral.IntLiteral(10)),
|
||||
new TargetReturn(new TargetLiteral.IntLiteral(1)),
|
||||
new TargetIf(
|
||||
new TargetBinaryOp.Less(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "val"), new TargetLiteral.IntLiteral(5)),
|
||||
new TargetReturn(new TargetLiteral.IntLiteral(2)),
|
||||
new TargetReturn(new TargetLiteral.IntLiteral(3))
|
||||
)
|
||||
)))
|
||||
);
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "ifStmt", List.of(new MethodParameter(TargetType.Integer, "val")), TargetType.Integer, new TargetBlock(List.of(new TargetIf(new TargetBinaryOp.Equal(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "val"), new TargetLiteral.IntLiteral(10)), new TargetReturn(new TargetLiteral.IntLiteral(1)), new TargetIf(new TargetBinaryOp.Less(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "val"), new TargetLiteral.IntLiteral(5)), new TargetReturn(new TargetLiteral.IntLiteral(2)), new TargetReturn(new TargetLiteral.IntLiteral(3)))))));
|
||||
var clazz = generateClass(targetClass, new ByteArrayClassLoader());
|
||||
var ifStmt = clazz.getDeclaredMethod("ifStmt", Integer.class);
|
||||
assertEquals(ifStmt.invoke(null, 10), 1);
|
||||
@ -244,25 +152,7 @@ public class TestCodegen {
|
||||
@Test
|
||||
public void testFor() throws Exception {
|
||||
var targetClass = new TargetClass(Opcodes.ACC_PUBLIC, "For");
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "forLoop", List.of(), TargetType.Integer,
|
||||
new TargetBlock(List.of(
|
||||
new TargetVarDecl(TargetType.Integer, "sum", new TargetLiteral.IntLiteral(0)),
|
||||
new TargetFor(
|
||||
new TargetVarDecl(TargetType.Integer, "i", new TargetLiteral.IntLiteral(0)),
|
||||
new TargetBinaryOp.Less(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "i"), new TargetLiteral.IntLiteral(10)),
|
||||
new TargetAssign(TargetType.Integer,
|
||||
new TargetLocalVar(TargetType.Integer, "i"),
|
||||
new TargetBinaryOp.Add(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "i"), new TargetLiteral.IntLiteral(1))),
|
||||
new TargetBlock(List.of(
|
||||
new TargetAssign(TargetType.Integer,
|
||||
new TargetLocalVar(TargetType.Integer, "sum"),
|
||||
new TargetBinaryOp.Add(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "sum"), new TargetLocalVar(TargetType.Integer, "i"))
|
||||
)
|
||||
))
|
||||
),
|
||||
new TargetReturn(new TargetLocalVar(TargetType.Integer, "sum"))
|
||||
))
|
||||
);
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "forLoop", List.of(), TargetType.Integer, new TargetBlock(List.of(new TargetVarDecl(TargetType.Integer, "sum", new TargetLiteral.IntLiteral(0)), new TargetFor(new TargetVarDecl(TargetType.Integer, "i", new TargetLiteral.IntLiteral(0)), new TargetBinaryOp.Less(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "i"), new TargetLiteral.IntLiteral(10)), new TargetAssign(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "i"), new TargetBinaryOp.Add(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "i"), new TargetLiteral.IntLiteral(1))), new TargetBlock(List.of(new TargetAssign(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "sum"), new TargetBinaryOp.Add(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "sum"), new TargetLocalVar(TargetType.Integer, "i")))))), new TargetReturn(new TargetLocalVar(TargetType.Integer, "sum")))));
|
||||
var clazz = generateClass(targetClass, new ByteArrayClassLoader());
|
||||
assertEquals(clazz.getDeclaredMethod("forLoop").invoke(null), 45);
|
||||
}
|
||||
@ -270,21 +160,7 @@ public class TestCodegen {
|
||||
@Test
|
||||
public void testWhile() throws Exception {
|
||||
var targetClass = new TargetClass(Opcodes.ACC_PUBLIC, "While");
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "whileLoop", List.of(), TargetType.Integer,
|
||||
new TargetBlock(List.of(
|
||||
new TargetVarDecl(TargetType.Integer, "i", new TargetLiteral.IntLiteral(0)),
|
||||
new TargetWhile(
|
||||
new TargetBinaryOp.Less(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "i"), new TargetLiteral.IntLiteral(10)),
|
||||
new TargetBlock(List.of(
|
||||
new TargetAssign(TargetType.Integer,
|
||||
new TargetLocalVar(TargetType.Integer, "i"),
|
||||
new TargetBinaryOp.Add(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "i"), new TargetLiteral.IntLiteral(1))
|
||||
)
|
||||
))
|
||||
),
|
||||
new TargetReturn(new TargetLocalVar(TargetType.Integer, "i"))
|
||||
))
|
||||
);
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "whileLoop", List.of(), TargetType.Integer, new TargetBlock(List.of(new TargetVarDecl(TargetType.Integer, "i", new TargetLiteral.IntLiteral(0)), new TargetWhile(new TargetBinaryOp.Less(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "i"), new TargetLiteral.IntLiteral(10)), new TargetBlock(List.of(new TargetAssign(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "i"), new TargetBinaryOp.Add(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "i"), new TargetLiteral.IntLiteral(1)))))), new TargetReturn(new TargetLocalVar(TargetType.Integer, "i")))));
|
||||
var clazz = generateClass(targetClass, new ByteArrayClassLoader());
|
||||
assertEquals(clazz.getDeclaredMethod("whileLoop").invoke(null), 10);
|
||||
}
|
||||
@ -295,31 +171,10 @@ public class TestCodegen {
|
||||
var pointTarget = new TargetClass(Opcodes.ACC_PUBLIC, "Point");
|
||||
pointTarget.addField(Opcodes.ACC_PUBLIC, TargetType.Integer, "x");
|
||||
pointTarget.addField(Opcodes.ACC_PUBLIC, TargetType.Integer, "y");
|
||||
pointTarget.addConstructor(Opcodes.ACC_PUBLIC,
|
||||
List.of(new MethodParameter(TargetType.Integer, "x"), new MethodParameter(TargetType.Integer, "y")),
|
||||
new TargetBlock(List.of(
|
||||
new TargetMethodCall(null, new TargetSuper(TargetType.Object), List.of(), TargetType.Object, "<init>", false, false),
|
||||
new TargetAssign(TargetType.Integer,
|
||||
new TargetFieldVar(TargetType.Integer, pointType, false, new TargetThis(pointType), "x"),
|
||||
new TargetLocalVar(TargetType.Integer, "x")
|
||||
),
|
||||
new TargetAssign(TargetType.Integer,
|
||||
new TargetFieldVar(TargetType.Integer, pointType, false, new TargetThis(pointType), "y"),
|
||||
new TargetLocalVar(TargetType.Integer, "y")
|
||||
)
|
||||
))
|
||||
);
|
||||
pointTarget.addConstructor(Opcodes.ACC_PUBLIC, List.of(new MethodParameter(TargetType.Integer, "x"), new MethodParameter(TargetType.Integer, "y")), new TargetBlock(List.of(new TargetMethodCall(null, new TargetSuper(TargetType.Object), List.of(), TargetType.Object, "<init>", false, false), new TargetAssign(TargetType.Integer, new TargetFieldVar(TargetType.Integer, pointType, false, new TargetThis(pointType), "x"), new TargetLocalVar(TargetType.Integer, "x")), new TargetAssign(TargetType.Integer, new TargetFieldVar(TargetType.Integer, pointType, false, new TargetThis(pointType), "y"), new TargetLocalVar(TargetType.Integer, "y")))));
|
||||
|
||||
var mainTarget = new TargetClass(Opcodes.ACC_PUBLIC, "New");
|
||||
mainTarget.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "makePoint",
|
||||
List.of(new MethodParameter(TargetType.Integer, "x"), new MethodParameter(TargetType.Integer, "y")), pointType,
|
||||
new TargetBlock(List.of(
|
||||
new TargetReturn(new TargetNew(pointType, List.of(
|
||||
new TargetLocalVar(TargetType.Integer, "x"),
|
||||
new TargetLocalVar(TargetType.Integer, "y")
|
||||
)))
|
||||
))
|
||||
);
|
||||
mainTarget.addMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "makePoint", List.of(new MethodParameter(TargetType.Integer, "x"), new MethodParameter(TargetType.Integer, "y")), pointType, new TargetBlock(List.of(new TargetReturn(new TargetNew(pointType, List.of(new TargetLocalVar(TargetType.Integer, "x"), new TargetLocalVar(TargetType.Integer, "y")))))));
|
||||
|
||||
var classLoader = new ByteArrayClassLoader();
|
||||
var pointClass = generateClass(pointTarget, classLoader);
|
||||
@ -338,26 +193,8 @@ public class TestCodegen {
|
||||
var interfaceType = new TargetFunNType(1, List.of(TargetType.Integer));
|
||||
|
||||
var targetClass = new TargetClass(Opcodes.ACC_PUBLIC, "CGLambda");
|
||||
targetClass.addConstructor(Opcodes.ACC_PUBLIC, List.of(), new TargetBlock(List.of(
|
||||
new TargetMethodCall(null, new TargetSuper(TargetType.Object), List.of(), TargetType.Object, "<init>", false, false)
|
||||
)));
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC, "lambda", List.of(), TargetType.Integer,
|
||||
new TargetBlock(List.of(
|
||||
new TargetVarDecl(interfaceType, "by2",
|
||||
new TargetLambdaExpression(interfaceType, List.of(), List.of(new MethodParameter(TargetType.Integer, "num")), TargetType.Integer,
|
||||
new TargetBlock(List.of(
|
||||
new TargetReturn(new TargetBinaryOp.Mul(TargetType.Integer,
|
||||
new TargetLocalVar(TargetType.Integer, "num"),
|
||||
new TargetLiteral.IntLiteral(2)
|
||||
))
|
||||
)
|
||||
))
|
||||
),
|
||||
new TargetReturn(new TargetCast(TargetType.Integer, new TargetMethodCall(TargetType.Object, TargetType.Object, List.of(TargetType.Object), new TargetLocalVar(interfaceType, "by2"), List.of(
|
||||
new TargetLiteral.IntLiteral(10)
|
||||
), interfaceType, "apply", false, true)))
|
||||
))
|
||||
);
|
||||
targetClass.addConstructor(Opcodes.ACC_PUBLIC, List.of(), new TargetBlock(List.of(new TargetMethodCall(null, new TargetSuper(TargetType.Object), List.of(), TargetType.Object, "<init>", false, false))));
|
||||
targetClass.addMethod(Opcodes.ACC_PUBLIC, "lambda", List.of(), TargetType.Integer, new TargetBlock(List.of(new TargetVarDecl(interfaceType, "by2", new TargetLambdaExpression(interfaceType, List.of(), List.of(new MethodParameter(TargetType.Integer, "num")), TargetType.Integer, new TargetBlock(List.of(new TargetReturn(new TargetBinaryOp.Mul(TargetType.Integer, new TargetLocalVar(TargetType.Integer, "num"), new TargetLiteral.IntLiteral(2))))))), new TargetReturn(new TargetCast(TargetType.Integer, new TargetMethodCall(TargetType.Object, TargetType.Object, List.of(TargetType.Object), new TargetLocalVar(interfaceType, "by2"), List.of(new TargetLiteral.IntLiteral(10)), interfaceType, "apply", false, true))))));
|
||||
var clazz = generateClass(targetClass, classLoader);
|
||||
var instance = clazz.getConstructor().newInstance();
|
||||
assertEquals(clazz.getDeclaredMethod("lambda").invoke(instance), 20);
|
||||
|
@ -20,10 +20,9 @@ import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class TestGenerics {
|
||||
|
||||
private static final String rootDirectory = System.getProperty("user.dir") + "/resources/insertGenericsJav/";
|
||||
private static final String rootDirectory = System.getProperty("user.dir") + "/src/test/resources/insertGenericsJav/";
|
||||
private static final String bytecodeDirectory = System.getProperty("user.dir") + "/src/test/resources/testBytecode/generatedBC/";
|
||||
|
||||
private record Result(List<GenericsResult> genericsResults, ClassOrInterface clazz) {
|
||||
@ -266,12 +265,7 @@ public class TestGenerics {
|
||||
|
||||
var generics = result.genericsResults.get(0);
|
||||
var AO = generics.getBounds(a.getType(), result.clazz);
|
||||
var AOBound = new BoundsList(
|
||||
new Bound(false, TypePlaceholder.of("Y")),
|
||||
new Bound(false, TypePlaceholder.of("AK")),
|
||||
new Bound(false, TypePlaceholder.of("AE")),
|
||||
new Bound(false, ASTToTargetAST.OBJECT)
|
||||
);
|
||||
var AOBound = new BoundsList(new Bound(false, TypePlaceholder.of("Y")), new Bound(false, TypePlaceholder.of("AK")), new Bound(false, TypePlaceholder.of("AE")), new Bound(false, ASTToTargetAST.OBJECT));
|
||||
assertEquals(AO, AOBound);
|
||||
|
||||
var S = generics.getBounds(setA.getParameterList().getParameterAt(0).getType(), result.clazz, setA);
|
||||
@ -288,12 +282,9 @@ public class TestGenerics {
|
||||
assertEquals(AE, new BoundsList(new Bound(false, ASTToTargetAST.OBJECT)));
|
||||
|
||||
// TODO main seems to change between runs
|
||||
/*var AE2 = generics.getBounds(main.getReturnType(), result.clazz, main);
|
||||
var AF = generics.getBounds(main.getParameterList().getParameterAt(0).getType(), result.clazz, main);
|
||||
var AG = generics.getBounds(main.getParameterList().getParameterAt(1).getType(), result.clazz, main);
|
||||
assertEquals(AE, AE2));
|
||||
assertEquals(AF, new BoundsList(new Bound(true, TypePlaceholder.of("AK")), new Bound(true, TypePlaceholder.of("AE")), new Bound(false, ASTToTargetAST.OBJECT))));
|
||||
assertEquals(AG, SChain));*/
|
||||
/*
|
||||
* var AE2 = generics.getBounds(main.getReturnType(), result.clazz, main); var AF = generics.getBounds(main.getParameterList().getParameterAt(0).getType(), result.clazz, main); var AG = generics.getBounds(main.getParameterList().getParameterAt(1).getType(), result.clazz, main); assertEquals(AE, AE2)); assertEquals(AF, new BoundsList(new Bound(true, TypePlaceholder.of("AK")), new Bound(true, TypePlaceholder.of("AE")), new Bound(false, ASTToTargetAST.OBJECT)))); assertEquals(AG, SChain));
|
||||
*/
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -23,96 +23,119 @@ import java.util.Set;
|
||||
|
||||
public class JavaTXCompilerTest {
|
||||
|
||||
public static final String rootDirectory = System.getProperty("user.dir")+"/resources/javFiles/";
|
||||
public static final String rootDirectory = System.getProperty("user.dir") + "/src/test/resources/javFiles/";
|
||||
|
||||
@Test
|
||||
public void finiteClosure() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory + "fc.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void importTest() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory + "Import.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fieldTest() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory + "FieldAccess.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lambda() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory + "Lambda.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lambda2() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory + "Lambda2.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lambda3() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory + "Lambda3.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lambdaField() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory + "LambdaField.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mathStruc() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory + "mathStruc.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generics() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory + "Generics.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void genericsMethodCall() throws IOException, ClassNotFoundException {
|
||||
TestResultSet result = execute(new File(rootDirectory + "MethodCallGenerics.jav"));
|
||||
// TODO: Hier sollte der Rückgabetyp der Methode String sein
|
||||
}
|
||||
|
||||
@Test
|
||||
public void faculty() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory + "Faculty.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void facultyIf() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory + "FacultyIf.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void facultyTyped() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory + "FacultyTyped.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matrix() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory + "Matrix.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void packageTests() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory + "Package.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void vector() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory + "Vector.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lambdaRunnable() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory + "LambdaRunnable.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void expressions() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory + "Expressions.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addLong() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory + "AddLong.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fields() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory + "Fields.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ifStatement() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory + "IfTest.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multipleSolutions() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory + "Sorting.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listenerTest() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory + "ListenerOverload.jav"));
|
||||
@ -166,12 +189,9 @@ public class JavaTXCompilerTest {
|
||||
return new TestResultSet();
|
||||
}
|
||||
|
||||
static String readFile(String path, Charset encoding)
|
||||
throws IOException
|
||||
{
|
||||
static String readFile(String path, Charset encoding) throws IOException {
|
||||
byte[] encoded = Files.readAllBytes(Paths.get(path));
|
||||
return new String(encoded, encoding);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -23,64 +23,38 @@ import java.util.Set;
|
||||
|
||||
public class Meth_GenTest {
|
||||
|
||||
public static final String rootDirectory = System.getProperty("user.dir")+"/resources/javFiles/";
|
||||
public static final String rootDirectory = System.getProperty("user.dir") + "/src/test/resources/javFiles/";
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void finiteClosure() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"fc.jav"));
|
||||
}
|
||||
@Test
|
||||
public void lambda() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"Lambda.jav"));
|
||||
}
|
||||
@Test
|
||||
public void lambda2() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"Lambda2.jav"));
|
||||
}
|
||||
@Test
|
||||
public void lambda3() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"Lambda3.jav"));
|
||||
}
|
||||
@Test
|
||||
public void mathStruc() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"mathStruc.jav"));
|
||||
}
|
||||
@Test
|
||||
public void generics() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"Generics.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void faculty() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"Faculty.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void facultyTyped() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"FacultyTyped.jav"));
|
||||
}
|
||||
* @Test public void finiteClosure() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"fc.jav")); }
|
||||
*
|
||||
* @Test public void lambda() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"Lambda.jav")); }
|
||||
*
|
||||
* @Test public void lambda2() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"Lambda2.jav")); }
|
||||
*
|
||||
* @Test public void lambda3() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"Lambda3.jav")); }
|
||||
*
|
||||
* @Test public void mathStruc() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"mathStruc.jav")); }
|
||||
*
|
||||
* @Test public void generics() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"Generics.jav")); }
|
||||
*
|
||||
* @Test public void faculty() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"Faculty.jav")); }
|
||||
*
|
||||
* @Test public void facultyTyped() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"FacultyTyped.jav")); }
|
||||
*/
|
||||
@Test
|
||||
public void matrix() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory + "Meth_Gen.jav"));
|
||||
}
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void vector() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"Vector.jav"));
|
||||
}
|
||||
@Test
|
||||
public void lambdaRunnable() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"LambdaRunnable.jav"));
|
||||
}
|
||||
@Test
|
||||
public void expressions() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"Expressions.jav"));
|
||||
}
|
||||
@Test
|
||||
public void matrixFC() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"FC_Matrix.jav"));
|
||||
}
|
||||
* @Test public void vector() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"Vector.jav")); }
|
||||
*
|
||||
* @Test public void lambdaRunnable() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"LambdaRunnable.jav")); }
|
||||
*
|
||||
* @Test public void expressions() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"Expressions.jav")); }
|
||||
*
|
||||
* @Test public void matrixFC() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"FC_Matrix.jav")); }
|
||||
*/
|
||||
private static class TestResultSet {
|
||||
|
||||
@ -130,12 +104,9 @@ public class Meth_GenTest {
|
||||
return new TestResultSet();
|
||||
}
|
||||
|
||||
static String readFile(String path, Charset encoding)
|
||||
throws IOException
|
||||
{
|
||||
static String readFile(String path, Charset encoding) throws IOException {
|
||||
byte[] encoded = Files.readAllBytes(Paths.get(path));
|
||||
return new String(encoded, encoding);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -23,63 +23,34 @@ import java.util.Set;
|
||||
|
||||
public class UnifyTest {
|
||||
|
||||
public static final String rootDirectory = System.getProperty("user.dir")+"/resources/javFiles/";
|
||||
public static final String rootDirectory = System.getProperty("user.dir") + "/src/test/resources/javFiles/";
|
||||
/*
|
||||
@Test
|
||||
public void finiteClosure() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"fc.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lambda() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"Lambda.jav"));
|
||||
}
|
||||
|
||||
* @Test public void finiteClosure() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"fc.jav")); }
|
||||
*
|
||||
* @Test public void lambda() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"Lambda.jav")); }
|
||||
*
|
||||
*/
|
||||
/*
|
||||
@Test
|
||||
public void vector() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"Vector.jav"));
|
||||
}
|
||||
* @Test public void vector() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"Vector.jav")); }
|
||||
*/
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void lambda2() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"Lambda2.jav"));
|
||||
}
|
||||
* @Test public void lambda2() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"Lambda2.jav")); }
|
||||
*/
|
||||
/*
|
||||
@Test
|
||||
public void lambda3() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"Lambda3.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lambdafield() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"LambdaField.jav"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mathStruc() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"mathStruc.jav"));
|
||||
}
|
||||
@Test
|
||||
public void generics() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"Generics.jav"));
|
||||
}
|
||||
* @Test public void lambda3() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"Lambda3.jav")); }
|
||||
*
|
||||
* @Test public void lambdafield() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"LambdaField.jav")); }
|
||||
*
|
||||
* @Test public void mathStruc() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"mathStruc.jav")); }
|
||||
*
|
||||
* @Test public void generics() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"Generics.jav")); }
|
||||
*/
|
||||
/*
|
||||
@Test
|
||||
public void faculty() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"Faculty.jav"));
|
||||
}
|
||||
* @Test public void faculty() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"Faculty.jav")); }
|
||||
*/
|
||||
/*
|
||||
@Test
|
||||
public void facultyTyped() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"FacultyTyped.jav"));
|
||||
}
|
||||
* @Test public void facultyTyped() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"FacultyTyped.jav")); }
|
||||
*/
|
||||
|
||||
@Test
|
||||
@ -89,24 +60,14 @@ public class UnifyTest {
|
||||
// compiler.generateBytecode();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void vector() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"Vector.jav"));
|
||||
}
|
||||
@Test
|
||||
public void lambdaRunnable() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"LambdaRunnable.jav"));
|
||||
}
|
||||
@Test
|
||||
public void expressions() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"Expressions.jav"));
|
||||
}
|
||||
@Test
|
||||
public void matrixFC() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"FC_Matrix.jav"));
|
||||
}
|
||||
* @Test public void vector() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"Vector.jav")); }
|
||||
*
|
||||
* @Test public void lambdaRunnable() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"LambdaRunnable.jav")); }
|
||||
*
|
||||
* @Test public void expressions() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"Expressions.jav")); }
|
||||
*
|
||||
* @Test public void matrixFC() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"FC_Matrix.jav")); }
|
||||
*/
|
||||
private static class TestResultSet {
|
||||
|
||||
@ -156,12 +117,9 @@ public class UnifyTest {
|
||||
return new TestResultSet();
|
||||
}
|
||||
|
||||
static String readFile(String path, Charset encoding)
|
||||
throws IOException
|
||||
{
|
||||
static String readFile(String path, Charset encoding) throws IOException {
|
||||
byte[] encoded = Files.readAllBytes(Paths.get(path));
|
||||
return new String(encoded, encoding);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user