Skip to content
Generation of arbitrary case classes / ADTs instances with scalaprops and shapeless
Scala
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
core/shared/src/main/scala/scalaprops
project
test/shared/src
.gitignore
.sbtopts
.scalafmt.conf
.travis.yml
LICENSE
README.md
build.sbt
version.sbt

README.md

scalaprops-shapeless

Generation of arbitrary case classes / ADTs instances with scalaprops and shapeless ported from alexarchambault/scalacheck-shapeless.

Build Status Maven Central scaladoc Scala.js

Usage

Add to your build.sbt

libraryDependencies += "com.github.scalaprops" %% "scalaprops-shapeless" % "0.3.1"

scalaprops-shapeless depends on shapeless 2.3. It is built against scala 2.11, and 2.12.

Import the content of scalaprops.Shapeless close to where you want scalaprops.Gen type classes to be automatically available for case classes / sealed hierarchies,

import scalaprops.Shapeless._

//  If you defined:

// case class Foo(i: Int, s: String, blah: Boolean)
// case class Bar(foo: Foo, other: String)

// sealed trait Base
// case class BaseIntString(i: Int, s: String) extends Base
// case class BaseDoubleBoolean(d: Double, b: Boolean) extends Base

//  then you can now do

Gen[Foo]
Gen[Bar]
Gen[Base]

and in particular, while writing property-based tests,

val `some property about Foo` = Property.forAll {
  foo: Foo =>
    // Ensure foo has the required property
}

without having to define yourself a scalaprops.Gen for Foo.

Credits

scalaprops-shapeless ported from alexarchambault/scalacheck-shapeless

License

Released under the Apache 2 license. See LICENSE file for more details.

You can’t perform that action at this time.