2009-10-19 04:25:50 +02:00
|
|
|
package xsbt.boot
|
|
|
|
|
|
|
|
|
|
import org.scalacheck._
|
|
|
|
|
import Prop._
|
|
|
|
|
|
|
|
|
|
object CacheTest extends Properties("Cache")
|
|
|
|
|
{
|
2012-07-31 17:52:10 +02:00
|
|
|
implicit val functions: Arbitrary[Int => Int] = Arbitrary { Gen.oneOf( Seq(identity[Int], i => -i, i=>i/2, i => i+1) ) }
|
2009-10-19 04:25:50 +02:00
|
|
|
|
|
|
|
|
property("Cache") = Prop.forAll { (key: Int, keys: List[Int], map: Int => Int) =>
|
2011-04-13 04:58:32 +02:00
|
|
|
val cache = new Cache( (i: Int, _: Unit) => map(i) )
|
|
|
|
|
def toProperty(key: Int) = ("Key " + key) |: ("Value: " + map(key)) |: (cache.apply(key, ()) == map(key))
|
2009-10-19 04:25:50 +02:00
|
|
|
Prop.all( keys.map(toProperty) : _*)
|
|
|
|
|
}
|
|
|
|
|
}
|