Simplify tests by adding BoundsChain

This commit is contained in:
Victorious3 2023-01-17 12:42:20 +01:00
parent 268f2b72eb
commit 43e8837308
4 changed files with 123 additions and 89 deletions

View File

@ -7,18 +7,4 @@ import java.util.List;
public record Bound(boolean isOnMethod, RefTypeOrTPHOrWildcardOrGeneric bound) { public record Bound(boolean isOnMethod, RefTypeOrTPHOrWildcardOrGeneric bound) {
public static boolean chainEquals(List<Bound> left, List<Bound> right) {
if (left.size() != right.size()) return false;
for (var i = 0; i < left.size(); i++) {
var l = left.get(i);
var r = right.get(i);
if (l.isOnMethod != r.isOnMethod) return false;
if (i == left.size() - 1) {
if (!(l.bound instanceof TypePlaceholder)) {
if (!(l.bound.equals(r.bound))) return false;
}
}
}
return true;
}
} }

View File

@ -0,0 +1,44 @@
package de.dhbwstuttgart.target.generate;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import java.util.AbstractList;
import java.util.List;
public class BoundsList extends AbstractList<Bound> {
private final List<Bound> bounds;
public BoundsList(List<Bound> bounds) {
this.bounds = bounds;
}
public BoundsList(Bound... bounds) {
this.bounds = List.of(bounds);
}
@Override
public Bound get(int index) {
return bounds.get(index);
}
@Override
public int size() {
return bounds.size();
}
@Override
public boolean equals(Object other) {
if (!(other instanceof BoundsList right)) return false;
if (size() != right.size()) return false;
for (var i = 0; i < size(); i++) {
var l = get(i);
var r = right.get(i);
if (l.isOnMethod() != r.isOnMethod()) return false;
if (i == size() - 1) {
if (!(l.bound() instanceof TypePlaceholder)) {
if (!(l.bound().equals(r.bound()))) return false;
}
}
}
return true;
}
}

View File

