diff --git a/src/test/java/bytecode/mathStrucTest.java b/src/test/java/bytecode/mathStrucTest.java new file mode 100644 index 00000000..801de468 --- /dev/null +++ b/src/test/java/bytecode/mathStrucTest.java @@ -0,0 +1,38 @@ +package bytecode; + +import static org.junit.Assert.*; + +import java.io.File; +import java.lang.reflect.Field; +import java.net.URL; +import java.net.URLClassLoader; + +import org.junit.BeforeClass; +import org.junit.Test; + +import de.dhbwstuttgart.core.JavaTXCompiler; + +public class mathStrucTest { + + private static String path; + private static File fileToTest; + private static JavaTXCompiler compiler; + private static ClassLoader loader; + private static Class classToTest; + private static String pathToClassFile; + private static Object instanceOfClass; + + + @Test + public void test() throws Exception { + path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/mathStruc.jav"; + fileToTest = new File(path); + compiler = new JavaTXCompiler(fileToTest); + 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("mathStruc"); + instanceOfClass = classToTest.getDeclaredConstructor().newInstance(); + } + +} diff --git a/src/test/resources/bytecode/javFiles/Faculty.jav b/src/test/resources/bytecode/javFiles/Faculty.jav index 78fc5130..9d1e6124 100644 --- a/src/test/resources/bytecode/javFiles/Faculty.jav +++ b/src/test/resources/bytecode/javFiles/Faculty.jav @@ -3,9 +3,9 @@ import java.lang.Integer; //import java.lang.Short; public class Faculty { - public fact; - Faculty() { - fact = (x) -> { + //public fact; + //Faculty() { + public fact = (x) -> { if (x == 1) { return 1; } @@ -13,7 +13,7 @@ public class Faculty { return x * (fact.apply(x-1)); } }; - } + public getFact(x) { diff --git a/src/test/resources/bytecode/javFiles/Tph3.jav b/src/test/resources/bytecode/javFiles/Tph3.jav index f2bcd2ef..553e2745 100644 --- a/src/test/resources/bytecode/javFiles/Tph3.jav +++ b/src/test/resources/bytecode/javFiles/Tph3.jav @@ -7,7 +7,8 @@ public class Tph3 { // m2(a,b){ // return m(a,b); // } - m1(x, y) { m2(x); x = y; } + m1(x, y) { m2(x); x = y; + } m2(y) { m1(y, y); } } diff --git a/src/test/resources/bytecode/javFiles/Tph4.jav b/src/test/resources/bytecode/javFiles/Tph4.jav index 1eb529de..58fe1d16 100644 --- a/src/test/resources/bytecode/javFiles/Tph4.jav +++ b/src/test/resources/bytecode/javFiles/Tph4.jav @@ -2,11 +2,11 @@ public class Tph4{ m(a,b){ var c = m2(b); var d = m2(c); - return a; + return d; } m2(b){ - return b + return b; } } \ No newline at end of file diff --git a/src/test/resources/bytecode/javFiles/mathStruc.jav b/src/test/resources/bytecode/javFiles/mathStruc.jav new file mode 100644 index 00000000..2a5f9816 --- /dev/null +++ b/src/test/resources/bytecode/javFiles/mathStruc.jav @@ -0,0 +1,11 @@ +class mathStruc { + model; + + //Fun1*, Fun1*,MathStruc >> + innerOp = (o) -> (ms) -> new mathStruc<>(o.apply(model,ms.model)); + + mathStruc(m) { + model =m; + //innerOp = (o) -> (ms) -> new mathStruc<>(o.apply(this.model,ms.model)); + } +} \ No newline at end of file