new file: ../../../java/AllgemeinTest.java

new file:   ../../../java/bytecode/mathStrucMatrixOPTest.java.txt
	new file:   ../../../java/bytecode/mathStrucVectorAddTest.java.txt
	new file:   ../../../java/packages/mathStrucMatrixOPTest.java.txt
	new file:   ../../AllgemeinTest/FCTest1.jav
	new file:   ../../AllgemeinTest/FCTest2.jav
	new file:   ../../AllgemeinTest/FCTest3.jav
	new file:   ../../AllgemeinTest/GenTest.jav
	new file:   ../../AllgemeinTest/Generics.jav
	new file:   ../../AllgemeinTest/OverloadingMain.jav
	new file:   ../../AllgemeinTest/Overloading_Generics.jav
	new file:   ../../AllgemeinTest/OverrideMain.jav
	new file:   ../../AllgemeinTest/OverrideMainRet.jav
	new file:   ../../AllgemeinTest/Pair.java
This commit is contained in:
pl@gohorb.ba-horb.de 2020-03-30 16:17:52 +02:00
parent 97bdfe1d3a
commit 3f919be1bf
14 changed files with 328 additions and 0 deletions

View File

@ -0,0 +1,61 @@
import static org.junit.Assert.*;
import java.io.File;
import java.lang.reflect.Field;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Arrays;
import org.junit.BeforeClass;
import org.junit.Test;
import com.google.common.collect.Lists;
import de.dhbwstuttgart.core.JavaTXCompiler;
public class AllgemeinTest {
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 {
//String className = "GenTest";
//String className = "Overloading_Generics";
//String className = "Generics";
//String className = "OverloadingMain";
//String className = "OverrideMain";
//String className = "OverrideMainRet";
//String className = "FCTest1";
//String className = "FCTest2";
//String className = "Pair";
String className = "FCTest3";
//PL 2019-10-24: genutzt fuer unterschiedliche Tests
path = System.getProperty("user.dir")+"/src/test/resources/AllgemeinTest/" + className + ".jav";
//path = System.getProperty("user.dir")+"/src/test/resources/AllgemeinTest/Overloading_Generics.jav";
//path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/mathStrucInteger.jav";
//compiler = new JavaTXCompiler(Lists.newArrayList(new File(System.getProperty("user.dir")+"/src/test/resources/AllgemeinTest/Overloading_Generics.jav")));
///*
compiler = new JavaTXCompiler(
Lists.newArrayList(new File(path)),
Lists.newArrayList(new File(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/")));
//*/
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(className);
//classToTest = loader.loadClass("Overloading_Generics");
//instanceOfClass = classToTest.getDeclaredConstructor().newInstance("A");
//classToTest = loader.loadClass("Overloading_Generics1");
//instanceOfClass = classToTest.getDeclaredConstructor(Object.class).newInstance("B");
}
}

View File

@ -0,0 +1,40 @@
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 mathStrucMatrixOPTest {
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 {
//PL 2019-10-24: laeuft nicht durch deshalb ersetzt
path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/mathStrucMatrixOp.jav";
//path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/mathStrucInteger.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("mathStrucMatrixOP");
instanceOfClass = classToTest.getDeclaredConstructor(Object.class).newInstance("A");
}
}

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 mathStrucVectorAddTest {
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/mathStrucVector.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("mathStrucVector");
//instanceOfClass = classToTest.getDeclaredConstructor(Integer.class).newInstance("A");
}
}

View File

@ -0,0 +1,51 @@
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 mathStrucMatrixOPTest extends TestCase {
public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/javFiles/packageTest/de/test/";
public mathStrucMatrixOPTest() throws ClassNotFoundException, IOException {
/*
Generate ToImport class in rootDirectory and in output-Directory
*/
/* PL 2020-01-07 kann z.Zt. nicht erzeugt werden (siehe Bug 170, http://bugzilla.ba-horb.de/show_bug.cgi?id=170)
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());
*/
JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+"MatrixOP.jav"));
compiler.typeInference();
compiler.generateBytecode(rootDirectory + "output/");
File f = new File(rootDirectory + "output/de/test/MatrixOP.class");
assertTrue(f.exists());
}
@Test
public void testSetPackageNameInBytecodeAndOutputFolder() throws IOException, ClassNotFoundException {
JavaTXCompiler compiler = new JavaTXCompiler(
Lists.newArrayList(new File(rootDirectory+"mathStrucMatrixOP.jav")),
Lists.newArrayList(new File(rootDirectory+"output/")));
compiler.typeInference();
File f = new File(rootDirectory + "output/de/test/mathStrucMatrixOP.class");
if(f.exists() && !f.isDirectory()) {
f.delete();
}
compiler.generateBytecode(rootDirectory + "output/");
f = new File(rootDirectory + "output/de/test/mathStrucMatrixOP.class");
assertTrue(f.exists());
}
}

View File

@ -0,0 +1,12 @@
import java.util.Vector;
import java.util.List;
import java.lang.Integer;
class FCTest1 extends Vector<Vector<Integer>> {
fc1() {
var y;
var z;
y.add(z);
return y;
}
}

View File

@ -0,0 +1,11 @@
import java.util.Vector;
import java.util.List;
import java.lang.Integer;
class FCTest2 extends Vector<Vector<Integer>> {
fc2(y) {
var z;
y.add(z);
return y;
}
}

View File

