bug fix VectorNotObject test
This commit is contained in:
parent
52b7040337
commit
30a62a6621
7
pom.xml
7
pom.xml
@ -51,11 +51,10 @@ http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<compilerArgs>--enable-preview</compilerArgs>
|
||||
<source>19</source>
|
||||
<target>19</target>
|
||||
<release>20</release>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
@ -112,8 +111,6 @@ http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
</repository>
|
||||
</repositories>
|
||||
<properties>
|
||||
<maven.compiler.source>19</maven.compiler.source>
|
||||
<maven.compiler.target>19</maven.compiler.target>
|
||||
<mainClass>de.dhbwstuttgart.core.ConsoleInterface</mainClass>
|
||||
</properties>
|
||||
<distributionManagement>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -122,17 +122,15 @@ public class StatementGenerator {
|
||||
public ParameterList convert(Java17Parser.FormalParameterListContext formalParameterListContext) {
|
||||
List<FormalParameter> ret = new ArrayList<>();
|
||||
List<Java17Parser.FormalParameterContext> fps = new ArrayList<>();
|
||||
if (formalParameterListContext == null || formalParameterListContext.lastFormalParameter() == null)
|
||||
if (!Objects.isNull(formalParameterListContext.lastFormalParameter())) {
|
||||
/*
|
||||
* Der '...' Operator wird noch nicht unterstützt, da dafür benötigte Typen (List oder Array) nicht vom Typinferenzalgo. verarbeitet werden können
|
||||
*/
|
||||
throw new NotImplementedException("Formale Parameter variabler Länge nicht unterstützt.");
|
||||
}
|
||||
if (formalParameterListContext.children.size() == 0)
|
||||
return new ParameterList(ret, new NullToken()); // Dann ist die Parameterliste leer
|
||||
|
||||
/*
|
||||
* Restrukturierung Java17-Grammatik Zeile wird nicht mehr benötigt, da Regel für Parameter-Liste nicht mehr rekursiv ist. "lastFormalParameter" hat kein Kind "formalParameter" mehr.
|
||||
*
|
||||
* if(formalParameterListContext.lastFormalParameter().formalParameter() == null) throw new NotImplementedException();
|
||||
*/
|
||||
|
||||
fps = formalParameterListContext.formalParameter();
|
||||
|
||||
for (Java17Parser.FormalParameterContext fp : fps) {
|
||||
String paramName = SyntaxTreeGenerator.convert(fp.variableDeclaratorId());
|
||||
RefTypeOrTPHOrWildcardOrGeneric type;
|
||||
|
@ -206,7 +206,7 @@ public class StatementToTargetExpression implements StatementVisitor {
|
||||
var returnType = isFunNType ? TargetType.Object : converter.convert(methodCall.signature.get(methodCall.signature.size() - 1));
|
||||
var receiverName = new JavaClassName(converter.convert(methodCall.receiver.getType()).name());
|
||||
var argList = methodCall.signature.stream().map(converter::convert).toList();
|
||||
argList = argList.subList(0, argList.size() - 1);
|
||||
// argList = argList.subList(0, argList.size() - 1);
|
||||
|
||||
Method foundMethod = null;
|
||||
if (methodCall.receiver instanceof ExpressionReceiver expressionReceiver && expressionReceiver.expr instanceof This) {
|
||||
|
@ -206,7 +206,7 @@ public class TestComplete {
|
||||
vv1.addElement(v3);
|
||||
vv1.addElement(v4);
|
||||
|
||||
var instanceOfClass_m2 = matrixOP.getDeclaredConstructor(Vector.class).newInstance(vv1);//Matrix m2 = new Matrix(vv1);
|
||||
var instanceOfClass_m2 = matrixOP.getDeclaredConstructor(Vector.class).newInstance(vv1);// Matrix m2 = new Matrix(vv1);
|
||||
|
||||
var mul = matrixOP.getField("mul");
|
||||
mul.setAccessible(true);
|
||||
@ -238,10 +238,10 @@ public class TestComplete {
|
||||
var matrix = classFiles.get("Matrix");
|
||||
|
||||
Vector<Vector<Integer>> vv = new Vector<>();
|
||||
Vector<Integer> v1 = new Vector<> ();
|
||||
Vector<Integer> v1 = new Vector<>();
|
||||
v1.addElement(2);
|
||||
v1.addElement(2);
|
||||
Vector<Integer> v2 = new Vector<> ();
|
||||
Vector<Integer> v2 = new Vector<>();
|
||||
v2.addElement(3);
|
||||
v2.addElement(3);
|
||||
vv.addElement(v1);
|
||||
@ -250,10 +250,10 @@ public class TestComplete {
|
||||
var instanceOfClass_m1 = matrix.getDeclaredConstructor(Vector.class).newInstance(vv);
|
||||
|
||||
Vector<Vector<Integer>> vv1 = new Vector<>();
|
||||
Vector<Integer> v3 = new Vector<> ();
|
||||
Vector<Integer> v3 = new Vector<>();
|
||||
v3.addElement(2);
|
||||
v3.addElement(2);
|
||||
Vector<Integer> v4 = new Vector<> ();
|
||||
Vector<Integer> v4 = new Vector<>();
|
||||
v4.addElement(3);
|
||||
v4.addElement(3);
|
||||
vv1.addElement(v3);
|
||||
@ -266,10 +266,10 @@ public class TestComplete {
|
||||
System.out.println(instanceOfClass_m1.toString() + " * " + instanceOfClass_m2.toString() + " = " + result.toString());
|
||||
|
||||
Vector<Vector<Integer>> res = new Vector<>();
|
||||
Vector<Integer> v5 = new Vector<> ();
|
||||
Vector<Integer> v5 = new Vector<>();
|
||||
v5.addElement(10);
|
||||
v5.addElement(10);
|
||||
Vector<Integer> v6 = new Vector<> ();
|
||||
Vector<Integer> v6 = new Vector<>();
|
||||
v6.addElement(15);
|
||||
v6.addElement(15);
|
||||
res.addElement(v5);
|
||||
@ -324,7 +324,7 @@ public class TestComplete {
|
||||
var relOps = classFiles.get("RelOps");
|
||||
var instance = relOps.getDeclaredConstructor().newInstance();
|
||||
|
||||
var m = relOps.getDeclaredMethod("m", Integer.class,Integer.class);
|
||||
var m = relOps.getDeclaredMethod("m", Integer.class, Integer.class);
|
||||
assertFalse((Boolean) m.invoke(instance, 7, 3));
|
||||
}
|
||||
|
||||
@ -339,7 +339,7 @@ public class TestComplete {
|
||||
var classFiles = generateClassFiles("SubMatrix.jav", new ByteArrayClassLoader());
|
||||
var instance = classFiles.get("SubMatrix").getDeclaredConstructor().newInstance();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void tphTest() throws Exception {
|
||||
var classFiles = generateClassFiles("Tph.jav", new ByteArrayClassLoader());
|
||||
@ -487,7 +487,6 @@ public class TestComplete {
|
||||
assertEquals(W, m2.getGenericReturnType());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void Tph7Test() throws Exception {
|
||||
var classFiles = TestCodegen.generateClassFiles("Tph7.jav", new ByteArrayClassLoader());
|
||||
@ -497,59 +496,55 @@ public class TestComplete {
|
||||
// public <N, O> N m(O var1, N var2)
|
||||
Method m = classToTest.getDeclaredMethod("m", Object.class, Object.class);
|
||||
|
||||
//System.out.println(m.toString());
|
||||
// System.out.println(m.toString());
|
||||
|
||||
//Argumenttypes of the method m
|
||||
// Argumenttypes of the method m
|
||||
var paraTypes = m.getGenericParameterTypes();
|
||||
|
||||
//Typeparameters of the method m
|
||||
var typeParaTypes = m.getTypeParameters();
|
||||
// Typeparameters of the method m
|
||||
var typeParaTypes = m.getTypeParameters();
|
||||
|
||||
//Typeparameters are extracted from the argumenttypes
|
||||
//Conditions for the extracted typeparameters are set
|
||||
// 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();
|
||||
// paraTypes[0] = O
|
||||
var boundFstArg = Arrays.stream(typeParaTypes).filter(x -> x.equals(paraTypes[0])).findFirst().get().getBounds();
|
||||
|
||||
//Bound of O has to be Object
|
||||
// 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();
|
||||
// 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
|
||||
// Bound of H has to be Object
|
||||
assertEquals(Object.class, Arrays.stream(boundSndArg).findFirst().get());
|
||||
|
||||
//N has to be the return type of m
|
||||
// N has to be the return type of m
|
||||
assertEquals(N, m.getGenericReturnType());
|
||||
|
||||
//public <DZU> DZU m2(DZU);
|
||||
// public <DZU> DZU m2(DZU);
|
||||
Method m2 = classToTest.getDeclaredMethod("m2", Object.class);
|
||||
|
||||
//Argumenttypes of the method m2
|
||||
// Argumenttypes of the method m2
|
||||
var paraTypesm2 = m2.getGenericParameterTypes();
|
||||
|
||||
//Typeparameters of the method m2
|
||||
var typeParaTypesm2 = m2.getTypeParameters();
|
||||
// Typeparameters of the method m2
|
||||
var typeParaTypesm2 = m2.getTypeParameters();
|
||||
|
||||
//Typeparameters are extracted from the argumenttypes
|
||||
//Conditions for the extracted typeparameters are set
|
||||
// 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();
|
||||
// paraTypes[0] = DZU
|
||||
var fstArgm2 = Arrays.stream(typeParaTypesm2).filter(x -> x.equals(paraTypesm2[0])).findFirst().get();
|
||||
|
||||
//Bound of DZU has to be Object
|
||||
// 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
|
||||
// DZU has to be the return type of m
|
||||
assertEquals(fstArgm2, m2.getGenericReturnType());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void typedIdTest() throws Exception {
|
||||
var classFiles = generateClassFiles("TypedID.jav", new ByteArrayClassLoader());
|
||||
|
Loading…
Reference in New Issue
Block a user