scalaprops.Scalaprops.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scalaprops_2.10 Show documentation
Show all versions of scalaprops_2.10 Show documentation
property based testing library for Scala
package scalaprops
import scalaz._
trait Scalaprops {
def param: Param = Param.withCurrentTimeSeed()
def listener: ScalapropsListener =
ScalapropsListener.default
def transformProperties[A](properties: List[Properties[A]]): List[Properties[A]] =
properties.map(Scalaprops.filterUnitEmpty).sortBy(_.id.toString)
}
object Scalaprops {
def filterUnitEmpty[A](p: Properties[A]): Properties[A] = {
def loop(tree: Tree[(A, Maybe[Check])]): Tree[(A, Maybe[Check])] =
tree match {
case Tree.Node(root, Stream(Tree.Node((Or.L(()), Maybe.Empty()), sub))) =>
Tree.node(root, sub.map(loop))
case Tree.Node((root, Maybe.Empty()), Stream(Tree.Node(((), sub1), sub2))) =>
Tree.node(root -> sub1, sub2.map(loop))
case _ =>
Tree.node(tree.rootLabel, tree.subForest.map(loop))
}
Properties.noSort(loop(p.props))
}
}