mathStruc.jav hinzugefügt

This commit is contained in:
pl@gohorb.ba-horb.de 2019-08-23 15:06:54 +02:00
parent a41e9804a0
commit 82c0837d1f
5 changed files with 57 additions and 7 deletions

View File

@ -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();
}
}

View File

@ -3,9 +3,9 @@ import java.lang.Integer;
//import java.lang.Short; //import java.lang.Short;
public class Faculty { public class Faculty {
public fact; //public fact;
Faculty() { //Faculty() {
fact = (x) -> { public fact = (x) -> {
if (x == 1) { if (x == 1) {
return 1; return 1;
} }
@ -13,7 +13,7 @@ public class Faculty {
return x * (fact.apply(x-1)); return x * (fact.apply(x-1));
} }
}; };
}
public getFact(x) { public getFact(x) {

View File

@ -7,7 +7,8 @@ public class Tph3 {
// m2(a,b){ // m2(a,b){
// return m(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); } m2(y) { m1(y, y); }
} }

View File

@ -2,11 +2,11 @@ public class Tph4{
m(a,b){ m(a,b){
var c = m2(b); var c = m2(b);
var d = m2(c); var d = m2(c);
return a; return d;
} }
m2(b){ m2(b){
return b return b;
} }
} }

View File

@ -0,0 +1,11 @@
class mathStruc {
model;
//Fun1*<Fun2*<A,A,A>, Fun1*<MathStruc <A>,MathStruc <A>>>
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));
}
}