scalacheck-magnolia


License

License

Categories

Categories

Scala Languages
GroupId

GroupId

com.mrdziuban
ArtifactId

ArtifactId

scalacheck-magnolia_sjs0.6_2.11
Last Version

Last Version

0.0.4
Release Date

Release Date

Type

Type

jar
Description

Description

scalacheck-magnolia
scalacheck-magnolia
Project URL

Project URL

https://github.com/mrdziuban/scalacheck-magnolia
Project Organization

Project Organization

com.mrdziuban
Source Code Management

Source Code Management

https://github.com/mrdziuban/scalacheck-magnolia

Download scalacheck-magnolia_sjs0.6_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/com.mrdziuban/scalacheck-magnolia_sjs0.6_2.11/ -->
<dependency>
    <groupId>com.mrdziuban</groupId>
    <artifactId>scalacheck-magnolia_sjs0.6_2.11</artifactId>
    <version>0.0.4</version>
</dependency>
// https://jarcasting.com/artifacts/com.mrdziuban/scalacheck-magnolia_sjs0.6_2.11/
implementation 'com.mrdziuban:scalacheck-magnolia_sjs0.6_2.11:0.0.4'
// https://jarcasting.com/artifacts/com.mrdziuban/scalacheck-magnolia_sjs0.6_2.11/
implementation ("com.mrdziuban:scalacheck-magnolia_sjs0.6_2.11:0.0.4")
'com.mrdziuban:scalacheck-magnolia_sjs0.6_2.11:jar:0.0.4'
<dependency org="com.mrdziuban" name="scalacheck-magnolia_sjs0.6_2.11" rev="0.0.4">
  <artifact name="scalacheck-magnolia_sjs0.6_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.mrdziuban', module='scalacheck-magnolia_sjs0.6_2.11', version='0.0.4')
)
libraryDependencies += "com.mrdziuban" % "scalacheck-magnolia_sjs0.6_2.11" % "0.0.4"
[com.mrdziuban/scalacheck-magnolia_sjs0.6_2.11 "0.0.4"]

Dependencies

compile (4)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.12
org.scala-js : scalajs-library_2.11 jar 0.6.24
org.scalacheck : scalacheck_sjs0.6_2.11 jar 1.14.0
com.propensive : magnolia_sjs0.6_2.11 jar 0.10.0

test (1)

Group / Artifact Type Version
org.scala-js : scalajs-test-interface_2.11 jar 0.6.24

Project Modules

There are no modules declared in this project.

scalacheck-magnolia

scalacheck-magnolia performs generic derivation of scalacheck Arbitrary instances for product and sum types, i.e. case classes and ADTs, using Magnolia. Much of the code was inspired by scalacheck-shapeless, which I've found to work reliably, but cause huge compile time increases, especially for deeply nested case classes.

Usage

Add to your build.sbt:

resolvers += Resolver.bintrayRepo("mrdziuban", "scalacheck-magnolia")
libraryDependencies += "com.mrdziuban" %% "scalacheck-magnolia" % "0.2.1"

This will pull in scalacheck 1.14.3 and magnolia 0.16.0.

To materialize Arbitrary instances for your case classes or sealed traits, import com.mrdziuban.ScalacheckMagnolia._. Magnolia can derive Arbitrary instances for case classes

import com.mrdziuban.ScalacheckMagnolia._
import org.scalacheck.Arbitrary

case class Test(i: Int, b: Boolean, s: String)

implicitly[Arbitrary[Test]]

as well as for sealed traits

sealed trait Foo
case object Bar extends Foo
case class Baz(s: String) extends Foo

implicitly[Arbitrary[Foo]]

It can be used in scalacheck property tests like so:

import org.scalacheck.Prop.forAll

forAll((_: Test) => true /* check some properties of Test */)

License

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

Versions

Version
0.0.4
0.0.3
0.0.2
0.0.1