@ -0,0 +1,19 @@
import java.util.Vector;
import java.lang.Integer;
class FCTest3 extends Pair<Vector<Integer>, Vector<Integer>> {
fc2(x) {
x.snd().addElement(2);
}
fc2a() {
var y;
y.snd().addElement(2);
return y;
}
}

View File

@ -0,0 +1,10 @@
import java.lang.Integer;
import java.util.Vector;
public class GenTest {
main(x) {
var v = new Vector();
return 1 + v.elementAt(0);
}
}

View File

@ -0,0 +1,9 @@
class Generics {
a;
id(b) { return b; }
setA(x) {
a = x;
return a;
}
m(x,y) { x = id(y); }
}

View File

@ -0,0 +1,9 @@
import java.util.Stack;
import java.util.Vector;
class OverloadingMain {
mmMain(x) { var y; return new O1().mm(y); }
}

View File

@ -0,0 +1,20 @@
import java.lang.Integer;
public class Overloading_Generics {
id1 (x) { return x; }
//Integer id (Integer x) { return x; }
}
class Overloading_Generics1 {
main(x) {
var olg = new Overloading_Generics();
return olg.id1(1);
}
}

View File

@ -0,0 +1,25 @@
import java.util.Vector;
import java.util.Stack;
class OverrideMain {
ovrMain(x) {
var overide;
overide.ovr(x);
}
}
/*
[
[(TPH L = java.util.Stack<TPH FTM>), (TPH N = java.lang.String), (TPH M = ? extends Override2), (TPH FTN, TPH FTM), (TPH K = void)],
[(TPH FTO, TPH FTP), (TPH M = ? extends Override2), (TPH N = java.lang.String), (TPH L = java.util.Stack<TPH FTP>), (TPH K = void)],
[(TPH M = ? extends Override2), (TPH N = java.lang.String), (TPH K = void), (TPH FTR, TPH FTQ), (TPH L = java.util.Vector<TPH FTQ>)],
[(TPH FTT, TPH FTS), (TPH M = ? extends Override2), (TPH L = java.util.Vector<TPH FTS>), (TPH K = void), (TPH N = java.lang.String)],
[(TPH L = java.util.Vector<TPH FTV>), (TPH M = ? extends Override2), (TPH N = java.lang.String), (TPH FTU, TPH FTV), (TPH K = void)],
[(TPH FTX, TPH FTW), (TPH M = ? extends Override2), (TPH L = java.util.Vector<TPH FTW>), (TPH K = void), (TPH N = java.lang.String)],
[(TPH M = ? extends Override2), (TPH L = java.util.Stack<TPH FTZ>), (TPH K = void), (TPH FTY, TPH FTZ), (TPH N = java.lang.String)],
[(TPH FUB, TPH FUA), (TPH K = void), (TPH M = ? extends Override2), (TPH N = java.lang.String), (TPH L = java.util.Vector<TPH FUA>)],
[(TPH N = java.lang.String), (TPH L = java.util.Vector<TPH FUC>), (TPH FUD, TPH FUC), (TPH M = ? extends Override2), (TPH K = void)],
[(TPH N = java.lang.String), (TPH FUF, TPH FUE), (TPH M = ? extends Override2), (TPH K = void), (TPH L = java.util.Vector<TPH FUE>)]]
[[(TPH M = ? extends Override2), (TPH MNX, TPH MNY), (TPH N = java.lang.String), (TPH K = void), (TPH L = java.util.Stack<TPH MNY>)], [(TPH L = java.util.Stack<TPH MOC>), (TPH N = java.lang.String), (TPH M = ? extends Override2), (TPH K = void), (TPH MOB, TPH MOC)], [(TPH M = ? extends Override2), (TPH N = java.lang.String), (TPH MNZ, TPH MOA), (TPH L = java.util.Vector<TPH MOA>), (TPH K = void)], [(TPH L = java.util.Vector<TPH MOE>), (TPH K = void), (TPH M = ? extends Override2), (TPH MOD, TPH MOE), (TPH N = java.lang.String)], [(TPH M = ? extends Override2), (TPH K = void), (TPH N = java.lang.String), (TPH MOF, TPH MOG), (TPH L = java.util.Stack<TPH MOG>)], [(TPH L = java.util.Vector<TPH MOI>), (TPH K = void), (TPH MOH, TPH MOI), (TPH M = ? extends Override2), (TPH N = java.lang.String)], [(TPH L = java.util.Vector<TPH MOK>), (TPH MOJ, TPH MOK), (TPH K = void), (TPH M = ? extends Override2), (TPH N = java.lang.String)], [(TPH MOL, TPH MOM), (TPH L = java.util.Stack<TPH MOM>), (TPH M = ? extends Override2), (TPH K = void), (TPH N = java.lang.String)], [(TPH L = java.util.Vector<TPH MOO>), (TPH MON, TPH MOO), (TPH N = java.lang.String), (TPH K = void), (TPH M = ? extends Override2)], [(TPH L = java.util.Stack<TPH MOP>), (TPH N = java.lang.String), (TPH M = ? extends Override2), (TPH MOQ, TPH MOP), (TPH K = void)]]
*/

View File

@ -0,0 +1,11 @@
import java.util.Vector;
import java.util.Stack;
class OverrideMainRet {
ovrMain() {
var overide;
var x;
overide.ovr(x);
return x;
}
}

View File

@ -0,0 +1,12 @@
class Pair<T, U> {
T x;
U y;
public T fst () {
return x;
}
public U snd () {
return y;
}
}