Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scalaprops/scalaprops-shapeless
Generation of arbitrary case classes / ADTs instances with scalaprops and shapeless
https://github.com/scalaprops/scalaprops-shapeless
scala scala-native scalajs scalaprops scalaz shapeless testing
Last synced: 25 days ago
JSON representation
Generation of arbitrary case classes / ADTs instances with scalaprops and shapeless
- Host: GitHub
- URL: https://github.com/scalaprops/scalaprops-shapeless
- Owner: scalaprops
- License: apache-2.0
- Created: 2017-01-08T03:16:10.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-11-15T02:40:55.000Z (28 days ago)
- Last Synced: 2024-11-15T03:26:29.770Z (28 days ago)
- Topics: scala, scala-native, scalajs, scalaprops, scalaz, shapeless, testing
- Language: Scala
- Homepage:
- Size: 422 KB
- Stars: 10
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- awesome-scala-native - scalaprops-shapeless - Generation of arbitrary ADT instances. (Unit Tests)
README
# scalaprops-shapeless
Generation of arbitrary case classes / ADTs instances with [scalaprops](https://github.com/scalaprops/scalaprops) and [shapeless](https://github.com/milessabin/shapeless) ported from [alexarchambault/scalacheck-shapeless](https://github.com/alexarchambault/scalacheck-shapeless).
[![Maven Central](https://img.shields.io/maven-central/v/com.github.scalaprops/scalaprops-shapeless_3.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.scalaprops/scalaprops-shapeless_3)
[![scaladoc](https://javadoc.io/badge2/com.github.scalaprops/scalaprops-shapeless_3/javadoc.svg)](https://javadoc.io/doc/com.github.scalaprops/scalaprops-shapeless_3)## Usage
Add to your `build.sbt`
```scala
libraryDependencies += "com.github.scalaprops" %% "scalaprops-shapeless" % "0.6.0"
```Import the content of `scalaprops.ScalapropsShapeless` close to where you want
`scalaprops.Gen` type classes to be automatically available for case classes / sealed hierarchies,```scala
import scalaprops.ScalapropsShapeless._// 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,
```scala
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](https://github.com/alexarchambault/scalacheck-shapeless)
## License
Released under the Apache 2 license. See LICENSE file for more details.