fc smaller test

This commit is contained in:
Florian Steurer 2016-03-26 14:09:45 +01:00
parent 5e18496847
commit 257edfc0b3
2 changed files with 125 additions and 0 deletions

View File

@ -29,6 +29,8 @@ public class FiniteClosureBuilder {
public IFiniteClosure getCollectionExample() {
TypeFactory tf = new TypeFactory();
/* Collection */
Type collection = tf.getSimpleType("Collection");
Type set = tf.getSimpleType("Set", "T");
Type sortedSet = tf.getSimpleType("Set", "T");
@ -58,6 +60,22 @@ public class FiniteClosureBuilder {
add(arrayList, list);
add(stack, vector);
/* Map */
Type map = tf.getSimpleType("Map", "K", "V");
Type sortedMap = tf.getSimpleType("SortedMap", "K", "V");
Type navigableMap = tf.getSimpleType("NavigableMap", "K", "V");
Type treeMap = tf.getSimpleType("TreeMap", "K", "V");
Type hashMap = tf.getSimpleType("HashMap", "K", "V");
Type hashtable = tf.getSimpleType("Hashtable", "K", "V");
Type linkedHashMap = tf.getSimpleType("LinkedHashSet", "K", "V");
add(sortedMap, map);
add(hashMap, map);
add(hashtable, map);
add(navigableMap, sortedMap);
add(treeMap, navigableMap);
add(linkedHashMap, hashMap);
IFiniteClosure fc = getFiniteClosure();
clear();
return fc;

View File

@ -168,6 +168,7 @@ public class FiniteClosureTest {
/*
* Test Case 7:
*
* smaller(Set<NotInFc>) =
* { HashSet<NotInFc>, Set<NotInFc>, TreeSet<NotInFc>, LinkedHashSet<NotInFc>,
* HashSet<? ext NotInFc>, Set<? ext NotInFc>, TreeSet<? ext NotInFc>, LinkedHashSet<? ext NotInFc> }
@ -193,6 +194,112 @@ public class FiniteClosureTest {
/*
* Test Case 8:
*
* smaller(Set<? super NotInFC>) =
* { Set<NotInFC>, HashSet<NotInFC>, LinkedHashSet<NotInFC>, TreeSet<NotInFC>,
* Set<? super NotInFC>, HashSet<? super NotInFC>, LinkedHashSet<? super NotInFC>, TreeSet<? super NotInFc> }
*/
Type superNotInFc = tf.getSuperType(notInFc);
Type setSuperNotInFc = tf.getSimpleType("Set", superNotInFc);
Type hashSetSuperNotInFc = tf.getSimpleType("HashSet", superNotInFc);
Type treeSetSuperNotInFc = tf.getSimpleType("TreeSet", superNotInFc);
Type linkedHashSetSuperNotInFc = tf.getSimpleType("LinkedHashSet", superNotInFc);
expectedResult = new HashSet<>(Arrays.stream(new Type[] {
setNotInFc, hashSetNotInFc, treeSetNotInFc, linkedHashSetNotInFc,
setSuperNotInFc, hashSetSuperNotInFc, treeSetSuperNotInFc, linkedHashSetSuperNotInFc
}).collect(Collectors.toSet()));
Assert.assertEquals(expectedResult, fc.smaller(setSuperNotInFc));
/*
* Test Case 8:
*
* smaller(NotInFc<? extends Number>) =
* { NotInFc<Integer>, NotInFc<Number>, NotInFc<? extends Number>, NotInFc<? extends Integer> }
*/
Type notInFcExtNumber = tf.getSimpleType("NotInFc", extNum);
Type notInFcInteger = tf.getSimpleType("NotInFc", integer);
Type notInFcNumber = tf.getSimpleType("NotInFc", number);
Type notInFcExtInt = tf.getSimpleType("NotInFc", extInt);
expectedResult = new HashSet<>(Arrays.stream(new Type[] {
notInFcExtNumber, notInFcInteger, notInFcNumber, notInFcExtInt
}).collect(Collectors.toSet()));
Assert.assertEquals(expectedResult, fc.smaller(notInFcExtNumber));
/*
* Test Case 9:
*
* smaller(NotInFc<? super AlsoNotInFc> =
* { NotInFc<AlsoNotInFc>, NotInFc<? super AlsoNotInFc> }
*/
Type alsoNotInFc = tf.getSimpleType("AlsoNotInFc");
Type notInFcAlsoNotInFc = tf.getSimpleType("NotInFc", alsoNotInFc);
Type notInFcSupAlsoNotInFc = tf.getSimpleType("NotInFc", tf.getSuperType(alsoNotInFc));
expectedResult = new HashSet<>(Arrays.stream(new Type[] {
notInFcAlsoNotInFc, notInFcSupAlsoNotInFc
}).collect(Collectors.toSet()));
Set<Type> actual = fc.smaller(notInFcSupAlsoNotInFc);
Assert.assertEquals(expectedResult, actual);
/*
* Test Case 10:
*
* smaller(HashMap<? extends Number, ? super Integer>) =
* { HashMap<? extends Number, ? super Integer>, HashMap<? extends Number, ? super Number>, HashMap<? extends Number, Integer>, HashMap<? extends Number, Number>
* HashMap<Number, ? super Integer>, HashMap<Number, ? super Number>, HashMap<Number, Integer>, HashMap<Number, Number>,
* HashMap<Integer, ? super Integer, HashMap<Integer, ? super Number>, HashMap<Integer, Integer>, HashMap<Integer, Number>
* HashMap<? extends Integer, ? super Integer>, HashMap<? extends Integer, ? super Number>, HashMap<? extends Integer, Integer>, HashMap<? extends Integer, Number> }
*/
/*
* Test Case 11:
*
* smaller(SortedMap<Number, T>) = { SortedMap<Number, T>, NavigableMap<Number, T>, TreeMap<Number, T> }
*/
/*
* Test Case 12:
*
* MyMap<K, List<K>> <* HashMap<K, V>
*
* smaller(HashMap<Number, List<Number>) = { HashMap<Number, List<Number>>, MyMap<Number, List<Number>> }
*/
/*
* Test Case 13:
*
* MyMap<K, List<K>> <* HashMap<K, V>
*
* smaller(HashMap<? extends Number, List<Integer>) =
* { HashMap<? extends Integer>, List<Integer>>,
* HashMap<? extends Number, List<Integer>>,
* MyMap<Integer, List<Integer>> }
*/
/*
* Test Case 14
*
* MyMap<K, List<K>> <* HashMap<K, V>
*
* smaller(HashMap<? extends Number, List<? extends Number>) =
*/
/*
* Test Case 13:
*
* MyMap<K, List<K>> <* HashMap<K, V>
// * TODO sinnvoll ausformulieren
* smaller(HashMap<? extends Number, ? extends List< ? extends Integer>) =
* { HashMap<? extends Integer>, List<Integer>>,
* HashMap<? extends Number, List<Integer>>,
* MyMap<Integer, List<Integer>> }
*/
}