ScalaCheck 1.14.0 was just released with support for deterministic testing using seeds. Some folks have asked for examples, so I wanted to produce a Gist to help people use this feature.
These examples will assume the following imports:
import scala.concurrent._ | |
import scala.collection.mutable.Builder | |
import scala.collection.generic.CanBuildFrom | |
import language.higherKinds | |
/** | |
* Linearize asynchrnously applies a given function in-order to a sequence of values, producing a Future with the result of the function applications. | |
* Execution of subsequent entries will be aborted if an exception is thrown in the application of the function. | |
*/ | |
def linearize[T, U, C[T] <: Traversable[T]](s: C[T])(f: T => U)(implicit cbf: CanBuildFrom[C[T], U, C[U]], e: ExecutionContext): Future[C[U]] = { |
miles@frege:~$ ./shapeless.sh | |
Loading... | |
Welcome to the Ammonite Repl 0.5.2 | |
(Scala 2.11.7 Java 1.8.0_51) | |
@ val l = 23 :: "foo" :: true :: HNil | |
l: Int :: String :: Boolean :: HNil = ::(23, ::("foo", ::(true, HNil))) | |
@ |
package set.performance | |
import java.util.concurrent.TimeUnit | |
import scala.concurrent.duration.FiniteDuration | |
/** | |
* On my machine the fast method takes < 2 ms, the slow one 2.2s | |
*/ | |
object SetPerformance { |
scala> import frdomain.ch8.cqrs.service._ | |
import frdomain.ch8.cqrs.service._ | |
scala> import Scripts._ | |
import Scripts._ | |
scala> import RepositoryBackedAccountInterpreter._ | |
import RepositoryBackedAccountInterpreter._ | |
scala> RepositoryBackedAccountInterpreter(composite) |