1112 lines
45 KiB
Java
1112 lines
45 KiB
Java
|
|
import de.dhbwstuttgart.environment.ByteArrayClassLoader;
|
|
import org.junit.Ignore;
|
|
import org.junit.Test;
|
|
|
|
import java.lang.reflect.*;
|
|
import java.util.AbstractList;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.Vector;
|
|
|
|
import targetast.TestCodegen;
|
|
|
|
import static org.junit.Assert.*;
|
|
import static targetast.TestCodegen.generateClassFiles;
|
|
|
|
public class TestComplete {
|
|
@Test
|
|
public void applyLambdaTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "applyLambda.jav");
|
|
var applyLambda = classFiles.get("applyLambda");
|
|
var instance = applyLambda.getDeclaredConstructor().newInstance();
|
|
var m = applyLambda.getDeclaredMethod("m");
|
|
var result = m.invoke(instance);
|
|
|
|
assertEquals(result.getClass(), classFiles.get("Apply"));
|
|
}
|
|
|
|
@Test
|
|
public void binaryTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "BinaryInMeth.jav");
|
|
var binaryInMeth = classFiles.get("BinaryInMeth");
|
|
var instance = binaryInMeth.getDeclaredConstructor().newInstance();
|
|
|
|
var m2 = binaryInMeth.getDeclaredMethod("m2", Integer.class, Integer.class);
|
|
var m3 = binaryInMeth.getDeclaredMethod("m3", Integer.class);
|
|
|
|
assertEquals(6, m2.invoke(instance, 2, 3));
|
|
assertEquals(4, m3.invoke(instance, 2));
|
|
}
|
|
|
|
@Test
|
|
public void classGenLamTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "ClassGenLam.jav");
|
|
classFiles.get("ClassGenLam").getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void facTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Fac.jav");
|
|
var fac = classFiles.get("Fac");
|
|
var instance = fac.getDeclaredConstructor().newInstance();
|
|
|
|
var getFac = fac.getDeclaredMethod("getFac", Integer.class);
|
|
// assertEquals(6, getFac.invoke(instance, 3)); TODO This could be either an Integer or a Double so this simple test fails
|
|
}
|
|
|
|
@Test
|
|
public void facultyTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Faculty.jav");
|
|
|
|
var fac = classFiles.get("Faculty");
|
|
var constructor = fac.getDeclaredConstructor();
|
|
constructor.setAccessible(true);
|
|
var instance = constructor.newInstance();
|
|
|
|
var getFact = fac.getDeclaredMethod("getFact", Integer.class);
|
|
assertEquals(6, getFact.invoke(instance, 3));
|
|
}
|
|
|
|
@Test
|
|
public void fieldTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Field.jav");
|
|
var field = classFiles.get("Field");
|
|
var instance = field.getDeclaredConstructor().newInstance();
|
|
assertEquals(1, field.getFields().length);
|
|
}
|
|
|
|
@Test
|
|
public void fieldTph2Test() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "FieldTph2.jav");
|
|
var fieldtph2 = classFiles.get("FieldTph2");
|
|
var instance = fieldtph2.getDeclaredConstructor().newInstance();
|
|
|
|
var a = fieldtph2.getDeclaredField("a");
|
|
var m2 = fieldtph2.getDeclaredMethod("m2", Object.class);
|
|
m2.invoke(instance, 1);
|
|
|
|
var m = fieldtph2.getDeclaredMethod("m", Object.class);
|
|
assertEquals(1, m.invoke(instance, 1));
|
|
}
|
|
|
|
@Test
|
|
public void fieldTphConsMethTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "FieldTphConsMeth.jav");
|
|
var fieldTphConsMeth = classFiles.get("FieldTphConsMeth");
|
|
|
|
var ctor = fieldTphConsMeth.getDeclaredConstructor(Object.class);
|
|
var instance = ctor.newInstance("C");
|
|
var a = fieldTphConsMeth.getDeclaredField("a");
|
|
var id = fieldTphConsMeth.getDeclaredMethod("id", Object.class);
|
|
|
|
assertEquals(42, id.invoke(instance, 42));
|
|
assertEquals("C", a.get(instance));
|
|
}
|
|
|
|
@Test
|
|
public void fieldTphMMethTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "FieldTphMMeth.jav");
|
|
var fieldTphMMeth = classFiles.get("FieldTphMMeth");
|
|
var ctor = fieldTphMMeth.getDeclaredConstructor(Object.class, Object.class, Boolean.class);
|
|
|
|
var instance1 = ctor.newInstance("C", 42, true);
|
|
var instance2 = ctor.newInstance("C", 42, false);
|
|
|
|
var m = fieldTphMMeth.getDeclaredMethod("m", Object.class, Object.class, Boolean.class);
|
|
assertEquals(42, m.invoke(instance1, "C", 42, false));
|
|
|
|
var a = fieldTphMMeth.getDeclaredField("a");
|
|
assertEquals("C", a.get(instance1));
|
|
assertEquals(42, a.get(instance2));
|
|
}
|
|
|
|
@Test
|
|
public void genTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Gen.jav");
|
|
}
|
|
|
|
@Test
|
|
public void idTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Id.jav");
|
|
var instance = classFiles.get("Id").getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void infTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Inf.jav");
|
|
var instance = classFiles.get("Inf").getDeclaredConstructor().newInstance();
|
|
// TODO check generics
|
|
}
|
|
|
|
@Test
|
|
public void kompTphTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "KompTph.jav");
|
|
var instance = classFiles.get("KompTph").getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void lambdaCaptureTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "LambdaCapture.jav");
|
|
var instance = classFiles.get("LambdaCapture").getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void lambdaTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Lambda.jav");
|
|
var classToTest = classFiles.get("Lambda");
|
|
var instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
|
|
|
var m = classToTest.getDeclaredMethod("m");
|
|
var lambda = m.invoke(instanceOfClass).getClass();
|
|
var apply = lambda.getMethod("apply", Object.class);
|
|
apply.setAccessible(true);
|
|
|
|
var i = Integer.valueOf(77);
|
|
assertEquals(i, apply.invoke(m.invoke(instanceOfClass), i));
|
|
}
|
|
|
|
@Test
|
|
public void mathStrucInteger() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "mathStrucInteger.jav");
|
|
var mathStrucInteger = classFiles.get("mathStrucInteger");
|
|
mathStrucInteger.getDeclaredConstructor(Integer.class).newInstance(10);
|
|
}
|
|
|
|
@Test
|
|
public void mathStruc() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "mathStruc.jav");
|
|
var mathStruc = classFiles.get("mathStruc");
|
|
mathStruc.getDeclaredConstructor(Object.class).newInstance("A");
|
|
}
|
|
|
|
@Test
|
|
//@Ignore()
|
|
public void matrixOpTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "MatrixOP.jav");
|
|
var matrixOP = classFiles.get("MatrixOP");
|
|
|
|
Vector<Vector<Integer>> vv = new Vector<>();
|
|
Vector<Integer> v1 = new Vector<>();
|
|
v1.addElement(2);
|
|
v1.addElement(2);
|
|
Vector<Integer> v2 = new Vector<>();
|
|
v2.addElement(3);
|
|
v2.addElement(3);
|
|
vv.addElement(v1);
|
|
vv.addElement(v2);
|
|
|
|
var instanceOfClass_m1 = matrixOP.getDeclaredConstructor(Vector.class).newInstance(vv);
|
|
|
|
Vector<Vector<Integer>> vv1 = new Vector<>();
|
|
Vector<Integer> v3 = new Vector<>();
|
|
v3.addElement(2);
|
|
v3.addElement(2);
|
|
Vector<Integer> v4 = new Vector<>();
|
|
v4.addElement(3);
|
|
v4.addElement(3);
|
|
vv1.addElement(v3);
|
|
vv1.addElement(v4);
|
|
|
|
var instanceOfClass_m2 = matrixOP.getDeclaredConstructor(Vector.class).newInstance(vv1);// Matrix m2 = new Matrix(vv1);
|
|
|
|
var mul = matrixOP.getField("mul");
|
|
mul.setAccessible(true);
|
|
|
|
var lambda = mul.get(instanceOfClass_m1).getClass();
|
|
var apply = lambda.getMethod("apply", Object.class, Object.class);
|
|
apply.setAccessible(true);
|
|
|
|
var result = apply.invoke(mul.get(instanceOfClass_m1), instanceOfClass_m1, instanceOfClass_m2);
|
|
System.out.println(instanceOfClass_m1.toString() + " * " + instanceOfClass_m2.toString() + " = " + result.toString());
|
|
|
|
Vector<Vector<Integer>> res = new Vector<>();
|
|
Vector<Integer> v5 = new Vector<>();
|
|
v5.addElement(10);
|
|
v5.addElement(10);
|
|
Vector<Integer> v6 = new Vector<>();
|
|
v6.addElement(15);
|
|
v6.addElement(15);
|
|
res.addElement(v5);
|
|
res.addElement(v6);
|
|
|
|
var instanceOfClass_m3 = matrixOP.getDeclaredConstructor(Vector.class).newInstance(res);
|
|
assertEquals(result, instanceOfClass_m3);
|
|
}
|
|
|
|
@Test
|
|
//@Ignore("This is too complex")
|
|
public void matrixTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Matrix.jav");
|
|
var matrix = classFiles.get("Matrix");
|
|
|
|
Vector<Vector<Integer>> vv = new Vector<>();
|
|
Vector<Integer> v1 = new Vector<>();
|
|
v1.addElement(2);
|
|
v1.addElement(2);
|
|
Vector<Integer> v2 = new Vector<>();
|
|
v2.addElement(3);
|
|
v2.addElement(3);
|
|
vv.addElement(v1);
|
|
vv.addElement(v2);
|
|
|
|
var instanceOfClass_m1 = matrix.getDeclaredConstructor(Vector.class).newInstance(vv);
|
|
|
|
Vector<Vector<Integer>> vv1 = new Vector<>();
|
|
Vector<Integer> v3 = new Vector<>();
|
|
v3.addElement(2);
|
|
v3.addElement(2);
|
|
Vector<Integer> v4 = new Vector<>();
|
|
v4.addElement(3);
|
|
v4.addElement(3);
|
|
vv1.addElement(v3);
|
|
vv1.addElement(v4);
|
|
|
|
var instanceOfClass_m2 = matrix.getDeclaredConstructor(Vector.class).newInstance(vv1);
|
|
|
|
var mul = matrix.getDeclaredMethod("mul", List.class);
|
|
var result = mul.invoke(instanceOfClass_m1, instanceOfClass_m2);
|
|
System.out.println(instanceOfClass_m1.toString() + " * " + instanceOfClass_m2.toString() + " = " + result.toString());
|
|
|
|
Vector<Vector<Integer>> res = new Vector<>();
|
|
Vector<Integer> v5 = new Vector<>();
|
|
v5.addElement(10);
|
|
v5.addElement(10);
|
|
Vector<Integer> v6 = new Vector<>();
|
|
v6.addElement(15);
|
|
v6.addElement(15);
|
|
res.addElement(v5);
|
|
res.addElement(v6);
|
|
|
|
var instanceOfClass_m3 = matrix.getDeclaredConstructor(Vector.class).newInstance(res);
|
|
assertEquals(result, instanceOfClass_m3);
|
|
}
|
|
|
|
@Test
|
|
public void scalarTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Scalar.jav");
|
|
var scalar = classFiles.get("Scalar");
|
|
|
|
Vector<Vector<Integer>> vv = new Vector<>();
|
|
Vector<Integer> v1 = new Vector<>();
|
|
v1.addElement(2);
|
|
v1.addElement(2);
|
|
|
|
var instanceOfClass_s1 = scalar.getDeclaredConstructor(Vector.class).newInstance(v1);
|
|
|
|
Vector<Integer> v2 = new Vector<>();
|
|
v2.addElement(2);
|
|
v2.addElement(2);
|
|
|
|
var instanceOfClass_s2 = scalar.getDeclaredConstructor(Vector.class).newInstance(v2);
|
|
|
|
var mul = scalar.getDeclaredMethod("mul", Vector.class);
|
|
var result = mul.invoke(instanceOfClass_s1, instanceOfClass_s2);
|
|
System.out.println(instanceOfClass_s1.toString() + " * " + instanceOfClass_s2.toString() + " = " + result.toString());
|
|
|
|
assertEquals(result, 8);
|
|
}
|
|
|
|
@Test
|
|
public void mergeTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Merge.jav");
|
|
var instance = classFiles.get("Merge").getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void overloadingSortingTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Sorting.jav");
|
|
var instance = classFiles.get("Sorting").getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void overloadingTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Overloading.jav");
|
|
var overloading = classFiles.get("Overloading");
|
|
var overloading2 = classFiles.get("Overloading2");
|
|
var instance1 = overloading.getDeclaredConstructor().newInstance();
|
|
var instance2 = overloading2.getDeclaredConstructor().newInstance();
|
|
|
|
var m1 = overloading.getDeclaredMethod("test", overloading);
|
|
assertEquals("Overloading", m1.invoke(instance1, instance1));
|
|
var m2 = overloading.getDeclaredMethod("test", overloading2);
|
|
assertEquals("Overloading2", m2.invoke(instance1, instance2));
|
|
}
|
|
|
|
@Test
|
|
public void plusTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Plus.jav");
|
|
var plus = classFiles.get("Plus");
|
|
var instance = plus.getDeclaredConstructor().newInstance();
|
|
|
|
var addInt = plus.getDeclaredMethod("m", Integer.class, Integer.class);
|
|
assertEquals(10, addInt.invoke(instance, 7, 3));
|
|
|
|
var addString = plus.getDeclaredMethod("m", String.class, String.class);
|
|
assertEquals("ByteCode", addString.invoke(instance, "Byte", "Code"));
|
|
}
|
|
|
|
@Test
|
|
public void relOpsTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "RelOps.jav");
|
|
var relOps = classFiles.get("RelOps");
|
|
var instance = relOps.getDeclaredConstructor().newInstance();
|
|
|
|
var m = relOps.getDeclaredMethod("m", Integer.class, Integer.class);
|
|
assertFalse((Boolean) m.invoke(instance, 7, 3));
|
|
}
|
|
|
|
@Test
|
|
public void simpleCyclesTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "SimpleCycle.jav");
|
|
var instance = classFiles.get("SimpleCycle").getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void subMatTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "SubMatrix.jav");
|
|
var instance = classFiles.get("SubMatrix").getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void tphTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Tph.jav");
|
|
var tph = classFiles.get("Tph");
|
|
var instance = tph.getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void tph2Test() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Tph2.jav");
|
|
var tph2 = classFiles.get("Tph2");
|
|
var instance = tph2.getDeclaredConstructor().newInstance();
|
|
|
|
assertEquals(1, tph2.getTypeParameters().length);
|
|
// public class Tph2<DZG>
|
|
var DZG = tph2.getTypeParameters()[0];
|
|
|
|
var id = tph2.getDeclaredField("id");
|
|
// public Fun1$$<DZG, DZG> id
|
|
var idParams = ((ParameterizedType) id.getGenericType()).getActualTypeArguments();
|
|
assertEquals(2, idParams.length);
|
|
assertEquals(DZG, idParams[0]);
|
|
assertEquals(DZG, idParams[1]);
|
|
|
|
var id3 = tph2.getDeclaredMethod("id3", Object.class);
|
|
// public <U extends DZG> DZG id3(U var1)
|
|
var paraTypes = id3.getGenericParameterTypes();
|
|
var typeParaTypes = id3.getTypeParameters();
|
|
|
|
var U = Arrays.stream(typeParaTypes).filter(t -> t.equals(paraTypes[0])).findFirst().get();
|
|
assertEquals(DZG, U.getBounds()[0]);
|
|
assertEquals(DZG, id3.getGenericReturnType());
|
|
}
|
|
|
|
@Test
|
|
public void tph3Test() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Tph3.jav");
|
|
var tph3 = classFiles.get("Tph3");
|
|
var instance = tph3.getDeclaredConstructor().newInstance();
|
|
var m1 = tph3.getDeclaredMethod("m1", Object.class, Object.class);
|
|
|
|
// public <DXBE extends DXBD, DXBD> void m1(DXBD var1, DXBE var2)
|
|
var paraTypes = m1.getGenericParameterTypes();
|
|
var typeParaTypes = m1.getTypeParameters();
|
|
|
|
var DXBD = Arrays.stream(typeParaTypes).filter(t -> t.equals(paraTypes[0])).findFirst().get();
|
|
assertEquals(Object.class, DXBD.getBounds()[0]);
|
|
var DXBE = Arrays.stream(typeParaTypes).filter(t -> t.equals(paraTypes[1])).findFirst().get();
|
|
assertEquals(DXBD, DXBE.getBounds()[0]);
|
|
|
|
var m2 = tph3.getDeclaredMethod("m2", Object.class);
|
|
|
|
// public <V> void m2(V var1)
|
|
var paraTypes2 = m2.getGenericParameterTypes();
|
|
var typeParaTypes2 = m2.getTypeParameters();
|
|
|
|
var V = Arrays.stream(typeParaTypes2).filter(t -> t.equals(paraTypes2[0])).findFirst().get();
|
|
assertEquals(Object.class, V.getBounds()[0]);
|
|
}
|
|
|
|
@Test
|
|
public void tph4Test() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Tph4.jav");
|
|
var tph4 = classFiles.get("Tph4");
|
|
var instance = tph4.getDeclaredConstructor().newInstance();
|
|
var m = tph4.getDeclaredMethod("m", Object.class, Object.class);
|
|
|
|
// public <N, O> N m(O var1, N var2) {
|
|
var paraTypes = m.getGenericParameterTypes();
|
|
var typeParaTypes = m.getTypeParameters();
|
|
|
|
var N = Arrays.stream(typeParaTypes).filter(t -> t.equals(m.getGenericReturnType())).findFirst().get();
|
|
assertEquals(Object.class, N.getBounds()[0]);
|
|
|
|
var O = Arrays.stream(typeParaTypes).filter(t -> t.equals(paraTypes[0])).findFirst().get();
|
|
var N2 = Arrays.stream(typeParaTypes).filter(t -> t.equals(paraTypes[1])).findFirst().get();
|
|
assertEquals(N, N2);
|
|
assertEquals(N.getBounds()[0], Object.class);
|
|
assertEquals(O.getBounds()[0], Object.class);
|
|
|
|
var m2 = tph4.getDeclaredMethod("m2", Object.class);
|
|
|
|
// public <X> X m2(X var1)
|
|
var paraTypes2 = m2.getGenericParameterTypes();
|
|
var typeParaTypes2 = m2.getTypeParameters();
|
|
|
|
var X = Arrays.stream(typeParaTypes2).filter(t -> t.equals(paraTypes2[0])).findFirst().get();
|
|
assertEquals(Object.class, X.getBounds()[0]);
|
|
assertEquals(X, m2.getGenericReturnType());
|
|
}
|
|
|
|
@Test
|
|
public void tph5Test() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Tph5.jav");
|
|
var tph5 = classFiles.get("Tph5");
|
|
var instance = tph5.getDeclaredConstructor().newInstance();
|
|
var m = tph5.getDeclaredMethod("m", Object.class, Object.class);
|
|
|
|
// public <N, O extends N> void m(N var1, O var2)
|
|
var paraTypes = m.getGenericParameterTypes();
|
|
var typeParaTypes = m.getTypeParameters();
|
|
|
|
var N = Arrays.stream(typeParaTypes).filter(t -> t.equals(paraTypes[0])).findFirst().get();
|
|
var O = Arrays.stream(typeParaTypes).filter(t -> t.equals(paraTypes[1])).findFirst().get();
|
|
|
|
assertEquals(O.getBounds()[0], N);
|
|
assertEquals(Object.class, N.getBounds()[0]);
|
|
|
|
var m2 = tph5.getDeclaredMethod("m2", Object.class);
|
|
|
|
// public <R> R m2(R var1)
|
|
var paraTypes2 = m2.getGenericParameterTypes();
|
|
var typeParaTypes2 = m2.getTypeParameters();
|
|
|
|
var R = Arrays.stream(typeParaTypes2).filter(t -> t.equals(paraTypes2[0])).findFirst().get();
|
|
assertEquals(Object.class, R.getBounds()[0]);
|
|
assertEquals(R, m2.getGenericReturnType());
|
|
}
|
|
|
|
@Test
|
|
public void tph6Test() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Tph6.jav");
|
|
var tph5 = classFiles.get("Tph6");
|
|
var instance = tph5.getDeclaredConstructor().newInstance();
|
|
var m = tph5.getDeclaredMethod("m", Object.class, Object.class);
|
|
|
|
// public <P, O> void m(O var1, P var2)
|
|
var paraTypes = m.getGenericParameterTypes();
|
|
var typeParaTypes = m.getTypeParameters();
|
|
|
|
var P = Arrays.stream(typeParaTypes).filter(t -> t.equals(paraTypes[0])).findFirst().get();
|
|
var O = Arrays.stream(typeParaTypes).filter(t -> t.equals(paraTypes[1])).findFirst().get();
|
|
|
|
assertEquals(P.getBounds()[0], Object.class);
|
|
assertEquals(O.getBounds()[0], Object.class);
|
|
|
|
var m2 = tph5.getDeclaredMethod("m2", Object.class);
|
|
|
|
// public <W> W m2(W var1)
|
|
var paraTypes2 = m2.getGenericParameterTypes();
|
|
var typeParaTypes2 = m2.getTypeParameters();
|
|
|
|
var W = Arrays.stream(typeParaTypes2).filter(t -> t.equals(paraTypes2[0])).findFirst().get();
|
|
assertEquals(Object.class, W.getBounds()[0]);
|
|
assertEquals(W, m2.getGenericReturnType());
|
|
}
|
|
|
|
@Test
|
|
public void Tph7Test() throws Exception {
|
|
var classFiles = TestCodegen.generateClassFiles(new ByteArrayClassLoader(), "Tph7.jav");
|
|
var classToTest = classFiles.get("Tph7");
|
|
var instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
|
|
|
// public <N, O> N m(O var1, N var2)
|
|
Method m = classToTest.getDeclaredMethod("m", Object.class, Object.class);
|
|
|
|
// System.out.println(m.toString());
|
|
|
|
// Argumenttypes of the method m
|
|
var paraTypes = m.getGenericParameterTypes();
|
|
|
|
// Typeparameters of the method m
|
|
var typeParaTypes = m.getTypeParameters();
|
|
|
|
// Typeparameters are extracted from the argumenttypes
|
|
// Conditions for the extracted typeparameters are set
|
|
|
|
// paraTypes[0] = O
|
|
var boundFstArg = Arrays.stream(typeParaTypes).filter(x -> x.equals(paraTypes[0])).findFirst().get().getBounds();
|
|
|
|
// Bound of O has to be Object
|
|
assertEquals(Object.class, Arrays.stream(boundFstArg).findFirst().get());
|
|
|
|
// paraTypes[1] = N
|
|
var N = Arrays.stream(typeParaTypes).filter(x -> x.equals(paraTypes[1])).findFirst().get();
|
|
var boundSndArg = N.getBounds();
|
|
|
|
// Bound of H has to be Object
|
|
assertEquals(Object.class, Arrays.stream(boundSndArg).findFirst().get());
|
|
|
|
// N has to be the return type of m
|
|
assertEquals(N, m.getGenericReturnType());
|
|
|
|
// public <DZU> DZU m2(DZU);
|
|
Method m2 = classToTest.getDeclaredMethod("m2", Object.class);
|
|
|
|
// Argumenttypes of the method m2
|
|
var paraTypesm2 = m2.getGenericParameterTypes();
|
|
|
|
// Typeparameters of the method m2
|
|
var typeParaTypesm2 = m2.getTypeParameters();
|
|
|
|
// Typeparameters are extracted from the argumenttypes
|
|
// Conditions for the extracted typeparameters are set
|
|
|
|
// paraTypes[0] = DZU
|
|
var fstArgm2 = Arrays.stream(typeParaTypesm2).filter(x -> x.equals(paraTypesm2[0])).findFirst().get();
|
|
|
|
// Bound of DZU has to be Object
|
|
assertEquals(Object.class, Arrays.stream(fstArgm2.getBounds()).findFirst().get());
|
|
|
|
// DZU has to be the return type of m
|
|
assertEquals(fstArgm2, m2.getGenericReturnType());
|
|
}
|
|
|
|
@Test
|
|
public void testTXGenerics() throws Exception {
|
|
var classLoader = new ByteArrayClassLoader();
|
|
generateClassFiles(classLoader, "Cycle.jav");
|
|
var classFiles = generateClassFiles(classLoader, "TXGenerics.jav");
|
|
var instance = classFiles.get("TXGenerics").getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void typedIdTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "TypedID.jav");
|
|
var instance = classFiles.get("TypedID").getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void vectorAddTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "VectorAdd.jav");
|
|
var instance = classFiles.get("VectorAdd").getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void vectorSuperTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "VectorSuper.jav");
|
|
var instance = classFiles.get("VectorSuper").getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void yTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Y.jav");
|
|
var instance = classFiles.get("Y").getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
@Ignore("This one isn't working")
|
|
public void boxTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Box.jav");
|
|
var instance = classFiles.get("Box_Main").getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void cycleTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Cycle.jav");
|
|
var instance = classFiles.get("Cycle").getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void olFunTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "OLFun.jav");
|
|
var instance = classFiles.get("OLFun").getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void olFun2Test() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "OLFun2.jav");
|
|
var instance = classFiles.get("OLFun2").getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void pairTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Pair.jav");
|
|
var instance = classFiles.get("Pair").getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void olTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "OL.jav");
|
|
var instance = classFiles.get("OL").getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void recordTest() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "RecordTest.jav");
|
|
var clazz = classFiles.get("RecordTest");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
assertTrue((Boolean) clazz.getDeclaredMethod("doesEqual").invoke(instance));
|
|
assertFalse((Boolean) clazz.getDeclaredMethod("doesNotEqual").invoke(instance));
|
|
System.out.println(clazz.getDeclaredMethod("hashCode").invoke(instance));
|
|
System.out.println(clazz.getDeclaredMethod("toString").invoke(instance));
|
|
}
|
|
|
|
@Test
|
|
public void testSwitch() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Switch.jav");
|
|
var clazz = classFiles.get("Switch");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
var swtch = clazz.getDeclaredMethod("main", Object.class);
|
|
|
|
var record = classFiles.get("Rec");
|
|
var ctor = record.getDeclaredConstructor(Integer.class, Object.class);
|
|
var r1 = ctor.newInstance(10, 20);
|
|
var r2 = ctor.newInstance(10, 20f);
|
|
var r3 = ctor.newInstance(10, r1);
|
|
|
|
assertEquals(swtch.invoke(instance, r1), 30);
|
|
assertEquals(swtch.invoke(instance, r2), 20);
|
|
assertEquals(swtch.invoke(instance, r3), 40);
|
|
assertEquals(swtch.invoke(instance, 50), 50);
|
|
assertEquals(swtch.invoke(instance, "Some string"), 0);
|
|
}
|
|
|
|
@Ignore("Not implemented")
|
|
@Test
|
|
public void testSwitch2() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Switch2.jav");
|
|
var clazz = classFiles.get("Switch2");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void testStringSwitch() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "SwitchString.jav");
|
|
var clazz = classFiles.get("SwitchString");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
var main = clazz.getDeclaredMethod("main", String.class);
|
|
|
|
assertEquals(main.invoke(instance, "AaAaAa"), 1);
|
|
assertEquals(main.invoke(instance, "AaAaBB"), 2);
|
|
assertEquals(main.invoke(instance, "test"), 3);
|
|
assertEquals(main.invoke(instance, "TEST"), 3);
|
|
assertEquals(main.invoke(instance, "awawa"), 4);
|
|
}
|
|
|
|
@Test
|
|
public void testInstanceOfPattern() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "InstanceOf.jav");
|
|
var clazz = classFiles.get("InstanceOf");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Ignore("Not implemented")
|
|
@Test
|
|
public void testOverloadPattern() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "OverloadPattern.jav");
|
|
var clazz = classFiles.get("OverloadPattern");
|
|
var rec = classFiles.get("Point");
|
|
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
var m1 = clazz.getDeclaredMethod("m", rec);
|
|
var m2 = clazz.getDeclaredMethod("m", Integer.class);
|
|
|
|
var pt = rec.getDeclaredConstructor(Number.class, Number.class).newInstance(10, 20);
|
|
assertEquals(m1.invoke(instance, pt), 30);
|
|
assertEquals(m2.invoke(instance, 10), 10);
|
|
}
|
|
|
|
@Test
|
|
public void testInterfaces() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Interfaces.jav");
|
|
var clazz = classFiles.get("Interfaces");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
}
|
|
@Test
|
|
public void testStatic() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Static.jav");
|
|
var clazz = classFiles.get("Static");
|
|
var m = clazz.getDeclaredMethod("m");
|
|
assertEquals(m.invoke(null), 50);
|
|
}
|
|
|
|
@Test
|
|
public void testFor() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "For.jav");
|
|
var clazz = classFiles.get("For");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
var m = clazz.getDeclaredMethod("m", Integer.class);
|
|
assertEquals(m.invoke(instance, 10), 60);
|
|
}
|
|
|
|
@Test
|
|
public void testForEach() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "ForEach.jav");
|
|
var clazz = classFiles.get("ForEach");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
var m = clazz.getDeclaredMethod("m");
|
|
assertEquals(m.invoke(instance), 6);
|
|
}
|
|
|
|
@Test
|
|
public void testLambdaRunnable() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "LambdaRunnable.jav");
|
|
var clazz = classFiles.get("LambdaRunnable");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
//var m = clazz.getDeclaredMethod("m", Integer.class);
|
|
//assertEquals(m.invoke(instance, 10), 60);
|
|
}
|
|
|
|
@Test
|
|
public void testFunctionalInterface() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "FunctionalInterface.jav");
|
|
var clazz = classFiles.get("FunctionalInterface");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
var m = clazz.getDeclaredMethod("m");
|
|
assertEquals(m.invoke(instance), 200);
|
|
}
|
|
|
|
@Test
|
|
public void testChain() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Chain.jav");
|
|
var clazz = classFiles.get("Chain");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
var m = clazz.getDeclaredMethod("m");
|
|
assertEquals(m.invoke(instance), 5);
|
|
}
|
|
|
|
@Test
|
|
public void testHelloWorld() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "HelloWorld.jav");
|
|
var clazz = classFiles.get("HelloWorld");
|
|
var hello = clazz.getDeclaredMethod("hello");
|
|
hello.invoke(null);
|
|
}
|
|
|
|
@Test
|
|
public void testSuperCall() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "SuperCall.jav");
|
|
var clazz = classFiles.get("SuperCall");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void testInstanceOf() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "InstanceOf.jav");
|
|
var clazz = classFiles.get("InstanceOf");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
|
|
assertTrue((Boolean) clazz.getDeclaredMethod("test1").invoke(instance));
|
|
assertTrue((Boolean) clazz.getDeclaredMethod("test2").invoke(instance));
|
|
assertFalse((Boolean) clazz.getDeclaredMethod("test3").invoke(instance));
|
|
}
|
|
|
|
@Test
|
|
public void testExceptions() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Exceptions.jav");
|
|
var clazz = classFiles.get("Exceptions");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
|
|
try {
|
|
clazz.getDeclaredMethod("m").invoke(instance);
|
|
fail("No exception thrown!");
|
|
} catch (InvocationTargetException exception) {
|
|
var exc = exception.getTargetException();
|
|
if (!(exc instanceof RuntimeException rexp) || !rexp.getMessage().equals("Some Exception")) {
|
|
fail("Wrong exception thrown!");
|
|
}
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void testLiteral() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Literal.jav");
|
|
var clazz = classFiles.get("Literal");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
|
|
assertNull(clazz.getDeclaredMethod("m").invoke(instance));
|
|
assertEquals(clazz.getDeclaredMethod("m2").invoke(instance), 'C');
|
|
assertEquals(clazz.getDeclaredMethod("m3").invoke(instance), 10L);
|
|
assertEquals(clazz.getDeclaredMethod("m4").invoke(instance), 10.5F);
|
|
}
|
|
|
|
@Test
|
|
public void testOLConstructor() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "OLConstructor.jav");
|
|
var clazz = classFiles.get("Child");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
assertEquals(clazz.getSuperclass().getDeclaredField("x").get(instance), 3);
|
|
}
|
|
|
|
@Test
|
|
public void testOperators() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Op1.jav");
|
|
var clazz = classFiles.get("Op1");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
assertEquals(clazz.getDeclaredMethod("not").invoke(instance), true);
|
|
assertEquals(clazz.getDeclaredMethod("or").invoke(instance), 10 | 20);
|
|
assertEquals(clazz.getDeclaredMethod("and").invoke(instance), 10 & 20);
|
|
assertEquals(clazz.getDeclaredMethod("xor").invoke(instance), 10 ^ 20);
|
|
assertEquals(clazz.getDeclaredMethod("mod").invoke(instance), 10 % 2);
|
|
}
|
|
|
|
@Ignore("Not implemented")
|
|
@Test
|
|
public void testStringConcat() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Op2.jav");
|
|
var clazz = classFiles.get("Op2");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void testLamRunnable() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "LamRunnable.jav");
|
|
var clazz = classFiles.get("LamRunnable");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void testAccess() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Access.jav");
|
|
var clazzPublic = classFiles.get("Access");
|
|
var clazzDefault = classFiles.get("AccessDefault");
|
|
|
|
assertEquals(clazzPublic.getModifiers(), Modifier.PUBLIC);
|
|
assertEquals(clazzDefault.getModifiers(), 0);
|
|
|
|
assertEquals(clazzPublic.getDeclaredMethod("mPublic").getModifiers(), Modifier.PUBLIC);
|
|
assertEquals(clazzPublic.getDeclaredMethod("mProtected").getModifiers(), Modifier.PROTECTED);
|
|
assertEquals(clazzPublic.getDeclaredMethod("mDefault").getModifiers(), 0);
|
|
assertEquals(clazzPublic.getDeclaredMethod("mPrivate").getModifiers(), Modifier.PRIVATE);
|
|
|
|
assertEquals(clazzPublic.getDeclaredField("fPublic").getModifiers(), Modifier.PUBLIC);
|
|
assertEquals(clazzPublic.getDeclaredField("fProtected").getModifiers(), Modifier.PROTECTED);
|
|
assertEquals(clazzPublic.getDeclaredField("fDefault").getModifiers(), 0);
|
|
assertEquals(clazzPublic.getDeclaredField("fPrivate").getModifiers(), Modifier.PRIVATE);
|
|
}
|
|
|
|
@Test
|
|
public void testTypeCast() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "TypeCast.jav");
|
|
var clazz = classFiles.get("TypeCast");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void testAnnotation() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Annotation.jav");
|
|
var clazz = classFiles.get("Annotation");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void testWilcards() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Wildcards.jav");
|
|
var clazz = classFiles.get("Wildcards");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void testOverrideEquals() throws Exception {
|
|
var loader = new ByteArrayClassLoader();
|
|
loader.loadClass(TestCodegen.path.resolve("OverrideRoot.class"));
|
|
var classFiles = generateClassFiles(loader, "OverrideEquals.jav");
|
|
var clazz = classFiles.get("OverrideEquals");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void testTernary() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Ternary.jav");
|
|
var clazz = classFiles.get("Ternary");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
assertEquals(clazz.getDeclaredMethod("main", Integer.class).invoke(instance, 5), "small");
|
|
}
|
|
|
|
@Test
|
|
public void testBug122() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug122.jav");
|
|
var clazz = classFiles.get("Bug122");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void testBug123() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug123.jav");
|
|
var clazz = classFiles.get("Bug123");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void testBug125() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug125.jav");
|
|
var clazz = classFiles.get("Bug125");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void testBug112() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug112.jav");
|
|
var clazz = classFiles.get("Bug112");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void testBug285() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug285.jav");
|
|
var clazz = classFiles.get("Bug285");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void testBug290() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug290A.jav");
|
|
var clazz = classFiles.get("Bug290A");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void testBug293() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug293.jav");
|
|
var clazz = classFiles.get("Bug293");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void testBug295() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug295.jav");
|
|
var clazz = classFiles.get("Bug295");
|
|
var instance = clazz.getDeclaredConstructor(Integer.class, Integer.class, Integer.class).newInstance(1, 2, 3);
|
|
assertEquals(clazz.getDeclaredField("a").get(instance), 1);
|
|
assertEquals(clazz.getDeclaredField("b").get(instance), 2);
|
|
assertEquals(clazz.getDeclaredField("c").get(instance), 3);
|
|
}
|
|
|
|
@Test
|
|
public void testBug296() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug296.jav");
|
|
var clazz = classFiles.get("Bug296");
|
|
clazz.getDeclaredMethod("m1").invoke(null);
|
|
}
|
|
|
|
@Test
|
|
public void testBug297() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug297.jav");
|
|
var clazz = classFiles.get("Bug297");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
clazz.getDeclaredMethod("exec").invoke(instance);
|
|
}
|
|
|
|
@Test
|
|
public void testBug298() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug298.jav");
|
|
var clazz = classFiles.get("Bug298");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void testBug300() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug300.jav");
|
|
var clazz = classFiles.get("Bug300");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
assertEquals(clazz.getDeclaredMethod("m").invoke(instance), "Base");
|
|
}
|
|
|
|
@Test
|
|
public void testBug301() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug301.jav");
|
|
var clazz = classFiles.get("Bug301");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void testBug302() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug302.jav");
|
|
var clazz = classFiles.get("Bug302");
|
|
clazz.getDeclaredMethod("m").invoke(null);
|
|
}
|
|
|
|
@Test
|
|
public void testBug306() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug306.jav");
|
|
var clazz = classFiles.get("Bug306");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void testBug307() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug307.jav");
|
|
var clazz = classFiles.get("Bug307");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
clazz.getDeclaredMethod("main").invoke(instance);
|
|
}
|
|
|
|
@Test
|
|
public void testBug309() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug309.jav");
|
|
var clazz = classFiles.get("Bug309");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
clazz.getDeclaredMethod("main").invoke(instance);
|
|
}
|
|
|
|
@Test
|
|
public void testBug310() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug310.jav");
|
|
var clazz = classFiles.get("Bug310");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
assertEquals(clazz.getDeclaredMethod("toString").invoke(instance), "3");
|
|
}
|
|
|
|
@Test
|
|
public void testBug311() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug311.jav");
|
|
var clazz = classFiles.get("Bug311");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
clazz.getDeclaredMethod("toString").invoke(instance);
|
|
}
|
|
|
|
@Test
|
|
public void testBug312() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug312.jav");
|
|
var clazz = classFiles.get("Bug312");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
clazz.getDeclaredMethod("main").invoke(instance);
|
|
}
|
|
|
|
@Test
|
|
public void testBug314() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug314.jav");
|
|
var clazz = classFiles.get("Bug314");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
|
|
var list = List.of(3, 4, 6, 7, 8);
|
|
var res = clazz.getDeclaredMethod("convert", List.class).invoke(instance, list);
|
|
assertEquals(res, List.of(6, 7, 8));
|
|
}
|
|
@Test
|
|
public void testBug325() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug325.jav");
|
|
var clazz = classFiles.get("Bug325");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
clazz.getDeclaredMethod("main").invoke(instance);
|
|
}
|
|
|
|
@Test
|
|
public void testBug326() throws Exception {
|
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug326.jav");
|
|
var clazz = classFiles.get("Bug326");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
}
|
|
|
|
@Test
|
|
public void testBug328() throws Exception {
|
|
var loader = new ByteArrayClassLoader();
|
|
loader.loadClass(TestCodegen.path.resolve("Bug328B.class"));
|
|
var classFiles = generateClassFiles(loader, "Bug328.jav");
|
|
var clazz = classFiles.get("Bug328");
|
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
|
}
|
|
}
|