forked from JavaTX/JavaCompilerCore
Fix test cases for new inputs
This commit is contained in:
parent
84a5ed2cc3
commit
24bbce8265
@ -0,0 +1,2 @@
|
|||||||
|
package de.dhbwstuttgart.bytecode;public class JavaTXSignatureAttribute {
|
||||||
|
}
|
@ -407,7 +407,7 @@ public class TestComplete {
|
|||||||
var instance = tph4.getDeclaredConstructor().newInstance();
|
var instance = tph4.getDeclaredConstructor().newInstance();
|
||||||
var m = tph4.getDeclaredMethod("m", Object.class, Object.class);
|
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 paraTypes = m.getGenericParameterTypes();
|
||||||
var typeParaTypes = m.getTypeParameters();
|
var typeParaTypes = m.getTypeParameters();
|
||||||
|
|
||||||
@ -415,8 +415,9 @@ public class TestComplete {
|
|||||||
assertEquals(Object.class, N.getBounds()[0]);
|
assertEquals(Object.class, N.getBounds()[0]);
|
||||||
|
|
||||||
var O = Arrays.stream(typeParaTypes).filter(t -> t.equals(paraTypes[0])).findFirst().get();
|
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();
|
var N2 = Arrays.stream(typeParaTypes).filter(t -> t.equals(paraTypes[1])).findFirst().get();
|
||||||
assertEquals(N, P.getBounds()[0]);
|
assertEquals(N, N2);
|
||||||
|
assertEquals(N.getBounds()[0], Object.class);
|
||||||
assertEquals(O.getBounds()[0], Object.class);
|
assertEquals(O.getBounds()[0], Object.class);
|
||||||
|
|
||||||
var m2 = tph4.getDeclaredMethod("m2", Object.class);
|
var m2 = tph4.getDeclaredMethod("m2", Object.class);
|
||||||
@ -465,18 +466,15 @@ public class TestComplete {
|
|||||||
var instance = tph5.getDeclaredConstructor().newInstance();
|
var instance = tph5.getDeclaredConstructor().newInstance();
|
||||||
var m = tph5.getDeclaredMethod("m", Object.class, Object.class);
|
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 paraTypes = m.getGenericParameterTypes();
|
||||||
var typeParaTypes = m.getTypeParameters();
|
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 O = Arrays.stream(typeParaTypes).filter(t -> t.equals(paraTypes[1])).findFirst().get();
|
||||||
|
|
||||||
var PT = N.getBounds()[0];
|
assertEquals(P.getBounds()[0], Object.class);
|
||||||
assertEquals(PT, O.getBounds()[0]);
|
assertEquals(O.getBounds()[0], Object.class);
|
||||||
|
|
||||||
var P = Arrays.stream(typeParaTypes).filter(t -> t.equals(PT)).findFirst().get();
|
|
||||||
assertEquals(Object.class, P.getBounds()[0]);
|
|
||||||
|
|
||||||
var m2 = tph5.getDeclaredMethod("m2", Object.class);
|
var m2 = tph5.getDeclaredMethod("m2", Object.class);
|
||||||
|
|
||||||
@ -496,7 +494,7 @@ public class TestComplete {
|
|||||||
var classToTest = classFiles.get("Tph7");
|
var classToTest = classFiles.get("Tph7");
|
||||||
var instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
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);
|
Method m = classToTest.getDeclaredMethod("m", Object.class, Object.class);
|
||||||
|
|
||||||
//System.out.println(m.toString());
|
//System.out.println(m.toString());
|
||||||
@ -510,27 +508,23 @@ public class TestComplete {
|
|||||||
//Typeparameters are extracted from the argumenttypes
|
//Typeparameters are extracted from the argumenttypes
|
||||||
//Conditions for the extracted typeparameters are set
|
//Conditions for the extracted typeparameters are set
|
||||||
|
|
||||||
//paraTypes[0] = DLZ
|
//paraTypes[0] = O
|
||||||
var boundFstArg = Arrays.stream(typeParaTypes)
|
var boundFstArg = Arrays.stream(typeParaTypes)
|
||||||
.filter(x -> x.equals(paraTypes[0])).findFirst().get().getBounds();
|
.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());
|
assertEquals(Object.class, Arrays.stream(boundFstArg).findFirst().get());
|
||||||
|
|
||||||
//paraTypes[0] = DZM
|
//paraTypes[1] = N
|
||||||
var boundSndArg = Arrays.stream(typeParaTypes)
|
var N = Arrays.stream(typeParaTypes)
|
||||||
.filter(x -> x.equals(paraTypes[1])).findFirst().get().getBounds();
|
.filter(x -> x.equals(paraTypes[1])).findFirst().get();
|
||||||
|
var boundSndArg = N.getBounds();
|
||||||
|
|
||||||
//Bound of DZM has to be the return type of m
|
//Bound of H has to be Object
|
||||||
assertEquals(Arrays.stream(boundSndArg).findFirst().get(), m.getGenericReturnType());
|
assertEquals(Object.class, Arrays.stream(boundSndArg).findFirst().get());
|
||||||
|
|
||||||
//Bound of the bound of DZM
|
//N has to be the return type of m
|
||||||
var boundBoundSndArg = Arrays.stream(typeParaTypes).filter(x -> x.equals(Arrays.stream(boundSndArg)
|
assertEquals(N, m.getGenericReturnType());
|
||||||
.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();
|
|
||||||
|
|
||||||
//public <DZU> DZU m2(DZU);
|
//public <DZU> DZU m2(DZU);
|
||||||
Method m2 = classToTest.getDeclaredMethod("m2", Object.class);
|
Method m2 = classToTest.getDeclaredMethod("m2", Object.class);
|
||||||
|
Loading…
Reference in New Issue
Block a user