funN greater

This commit is contained in:
Florian Steurer 2016-04-07 22:30:30 +02:00
parent 53cfb4b046
commit b7f41c4d13
2 changed files with 46 additions and 4 deletions

View File

@ -241,8 +241,22 @@ public class FiniteClosure implements IFiniteClosure {
}
protected Set<UnifyType> computeGreaterFunN(FunNType type) {
// TODO Auto-generated method stub
return null;
Set<UnifyType> result = new HashSet<>();
// if T = T' then T <=* T'
result.add(type);
ArrayList<Set<UnifyType>> paramCandidates = new ArrayList<>();
paramCandidates.add(greater(type.getTypeParams().get(0)));
for (int i = 1; i < type.getTypeParams().size(); i++)
paramCandidates.add(smaller(type.getTypeParams().get(i)));
Set<TypeParams> permResult = permuteParams(paramCandidates);
for (TypeParams newParams : permResult)
result.add(type.setTypeParams(newParams));
return result;
}

View File

@ -169,7 +169,7 @@ public class FiniteClosureTest {
setExtT1, hashSetExtT1, treeSetExtT1, linkedHashSetExtT1
}).collect(Collectors.toSet()));
System.out.println(fc.smaller(setExtT1));
//System.out.println(fc.smaller(setExtT1));
Assert.assertEquals(expectedResult, fc.smaller(setExtT1));
/*
@ -424,7 +424,7 @@ public class FiniteClosureTest {
}).collect(Collectors.toSet()));
actual = fc.smaller(funNNumber);
System.out.println(actual);
//System.out.println(actual);
Assert.assertEquals(expectedResult, actual);
}
@ -664,6 +664,34 @@ public class FiniteClosureTest {
* greater(SortedMap<? super Number>, ? super List<? extends Integer>>) =
*
*/
/*
* Test Case 14:
*
* greater(FunN<Number, Number, Number>) =
* { FunN<Number, Number, Number>, FunN<Number, Object, Number>,
* FunN<Number, Number, Object>, FunN<Number, Object, Object>,
* FunN<Integer, Number, Number>, FunN<Integer, Object, Number>,
* FunN<Integer, Number, Object>, FunN<Integer, Object, Object> }
*/
UnifyType object = tf.getSimpleType("Object");
fcb = new FiniteClosureBuilder();
fcb.add(integer, number);
fcb.add(number, object);
fc = fcb.getCollectionExample();
UnifyType funNNumber = tf.getFunNType(number, number, number);
expectedResult = new HashSet<>(Arrays.stream(new UnifyType[] {
tf.getFunNType(number, number, number), tf.getFunNType(number, integer, number),
tf.getFunNType(number, number, integer), tf.getFunNType(number, integer, integer),
tf.getFunNType(object, number, number), tf.getFunNType(object, integer, number),
tf.getFunNType(object, number, integer), tf.getFunNType(object, integer, integer)
}).collect(Collectors.toSet()));
actual = fc.greater(funNNumber);
Assert.assertEquals(expectedResult, actual);
}
@Test