diff --git a/src/test/java/packages/mathStrucVectorTest.java b/src/test/java/packages/mathStrucVectorTest.java new file mode 100644 index 00000000..d28f40ec --- /dev/null +++ b/src/test/java/packages/mathStrucVectorTest.java @@ -0,0 +1,53 @@ +package packages; + +import com.google.common.collect.Lists; +import de.dhbwstuttgart.core.JavaTXCompiler; +import junit.framework.TestCase; +import org.junit.Before; +import org.junit.Test; + +import java.io.File; +import java.io.IOException; +import java.net.URL; + +public class mathStrucVectorTest extends TestCase { + + 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 + */ + + 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()); + + compiler = new JavaTXCompiler(new File(rootDirectory+"vectorAdd.jav")); + compiler.typeInference(); + compiler.generateBytecode(rootDirectory + "output/"); + f = new File(rootDirectory + "output/de/test/vectorAdd.class"); + assertTrue(f.exists()); + + } + + @Test + public void testSetPackageNameInBytecodeAndOutputFolder() throws IOException, ClassNotFoundException { + JavaTXCompiler compiler = new JavaTXCompiler( + Lists.newArrayList(new File(rootDirectory+"mathStrucVector.jav")), + Lists.newArrayList(new URL("file://"+rootDirectory+"output/"))); + compiler.typeInference(); + File f = new File(rootDirectory + "output/de/test/mathStrucVector.class"); + if(f.exists() && !f.isDirectory()) { + f.delete(); + } + compiler.generateBytecode(rootDirectory + "output/"); + f = new File(rootDirectory + "output/de/test/mathStrucVector.class"); + assertTrue(f.exists()); + } + + +} diff --git a/src/test/resources/javFiles/packageTest/de/test/mathStruc.jav b/src/test/resources/javFiles/packageTest/de/test/mathStruc.jav new file mode 100644 index 00000000..28db5db8 --- /dev/null +++ b/src/test/resources/javFiles/packageTest/de/test/mathStruc.jav @@ -0,0 +1,18 @@ +package de.test; + + +import java.util.Vector; +import java.lang.Integer; + +public class mathStruc { + model; + + //Fun1*, Fun1*,MathStruc >> + innerOp = (o) -> (ms) -> new mathStruc<>(o.apply(model,ms.model)); + + public mathStruc(m) { + model =m; + //innerOp = (o) -> (ms) -> new mathStruc<>(o.apply(this.model,ms.model)); + } +} + diff --git a/src/test/resources/javFiles/packageTest/de/test/mathStrucVector.jav b/src/test/resources/javFiles/packageTest/de/test/mathStrucVector.jav new file mode 100644 index 00000000..b92b1b98 --- /dev/null +++ b/src/test/resources/javFiles/packageTest/de/test/mathStrucVector.jav @@ -0,0 +1,33 @@ +package de.test; + +import java.util.Vector; +import java.lang.Integer; +import java.lang.Boolean; + +import de.test.mathStruc; +import de.test.vectorAdd; + + +class mathStrucVector { + + main() { + Vector v1 = new Vector(); + v1.addElement(2); + v1.addElement(2); + Vector v2 = new Vector(); + v2.addElement(3); + v2.addElement(3); + + vectorAdd va = new vectorAdd(); + + var ms; + ms = new mathStruc<>(v1); + var ms2; + ms2 = new mathStruc<>(v2); + var ms3; + /* + ms3 = ms.innerOp.apply(va.add).apply(ms2); + return ms3; + */ + } +} diff --git a/src/test/resources/javFiles/packageTest/de/test/vectorAdd.jav b/src/test/resources/javFiles/packageTest/de/test/vectorAdd.jav new file mode 100644 index 00000000..d61ab841 --- /dev/null +++ b/src/test/resources/javFiles/packageTest/de/test/vectorAdd.jav @@ -0,0 +1,20 @@ +package de.test; + +import java.util.Vector; +import java.lang.Integer; +import java.lang.Boolean; + + +class vectorAdd { + + public add = (v1, v2) -> { + var ret = new Vector(); + var i = 0; + while(i < v1.size()) { + //if (i < v2.size()) { + ret.addElement(v1.elementAt(i) + v2.elementAt(i)); + //} + } + return ret; + }; +}