mercredi 30 mai 2018

Property based testing in java

I have an assignment where I have to pass the following test. Problem is I dont understand what the test does. Can someone explain it to me step by step?

    public Property remove_if() {
    return property(isKVList, arbF(cogenInteger, arbBoolean), (kvs, predicate) -> {
        SortedTreeMap<Integer, String> tm = new SortedTreeMap<>(intOrd.toComparator());
        kvs.foreachDoEffect(kv -> tm.add(kv._1(), kv._2()));

        tm.removeIf((key, value) -> predicate.f(key));

        List<Integer> keys = fromIterator(tm.keys().iterator());
        List<Integer> kept_sorted = kvs.map(P2::_1).filter(key -> !predicate.f(key)).sort(intOrd);

        return prop(intListEqual.eq(keys, kept_sorted));
    });
}

Aucun commentaire:

Enregistrer un commentaire