This commit is contained in:
Fayez Abu Alia 2018-08-06 13:34:34 +02:00
commit d6364040fa
3 changed files with 18 additions and 17 deletions

View File

@ -1,12 +1,13 @@
package bytecode; package bytecode;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import java.io.File; import java.io.File;
import java.lang.reflect.Method;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader; import java.net.URLClassLoader;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import de.dhbwstuttgart.core.JavaTXCompiler; import de.dhbwstuttgart.core.JavaTXCompiler;
@ -20,24 +21,21 @@ public class MergeTest {
private static String pathToClassFile; private static String pathToClassFile;
private static Object instanceOfClass; private static Object instanceOfClass;
// @BeforeClass
// public static void setUpBeforeClass() throws Exception {
// path = System.getProperty("user.dir")+"/test/bytecode/javFiles/Merge.jav";
// fileToTest = new File(path);
// compiler = new JavaTXCompiler(fileToTest);
// compiler.generateBytecode(System.getProperty("user.dir")+"/testBytecode/generatedBC/");
// pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
// loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
// classToTest = loader.loadClass("Merge");
// instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
// }
@Test @Test
public void generateBC() throws Exception{ public void generateBC() throws Exception {
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/Merge.jav"; path = System.getProperty("user.dir")+"/test/bytecode/javFiles/Merge.jav";
fileToTest = new File(path); fileToTest = new File(path);
compiler = new JavaTXCompiler(fileToTest); compiler = new JavaTXCompiler(fileToTest);
compiler.generateBytecode(System.getProperty("user.dir")+"/testBytecode/generatedBC/"); compiler.generateBytecode(System.getProperty("user.dir")+"/testBytecode/generatedBC/");
} pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass("Merge");
//instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
//Method m = classToTest.getDeclaredMethod("m");
//Object result = m.invoke(instanceOfClass);
//assertEquals(result.getClass(), loader.loadClass("Apply"));
}
} }

View File

@ -9,9 +9,12 @@ class Merge {
return a; return a;
} }
/*
sort(in){ sort(in){
var firstHalf = in.subList(1,2); var firstHalf = in.subList(1,2);
var secondHalf = in.subList(1,2); var secondHalf = in.subList(1,2);
return merge(sort(firstHalf), sort(secondHalf)); return merge(sort(firstHalf), sort(secondHalf));
} }
*/
} }

View File

@ -13,9 +13,9 @@ public class OL {
} }
public class OLMain { public class OLMain {
main(x) { main(java.lang.Integer x) {
var ol; var ol;
ol = new OL(); ol = new OL();
return ol.m(x); return ol.m(x);