All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hedgehog.state.package.scala Maven / Gradle / Ivy

There is a newer version: 0.11.0
Show newest version
package hedgehog

import hedgehog.state.Action._

import scala.concurrent._
import scala.concurrent.duration._

package object state {

  def sequential[S](
      range: Range[Int]
    , initial: S
    , commands: List[CommandIO[S]]
    , cleanup: () => Unit
    ): Property =
    genActions(range, commands, Context.create(initial)).map(_._2)
      .forAllWithLog(Runner.renderActions(_))
      .map(actions =>
        try {
          executeSequential(initial, actions)
        } finally {
          cleanup()
        }
      )

  def parallel[S](
      prefixN: Range[Int]
    , parallelN: Range[Int]
    , initial: S
    , commands: List[CommandIO[S]]
    , cleanup: () => Unit
    )(implicit E: ExecutionContext): Property =
    genParallel(prefixN, parallelN, initial, commands)
      .forAllWithLog(Runner.renderParallel(_))
      .map(actions =>
        try {
          Await.result(executeParallel(initial, actions), Duration.Inf)
        } finally {
          cleanup()
        }
      )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy