new file: mathStrucVectorTest.java
new file: ../../resources/javFiles/packageTest/de/test/mathStruc.jav new file: ../../resources/javFiles/packageTest/de/test/mathStrucVector.jav new file: ../../resources/javFiles/packageTest/de/test/vectorAdd.jav
This commit is contained in:
parent
7fd03d505e
commit
c1c12fa33c
53
src/test/java/packages/mathStrucVectorTest.java
Normal file
53
src/test/java/packages/mathStrucVectorTest.java
Normal file
@ -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());
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package de.test;
|
||||
|
||||
|
||||
import java.util.Vector;
|
||||
import java.lang.Integer;
|
||||
|
||||
public class mathStruc {
|
||||
model;
|
||||
|
||||
//Fun1*<Fun2*<A,A,A>, Fun1*<MathStruc <A>,MathStruc <A>>>
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -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<Integer> v1 = new Vector<Integer>();
|
||||
v1.addElement(2);
|
||||
v1.addElement(2);
|
||||
Vector<Integer> v2 = new Vector<Integer>();
|
||||
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;
|
||||
*/
|
||||
}
|
||||
}
|
@ -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<Integer>();
|
||||
var i = 0;
|
||||
while(i < v1.size()) {
|
||||
//if (i < v2.size()) {
|
||||
ret.addElement(v1.elementAt(i) + v2.elementAt(i));
|
||||
//}
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user