Fix test cases for new inputs

This commit is contained in:
Victorious3 2023-02-21 14:04:53 +01:00
parent 84a5ed2cc3
commit 24bbce8265
2 changed files with 21 additions and 25 deletions

View File

@ -0,0 +1,2 @@
package de.dhbwstuttgart.bytecode;public class JavaTXSignatureAttribute {
}

View File

@ -407,7 +407,7 @@ public class TestComplete {
var instance = tph4.getDeclaredConstructor().newInstance();
var m = tph4.getDeclaredMethod("m", Object.class, Object.class);
// public <N, O, P extends N> N m(O var1, P var2)
// public <N, O> N m(O var1, N var2) {
var paraTypes = m.getGenericParameterTypes();
var typeParaTypes = m.getTypeParameters();
@ -415,8 +415,9 @@ public class TestComplete {
assertEquals(Object.class, N.getBounds()[0]);
var O = Arrays.stream(typeParaTypes).filter(t -> t.equals(paraTypes[0])).findFirst().get();
var P = Arrays.stream(typeParaTypes).filter(t -> t.equals(paraTypes[1])).findFirst().get();
assertEquals(N, P.getBounds()[0]);
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);
@ -465,18 +466,15 @@ public class TestComplete {
var instance = tph5.getDeclaredConstructor().newInstance();
var m = tph5.getDeclaredMethod("m", Object.class, Object.class);
// public <O extends P, N extends P, P> void m(N var1, O var2)
// public <P, O> void m(O var1, P var2)
var paraTypes = m.getGenericParameterTypes();
var typeParaTypes = m.getTypeParameters();
var N = Arrays.stream(typeParaTypes).filter(t -> t.equals(paraTypes[0])).findFirst().get();
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();
var PT = N.getBounds()[0];
assertEquals(PT, O.getBounds()[0]);
var P = Arrays.stream(typeParaTypes).filter(t -> t.equals(PT)).findFirst().get();
assertEquals(Object.class, P.getBounds()[0]);
assertEquals(P.getBounds()[0], Object.class);
assertEquals(O.getBounds()[0], Object.class);
var m2 = tph5.getDeclaredMethod("m2", Object.class);
@ -496,7 +494,7 @@ public class TestComplete {
var classToTest = classFiles.get("Tph7");
var instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
//public <DZN, DZL, DZU extends DZN, DZM extends DZU> DZU m(DZL, DZM);
// public <N, O> N m(O var1, N var2)
Method m = classToTest.getDeclaredMethod("m", Object.class, Object.class);
//System.out.println(m.toString());
@ -510,27 +508,23 @@ public class TestComplete {
//Typeparameters are extracted from the argumenttypes
//Conditions for the extracted typeparameters are set
//paraTypes[0] = DLZ
//paraTypes[0] = O
var boundFstArg = Arrays.stream(typeParaTypes)
.filter(x -> x.equals(paraTypes[0])).findFirst().get().getBounds();
//Bound of DLZ has to be Object
//Bound of O has to be Object
assertEquals(Object.class, Arrays.stream(boundFstArg).findFirst().get());
//paraTypes[0] = DZM
var boundSndArg = Arrays.stream(typeParaTypes)
.filter(x -> x.equals(paraTypes[1])).findFirst().get().getBounds();
//paraTypes[1] = N
var N = Arrays.stream(typeParaTypes)
.filter(x -> x.equals(paraTypes[1])).findFirst().get();
var boundSndArg = N.getBounds();
//Bound of DZM has to be the return type of m
assertEquals(Arrays.stream(boundSndArg).findFirst().get(), m.getGenericReturnType());
//Bound of H has to be Object
assertEquals(Object.class, Arrays.stream(boundSndArg).findFirst().get());
//Bound of the bound of DZM
var boundBoundSndArg = Arrays.stream(typeParaTypes).filter(x -> x.equals(Arrays.stream(boundSndArg)
.findFirst().get())).findFirst().get().getBounds();
//boundBoundSndArg have to be a type variable (type of the local variable c)
assertEquals(true, Arrays.stream(boundBoundSndArg).findFirst().get() instanceof TypeVariable);
m.getGenericParameterTypes();
//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);