@ -11,7 +11,7 @@ import java.util.*;
public class GenericsResult { public class GenericsResult {
final ASTToTargetAST.Sigma sigma; final ASTToTargetAST.Sigma sigma;
public GenericsResult(ASTToTargetAST.Sigma sigma) { GenericsResult(ASTToTargetAST.Sigma sigma) {
this.sigma = sigma; this.sigma = sigma;
} }
@ -23,11 +23,11 @@ public class GenericsResult {
return this.sigma.computedGenericsOfMethods.getOrDefault(method, Set.of()); return this.sigma.computedGenericsOfMethods.getOrDefault(method, Set.of());
} }
public List<Bound> getBounds(RefTypeOrTPHOrWildcardOrGeneric type, ClassOrInterface clazz) { public BoundsList getBounds(RefTypeOrTPHOrWildcardOrGeneric type, ClassOrInterface clazz) {
return getBounds(type, clazz, null); return getBounds(type, clazz, null);
} }
public List<Bound> getBounds(RefTypeOrTPHOrWildcardOrGeneric type, ClassOrInterface clazz, Method method) { public BoundsList getBounds(RefTypeOrTPHOrWildcardOrGeneric type, ClassOrInterface clazz, Method method) {
type = resolve(type); type = resolve(type);
if (type instanceof TypePlaceholder) { if (type instanceof TypePlaceholder) {
var methodGenerics = get(method); var methodGenerics = get(method);
@ -55,9 +55,9 @@ public class GenericsResult {
} }
bound.ifPresent(result::add); bound.ifPresent(result::add);
} while (bound.isPresent()); } while (bound.isPresent());
return result; return new BoundsList(result);
} }
return List.of(); return new BoundsList(List.of());
} }
public RefTypeOrTPHOrWildcardOrGeneric resolve(RefTypeOrTPHOrWildcardOrGeneric type) { public RefTypeOrTPHOrWildcardOrGeneric resolve(RefTypeOrTPHOrWildcardOrGeneric type) {

View File

@ -8,6 +8,7 @@ import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.target.generate.ASTToTargetAST; import de.dhbwstuttgart.target.generate.ASTToTargetAST;
import de.dhbwstuttgart.target.generate.Bound; import de.dhbwstuttgart.target.generate.Bound;
import de.dhbwstuttgart.target.generate.BoundsList;
import de.dhbwstuttgart.target.generate.GenericsResult; import de.dhbwstuttgart.target.generate.GenericsResult;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
@ -57,12 +58,13 @@ public class TestGenerics {
var ECK1 = generics.getBounds(otherMethod.getParameterList().getParameterAt(0).getType(), result.clazz, anyMethod); var ECK1 = generics.getBounds(otherMethod.getParameterList().getParameterAt(0).getType(), result.clazz, anyMethod);
var ECK2 = generics.getBounds(otherMethod.getReturnType(), result.clazz, anyMethod); var ECK2 = generics.getBounds(otherMethod.getReturnType(), result.clazz, anyMethod);
var ECKChain = List.of(new Bound(false, ASTToTargetAST.OBJECT)); var ECKChain = new BoundsList(new Bound(false, ASTToTargetAST.OBJECT));
assertTrue(Bound.chainEquals(ECK1, ECK2) && Bound.chainEquals(ECK2, ECKChain)); assertEquals(ECK1, ECK2);
assertEquals(ECK2, ECKChain);
var M = generics.getBounds(a.getType(), result.clazz); var M = generics.getBounds(a.getType(), result.clazz);
var MChain = List.of(new Bound(false, TypePlaceholder.of("ECK")), new Bound(false, ASTToTargetAST.OBJECT)); var MChain = new BoundsList(new Bound(false, TypePlaceholder.of("ECK")), new Bound(false, ASTToTargetAST.OBJECT));
assertTrue(Bound.chainEquals(M, MChain)); assertEquals(M, MChain);
} }
@Test @Test
@ -75,8 +77,8 @@ public class TestGenerics {
assertEquals(0, generics.get(fReturn).size()); assertEquals(0, generics.get(fReturn).size());
var N = generics.getBounds(fReturn.getReturnType(), result.clazz); var N = generics.getBounds(fReturn.getReturnType(), result.clazz);
var NChain = List.of(new Bound(false, ASTToTargetAST.OBJECT)); var NChain = new BoundsList(new Bound(false, ASTToTargetAST.OBJECT));
assertTrue(Bound.chainEquals(N, NChain)); assertEquals(N, NChain);
} }
@Test @Test
@ -91,18 +93,18 @@ public class TestGenerics {
assertEquals(2, generics.get(main).size()); assertEquals(2, generics.get(main).size());
var N = generics.getBounds(m.getParameterList().getParameterAt(0).getType(), result.clazz, m); var N = generics.getBounds(m.getParameterList().getParameterAt(0).getType(), result.clazz, m);
var NChain = List.of(new Bound(true, ASTToTargetAST.OBJECT)); var NChain = new BoundsList(new Bound(true, ASTToTargetAST.OBJECT));
assertTrue(Bound.chainEquals(N, NChain)); assertEquals(N, NChain);
var Q = generics.getBounds(m.getReturnType(), result.clazz, m); var Q = generics.getBounds(m.getReturnType(), result.clazz, m);
var QChain = List.of(new Bound(true, TypePlaceholder.of("N")), new Bound(true, ASTToTargetAST.OBJECT)); var QChain = new BoundsList(new Bound(true, TypePlaceholder.of("N")), new Bound(true, ASTToTargetAST.OBJECT));
assertTrue(Bound.chainEquals(Q, QChain)); assertEquals(Q, QChain);
var R = generics.getBounds(main.getParameterList().getParameterAt(0).getType(), result.clazz, main); var R = generics.getBounds(main.getParameterList().getParameterAt(0).getType(), result.clazz, main);
assertTrue(Bound.chainEquals(R, NChain)); assertEquals(R, NChain);
var Q2 = generics.getBounds(main.getReturnType(), result.clazz, main); var Q2 = generics.getBounds(main.getReturnType(), result.clazz, main);
assertTrue(Bound.chainEquals(Q2, NChain)); assertEquals(Q2, NChain);
} }
@Test @Test
@ -120,26 +122,26 @@ public class TestGenerics {
assertEquals(2, generics.get(m).size()); assertEquals(2, generics.get(m).size());
var R = generics.getBounds(a.getType(), result.clazz); var R = generics.getBounds(a.getType(), result.clazz);
var RChain = List.of(new Bound(false, ASTToTargetAST.OBJECT)); var RChain = new BoundsList(new Bound(false, ASTToTargetAST.OBJECT));
assertTrue(Bound.chainEquals(R, RChain)); assertEquals(R, RChain);
var O = generics.getBounds(id.getParameterList().getParameterAt(0).getType(), result.clazz, id); var O = generics.getBounds(id.getParameterList().getParameterAt(0).getType(), result.clazz, id);
var OChain = List.of(new Bound(true, TypePlaceholder.of("AB")), new Bound(true, ASTToTargetAST.OBJECT)); var OChain = new BoundsList(new Bound(true, TypePlaceholder.of("AB")), new Bound(true, ASTToTargetAST.OBJECT));
assertTrue(Bound.chainEquals(O, OChain)); assertEquals(O, OChain);
var AB = generics.getBounds(id.getReturnType(), result.clazz, id); var AB = generics.getBounds(id.getReturnType(), result.clazz, id);
assertTrue(Bound.chainEquals(AB, List.of(new Bound(true, ASTToTargetAST.OBJECT)))); assertEquals(AB, new BoundsList(new Bound(true, ASTToTargetAST.OBJECT)));
var S = generics.getBounds(setA.getParameterList().getParameterAt(0).getType(), result.clazz, setA); var S = generics.getBounds(setA.getParameterList().getParameterAt(0).getType(), result.clazz, setA);
var SChain = List.of(new Bound(true, TypePlaceholder.of("R")), new Bound(false, ASTToTargetAST.OBJECT)); var SChain = new BoundsList(new Bound(true, TypePlaceholder.of("R")), new Bound(false, ASTToTargetAST.OBJECT));
assertTrue(Bound.chainEquals(S, SChain)); assertEquals(S, SChain);
assertTrue(Bound.chainEquals(generics.getBounds(setA.getReturnType(), result.clazz, setA), RChain)); assertEquals(generics.getBounds(setA.getReturnType(), result.clazz, setA), RChain);
var X = generics.getBounds(m.getParameterList().getParameterAt(0).getType(), result.clazz, m); var X = generics.getBounds(m.getParameterList().getParameterAt(0).getType(), result.clazz, m);
var Y = generics.getBounds(m.getParameterList().getParameterAt(1).getType(), result.clazz, m); var Y = generics.getBounds(m.getParameterList().getParameterAt(1).getType(), result.clazz, m);
var XChain = List.of(new Bound(true, ASTToTargetAST.OBJECT)); var XChain = new BoundsList(new Bound(true, ASTToTargetAST.OBJECT));
var YChain = List.of(new Bound(true, TypePlaceholder.of("Y")), new Bound(true, ASTToTargetAST.OBJECT)); var YChain = new BoundsList(new Bound(true, TypePlaceholder.of("Y")), new Bound(true, ASTToTargetAST.OBJECT));
assertTrue(Bound.chainEquals(X, XChain)); assertEquals(X, XChain);
assertTrue(Bound.chainEquals(Y, YChain)); assertEquals(Y, YChain);
} }
@Test @Test
@ -164,28 +166,28 @@ public class TestGenerics {
assertEquals(3, generics.get(main).size()); assertEquals(3, generics.get(main).size());
var M = generics.getBounds(a.getType(), result.clazz); var M = generics.getBounds(a.getType(), result.clazz);
assertTrue(Bound.chainEquals(M, List.of(new Bound(false, ASTToTargetAST.OBJECT)))); assertEquals(M, new BoundsList(new Bound(false, ASTToTargetAST.OBJECT)));
var O = generics.getBounds(id.getParameterList().getParameterAt(0).getType(), result.clazz, id); var O = generics.getBounds(id.getParameterList().getParameterAt(0).getType(), result.clazz, id);
var OChain = List.of(new Bound(true, TypePlaceholder.of("P")), new Bound(true, ASTToTargetAST.OBJECT)); var OChain = new BoundsList(new Bound(true, TypePlaceholder.of("P")), new Bound(true, ASTToTargetAST.OBJECT));
assertTrue(Bound.chainEquals(O, OChain)); assertEquals(O, OChain);
var AK = generics.getBounds(id.getReturnType(), result.clazz, id); var AK = generics.getBounds(id.getReturnType(), result.clazz, id);
var AKChain = List.of(new Bound(true, ASTToTargetAST.OBJECT)); var AKChain = new BoundsList(new Bound(true, ASTToTargetAST.OBJECT));
assertTrue(Bound.chainEquals(AK, AKChain)); assertEquals(AK, AKChain);
// TODO Shouldn't AK and AK2 be the same and on the class? // TODO Shouldn't AK and AK2 be the same and on the class?
var AK2 = generics.getBounds(m.getParameterList().getParameterAt(0).getType(), result.clazz, m); var AK2 = generics.getBounds(m.getParameterList().getParameterAt(0).getType(), result.clazz, m);
var Y = generics.getBounds(m.getParameterList().getParameterAt(0).getType(), result.clazz, m); var Y = generics.getBounds(m.getParameterList().getParameterAt(0).getType(), result.clazz, m);
assertTrue(Bound.chainEquals(AK2, AKChain)); assertEquals(AK2, AKChain);
assertTrue(Bound.chainEquals(Y, AKChain)); assertEquals(Y, AKChain);
var AF = generics.getBounds(main.getParameterList().getParameterAt(0).getType(), result.clazz, main); var AF = generics.getBounds(main.getParameterList().getParameterAt(0).getType(), result.clazz, main);
var AG= generics.getBounds(main.getParameterList().getParameterAt(1).getType(), result.clazz, main); var AG= generics.getBounds(main.getParameterList().getParameterAt(1).getType(), result.clazz, main);
var AK3 = generics.getBounds(main.getReturnType(), result.clazz, main); var AK3 = generics.getBounds(main.getReturnType(), result.clazz, main);
var AFChain = List.of(new Bound(true, TypePlaceholder.of("AG")), new Bound(true, ASTToTargetAST.OBJECT)); var AFChain = new BoundsList(new Bound(true, TypePlaceholder.of("AG")), new Bound(true, ASTToTargetAST.OBJECT));
assertTrue(Bound.chainEquals(AF, AFChain)); assertEquals(AF, AFChain);
assertTrue(Bound.chainEquals(AG, AKChain)); assertEquals(AG, AKChain);
assertTrue(Bound.chainEquals(AK3, AKChain)); assertEquals(AK3, AKChain);
} }
@Test @Test
@ -197,7 +199,7 @@ public class TestGenerics {
assertEquals(1, generics.get(anyMethod).size()); assertEquals(1, generics.get(anyMethod).size());
var M = generics.getBounds(anyMethod.getReturnType(), result.clazz, anyMethod); var M = generics.getBounds(anyMethod.getReturnType(), result.clazz, anyMethod);
assertTrue(Bound.chainEquals(M, List.of(new Bound(true, ASTToTargetAST.OBJECT)))); assertEquals(M, new BoundsList(new Bound(true, ASTToTargetAST.OBJECT)));
} }
@Test @Test
@ -211,15 +213,16 @@ public class TestGenerics {
var generics = result.genericsResults.get(0); var generics = result.genericsResults.get(0);
var M = generics.getBounds(a.getType(), result.clazz); var M = generics.getBounds(a.getType(), result.clazz);
var DYX = generics.getBounds(b.getType(), result.clazz); var DYX = generics.getBounds(b.getType(), result.clazz);
var MChain = List.of(new Bound(false, TypePlaceholder.of("DYX")), new Bound(false, ASTToTargetAST.OBJECT)); var MChain = new BoundsList(new Bound(false, TypePlaceholder.of("DYX")), new Bound(false, ASTToTargetAST.OBJECT));
var DYXChain = List.of(new Bound(false, ASTToTargetAST.OBJECT)); var DYXChain = new BoundsList(new Bound(false, ASTToTargetAST.OBJECT));
assertTrue(Bound.chainEquals(M, MChain)); assertEquals(M, MChain);
var Q = generics.getBounds(anyMethod.getReturnType(), result.clazz, anyMethod); var Q = generics.getBounds(anyMethod.getReturnType(), result.clazz, anyMethod);
assertTrue(Bound.chainEquals(Q, List.of(new Bound(true, ASTToTargetAST.OBJECT)))); assertEquals(Q, new BoundsList(new Bound(true, ASTToTargetAST.OBJECT)));
var DYX2 = generics.getBounds(otherMethod.getReturnType(), result.clazz, otherMethod); var DYX2 = generics.getBounds(otherMethod.getReturnType(), result.clazz, otherMethod);
assertTrue(Bound.chainEquals(DYX, DYX2) && Bound.chainEquals(DYX2, DYXChain)); assertEquals(DYX, DYX2);
assertEquals(DYX2, DYXChain);
} }
@Test @Test
@ -238,18 +241,18 @@ public class TestGenerics {
var generics = result.genericsResults.get(0); var generics = result.genericsResults.get(0);
var U = generics.getBounds(id2.getParameterList().getParameterAt(0).getType(), result.clazz, id2); var U = generics.getBounds(id2.getParameterList().getParameterAt(0).getType(), result.clazz, id2);
var FPT = generics.getBounds(id2.getReturnType(), result.clazz, id2); var FPT = generics.getBounds(id2.getReturnType(), result.clazz, id2);
assertTrue(Bound.chainEquals(U, List.of(new Bound(true, TypePlaceholder.of("FPT")), new Bound(false, ASTToTargetAST.OBJECT)))); assertEquals(U, new BoundsList(new Bound(true, TypePlaceholder.of("FPT")), new Bound(false, ASTToTargetAST.OBJECT)));
assertTrue(Bound.chainEquals(FPT, List.of(new Bound(false, ASTToTargetAST.OBJECT)))); assertEquals(FPT, new BoundsList(new Bound(false, ASTToTargetAST.OBJECT)));
var AA = generics.getBounds(m.getReturnType(), result.clazz, m); var AA = generics.getBounds(m.getReturnType(), result.clazz, m);
var AC = generics.getBounds(m.getParameterList().getParameterAt(1).getType(), result.clazz, m); var AC = generics.getBounds(m.getParameterList().getParameterAt(1).getType(), result.clazz, m);
assertTrue(Bound.chainEquals(AA, List.of(new Bound(true, ASTToTargetAST.OBJECT)))); assertEquals(AA, new BoundsList(new Bound(true, ASTToTargetAST.OBJECT)));
assertTrue(Bound.chainEquals(AC, List.of(new Bound(true, TypePlaceholder.of("AD")), new Bound(true, ASTToTargetAST.OBJECT)))); assertEquals(AC, new BoundsList(new Bound(true, TypePlaceholder.of("AD")), new Bound(true, ASTToTargetAST.OBJECT)));
var AH = generics.getBounds(m2.getReturnType(), result.clazz, m2); var AH = generics.getBounds(m2.getReturnType(), result.clazz, m2);
var AL = generics.getBounds(m2.getParameterList().getParameterAt(0).getType(), result.clazz, m2); var AL = generics.getBounds(m2.getParameterList().getParameterAt(0).getType(), result.clazz, m2);
assertTrue(Bound.chainEquals(AH, List.of(new Bound(true, ASTToTargetAST.OBJECT)))); assertEquals(AH, new BoundsList(new Bound(true, ASTToTargetAST.OBJECT)));
assertTrue(Bound.chainEquals(AH, AL)); assertEquals(AH, AL);
} }
@Test @Test
@ -264,33 +267,34 @@ public class TestGenerics {
var generics = result.genericsResults.get(0); var generics = result.genericsResults.get(0);
var AO = generics.getBounds(a.getType(), result.clazz); var AO = generics.getBounds(a.getType(), result.clazz);
var AOBound = List.of( var AOBound = new BoundsList(
new Bound(false, TypePlaceholder.of("Y")), new Bound(false, TypePlaceholder.of("Y")),
new Bound(false, TypePlaceholder.of("AK")), new Bound(false, TypePlaceholder.of("AK")),
new Bound(false, TypePlaceholder.of("AE")), new Bound(false, TypePlaceholder.of("AE")),
new Bound(false, ASTToTargetAST.OBJECT) new Bound(false, ASTToTargetAST.OBJECT)
); );
assertTrue(Bound.chainEquals(AO, AOBound)); assertEquals(AO, AOBound);
var S = generics.getBounds(setA.getParameterList().getParameterAt(0).getType(), result.clazz, setA); var S = generics.getBounds(setA.getParameterList().getParameterAt(0).getType(), result.clazz, setA);
var SChain = new ArrayList<Bound>(); var c = new ArrayList<Bound>();
SChain.add(new Bound(true, TypePlaceholder.of("AO"))); c.add(new Bound(true, TypePlaceholder.of("AO")));
SChain.addAll(AOBound); c.addAll(AOBound);
assertTrue(Bound.chainEquals(S, SChain)); var SChain = new BoundsList(c);
assertEquals(S, SChain);
var Y = generics.getBounds(m.getParameterList().getParameterAt(1).getType(), result.clazz, m); var Y = generics.getBounds(m.getParameterList().getParameterAt(1).getType(), result.clazz, m);
var YChain = List.of(new Bound(true, TypePlaceholder.of("AE")), new Bound(false, ASTToTargetAST.OBJECT)); var YChain = new BoundsList(new Bound(true, TypePlaceholder.of("AE")), new Bound(false, ASTToTargetAST.OBJECT));
var AE = generics.getBounds(m.getReturnType(), result.clazz, m); var AE = generics.getBounds(m.getReturnType(), result.clazz, m);
assertTrue(Bound.chainEquals(Y, YChain)); assertEquals(Y, YChain);
assertTrue(Bound.chainEquals(AE, List.of(new Bound(false, ASTToTargetAST.OBJECT)))); assertEquals(AE, new BoundsList(new Bound(false, ASTToTargetAST.OBJECT)));
// TODO main seems to change between runs // TODO main seems to change between runs
/*var AE2 = generics.getBounds(main.getReturnType(), result.clazz, main); /*var AE2 = generics.getBounds(main.getReturnType(), result.clazz, main);
var AF = generics.getBounds(main.getParameterList().getParameterAt(0).getType(), result.clazz, main); var AF = generics.getBounds(main.getParameterList().getParameterAt(0).getType(), result.clazz, main);
var AG = generics.getBounds(main.getParameterList().getParameterAt(1).getType(), result.clazz, main); var AG = generics.getBounds(main.getParameterList().getParameterAt(1).getType(), result.clazz, main);
assertTrue(Bound.chainEquals(AE, AE2)); assertEquals(AE, AE2));
assertTrue(Bound.chainEquals(AF, List.of(new Bound(true, TypePlaceholder.of("AK")), new Bound(true, TypePlaceholder.of("AE")), new Bound(false, ASTToTargetAST.OBJECT)))); assertEquals(AF, new BoundsList(new Bound(true, TypePlaceholder.of("AK")), new Bound(true, TypePlaceholder.of("AE")), new Bound(false, ASTToTargetAST.OBJECT))));
assertTrue(Bound.chainEquals(AG, SChain));*/ assertEquals(AG, SChain));*/
} }
@Test @Test
@ -308,15 +312,15 @@ public class TestGenerics {
var generics = result.genericsResults.get(0); var generics = result.genericsResults.get(0);
var Q = generics.getBounds(id.getReturnType(), result.clazz, id); var Q = generics.getBounds(id.getReturnType(), result.clazz, id);
var N = generics.getBounds(id.getParameterList().getParameterAt(0).getType(), result.clazz, id); var N = generics.getBounds(id.getParameterList().getParameterAt(0).getType(), result.clazz, id);
assertTrue(Bound.chainEquals(Q, List.of(new Bound(true, ASTToTargetAST.OBJECT)))); assertEquals(Q, new BoundsList(new Bound(true, ASTToTargetAST.OBJECT)));
assertTrue(Bound.chainEquals(N, List.of(new Bound(true, TypePlaceholder.of("Q")), new Bound(true, ASTToTargetAST.OBJECT)))); assertEquals(N, new BoundsList(new Bound(true, TypePlaceholder.of("Q")), new Bound(true, ASTToTargetAST.OBJECT)));
var Q2 = generics.getBounds(main.getReturnType(), result.clazz, main); var Q2 = generics.getBounds(main.getReturnType(), result.clazz, main);
var R = generics.getBounds(main.getParameterList().getParameterAt(0).getType(), result.clazz, main); var R = generics.getBounds(main.getParameterList().getParameterAt(0).getType(), result.clazz, main);
var S = generics.getBounds(main.getParameterList().getParameterAt(1).getType(), result.clazz, main); var S = generics.getBounds(main.getParameterList().getParameterAt(1).getType(), result.clazz, main);
assertTrue(Bound.chainEquals(Q2, List.of(new Bound(true, ASTToTargetAST.OBJECT)))); assertEquals(Q2, new BoundsList(new Bound(true, ASTToTargetAST.OBJECT)));
assertTrue(Bound.chainEquals(R, List.of(new Bound(true, TypePlaceholder.of("Q")), new Bound(true, ASTToTargetAST.OBJECT)))); assertEquals(R, new BoundsList(new Bound(true, TypePlaceholder.of("Q")), new Bound(true, ASTToTargetAST.OBJECT)));
assertTrue(Bound.chainEquals(S, List.of(new Bound(true, TypePlaceholder.of("Q")), new Bound(true, ASTToTargetAST.OBJECT)))); assertEquals(S, new BoundsList(new Bound(true, TypePlaceholder.of("Q")), new Bound(true, ASTToTargetAST.OBJECT)));
} }
@Test @Test
@ -330,8 +334,8 @@ public class TestGenerics {
var S = generics.getBounds(((RefType) par1).getParaList().get(0), result.clazz, m); var S = generics.getBounds(((RefType) par1).getParaList().get(0), result.clazz, m);
var ACM = generics.getBounds(((RefType) par2).getParaList().get(0), result.clazz, m); var ACM = generics.getBounds(((RefType) par2).getParaList().get(0), result.clazz, m);
assertTrue(Bound.chainEquals(S, List.of(new Bound(true, TypePlaceholder.of("V")), new Bound(true, TypePlaceholder.of("ACM")), new Bound(true, ASTToTargetAST.OBJECT)))); assertEquals(S, new BoundsList(new Bound(true, TypePlaceholder.of("V")), new Bound(true, TypePlaceholder.of("ACM")), new Bound(true, ASTToTargetAST.OBJECT)));
assertTrue(Bound.chainEquals(ACM, List.of(new Bound(true, ASTToTargetAST.OBJECT)))); assertEquals(ACM, new BoundsList(new Bound(true, ASTToTargetAST.OBJECT)));
} }
@Test @Test
@ -344,14 +348,14 @@ public class TestGenerics {
var par1 = generics.resolve(add.getParameterList().getParameterAt(0).getType()); var par1 = generics.resolve(add.getParameterList().getParameterAt(0).getType());
var ACK = generics.getBounds(((RefType) par1).getParaList().get(0), result.clazz, add); var ACK = generics.getBounds(((RefType) par1).getParaList().get(0), result.clazz, add);
var O = generics.getBounds(add.getParameterList().getParameterAt(1).getType(), result.clazz, add); var O = generics.getBounds(add.getParameterList().getParameterAt(1).getType(), result.clazz, add);
assertTrue(Bound.chainEquals(ACK, List.of(new Bound(true, ASTToTargetAST.OBJECT)))); assertEquals(ACK, new BoundsList(new Bound(true, ASTToTargetAST.OBJECT)));
assertTrue(Bound.chainEquals(O, List.of(new Bound(true, TypePlaceholder.of("ACK")), new Bound(true, ASTToTargetAST.OBJECT)))); assertEquals(O, new BoundsList(new Bound(true, TypePlaceholder.of("ACK")), new Bound(true, ASTToTargetAST.OBJECT)));
var par2 = generics.resolve(main.getParameterList().getParameterAt(0).getType()); var par2 = generics.resolve(main.getParameterList().getParameterAt(0).getType());
var ACK2 = generics.getBounds(((RefType) par2).getParaList().get(0), result.clazz, add); var ACK2 = generics.getBounds(((RefType) par2).getParaList().get(0), result.clazz, add);
var V = generics.getBounds(add.getParameterList().getParameterAt(1).getType(), result.clazz, add); var V = generics.getBounds(add.getParameterList().getParameterAt(1).getType(), result.clazz, add);
assertTrue(Bound.chainEquals(ACK2, ACK)); assertEquals(ACK2, ACK);
assertTrue(Bound.chainEquals(V, O)); assertEquals(V, O);
} }
@Test @Test