Change tests to umatch updated generics

This commit is contained in:
Victorious3 2023-01-24 11:55:40 +01:00
parent 9d20c0564c
commit 1ce180ce74

View File

@ -1,6 +1,7 @@
package targetast;
import de.dhbwstuttgart.environment.ByteArrayClassLoader;
import org.junit.Ignore;
import org.junit.Test;
import java.lang.reflect.Method;
@ -381,13 +382,14 @@ public class TestComplete {
var instance = tph3.getDeclaredConstructor().newInstance();
var m1 = tph3.getDeclaredMethod("m1", Object.class, Object.class);
// public <DZC> void m1(DZC var1, DZC var2)
// public <DXBE extends DXBD, DXBD> void m1(DXBD var1, DXBE var2)
var paraTypes = m1.getGenericParameterTypes();
var typeParaTypes = m1.getTypeParameters();
var DZC = Arrays.stream(typeParaTypes).filter(t -> t.equals(paraTypes[0])).findFirst().get();
assertEquals(DZC, Arrays.stream(typeParaTypes).filter(t -> t.equals(paraTypes[1])).findFirst().get());
assertEquals(Object.class, DZC.getBounds()[0]);
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);
@ -406,18 +408,17 @@ public class TestComplete {
var instance = tph4.getDeclaredConstructor().newInstance();
var m = tph4.getDeclaredMethod("m", Object.class, Object.class);
// public <O extends P, N, P extends M, M> M m(N var1, O var2)
// public <N, O, P extends N> N 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 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[1])).findFirst().get();
var P = Arrays.stream(typeParaTypes).filter(t -> t.equals(O.getBounds()[0])).findFirst().get();
var M = Arrays.stream(typeParaTypes).filter(t -> t.equals(P.getBounds()[0])).findFirst().get();
assertEquals(Object.class, M.getBounds()[0]);
assertEquals(M, m.getGenericReturnType());
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]);
assertEquals(O.getBounds()[0], Object.class);
var m2 = tph4.getDeclaredMethod("m2", Object.class);