diff --git a/tests/plugin/BST.scala b/tests/plugin/BST.scala index f7a684e125b2fe3e31243cdc2b84fd83c1a325a7..09ed9cb80413ebd97ec05edcb2d51aea4067f5bb 100644 --- a/tests/plugin/BST.scala +++ b/tests/plugin/BST.scala @@ -47,8 +47,8 @@ object BST extends Application { } /** global assertions */ - forAll[(BST,Int)]( p => contains(p._2,p._1) == content(p._1).contains(p._2)) - forAll[(BST,Int)]( p => content(add(p._2, p._1)) == content(p._1) + p._2) + forAll{ p: (BST,Int) => contains(p._2,p._1) == content(p._1).contains(p._2)} + forAll{ p: (BST,Int) => content(add(p._2, p._1)) == content(p._1) + p._2} } diff --git a/tests/plugin/kawaguchi/MapReduce.scala b/tests/plugin/kawaguchi/MapReduce.scala index 97e2ddefbc6775779153cb5897d9b90d3dc8443f..beba264d687b915d172d8455009e0031a6721c26 100644 --- a/tests/plugin/kawaguchi/MapReduce.scala +++ b/tests/plugin/kawaguchi/MapReduce.scala @@ -5,19 +5,27 @@ package plugin.kawaguchi import funcheck.lib.Specs._ +import scala.collection.immutable.Multiset + object MapReduce { /* specification */ - def insert(map: Map[Int, List[Int]], entry: (Int, Int)): Map[Int, List[Int]] = { + def insert(map: Map[Int, Multiset[Int]], entry: (Int, Int)): Map[Int, Multiset[Int]] = { val (key,value) = entry map.get(key) match { - case None => map + ((key, List(value))) - case Some(vs) => map + ((key, value :: vs)) + case None => map + ((key, Multiset(value))) + case Some(vs) => map + ((key, vs +++ List(value))) } } - def content(kvs: List[(Int, List[Int])]) = - Map.empty[Int, List[Int]] ++ (kvs) + def content(kvs: List[(Int, List[Int])]): Map[Int, Multiset[Int]] = + (Map.empty[Int, Multiset[Int]] /: kvs) { + case (map,(key,values)) => + (map /: values) { + case (map,v) => insert(map,(key,v)) + } + } + /*****************************************/ @@ -55,7 +63,7 @@ object MapReduce { def collapse(f: (Int,Int) => Int, gs: List[(Int, List[Int])]): List[(Int, Int)] = { val collapser = { x: (Int, List[Int]) => x match { - case (k, Nil) => assert(false); null + case (k, Nil) => error("cannot collapse") case (k, v :: vs) => (k, vs.foldLeft(v)((z: Int,a: Int) => f(z,a))) }