@Test
public void testFindLabelsAliasesAllDefinite() {
FusionEnvironment<?> env = new FusionEnvironment<TestAliasContext>(aliases, null, null, testH, new InferenceEnvironment(null), Variant.PRAGMATIC_VARIANT);
FreeVars fv = new FreeVars().addVar(new SpecVar("a"), "Foo").addVar(new SpecVar("b"), "Bar");
Substitution existing = new Substitution().addSub(new SpecVar("a"), labels[0]).addSub(new SpecVar("b"), labels[1]);
fv = fv.addVar(new SpecVar("c"), "Foo");
List<Substitution> subs = env.allValidSubs(existing, fv);
Iterator<Substitution> itr = subs.iterator();
assertTrue(itr.hasNext());
Substitution subA = itr.next();
assertTrue(itr.hasNext());
Substitution subB = itr.next();
assertTrue(itr.hasNext());
Substitution subC = itr.next();
assertTrue(!itr.hasNext());
assertEquals(3, subA.size());
assertEquals(3, subB.size());
assertEquals(3, subC.size());
if (subA.getSub(new SpecVar("c")).equals(labels[0])) {
if (subB.getSub(new SpecVar("c")).equals(labels[3])) {
assertEquals(labels[4], subC.getSub(new SpecVar("c")));
}
else {
assertEquals(labels[4], subB.getSub(new SpecVar("c")));
assertEquals(labels[3], subC.getSub(new SpecVar("c")));
}
}
else if (subA.getSub(new SpecVar("c")).equals(labels[3])) {
if (subB.getSub(new SpecVar("c")).equals(labels[0])) {
assertEquals(labels[4], subC.getSub(new SpecVar("c")));
}
else {
assertEquals(labels[4], subB.getSub(new SpecVar("c")));
assertEquals(labels[0], subC.getSub(new SpecVar("c")));
}
}
else {
assertEquals(labels[4], subA.getSub(new SpecVar("c")));
if (subB.getSub(new SpecVar("c")).equals(labels[0])) {
assertEquals(labels[3], subC.getSub(new SpecVar("c")));
}
else {
assertEquals(labels[3], subB.getSub(new SpecVar("c")));
assertEquals(labels[0], subC.getSub(new SpecVar("c")));
}
}
}