Coder Social home page Coder Social logo

scala-steward / scalacheck-shapeless Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alexarchambault/scalacheck-shapeless

0.0 0.0 0.0 512 KB

Generation of arbitrary case classes / ADTs instances with scalacheck and shapeless

License: Apache License 2.0

Scala 100.00%

scalacheck-shapeless's Introduction

scalacheck-shapeless

Generation of arbitrary case classes / ADTs instances with scalacheck and shapeless

Build status Maven Central Gitter

Usage

Add to your build.sbt

libraryDependencies += "com.github.alexarchambault" %% "scalacheck-shapeless_1.16" % "1.3.1"

scalacheck-shapeless depends on shapeless 2.3 and scalacheck 1.16. It is built against scala 2.12, and 2.13.

Import the content of org.scalacheck.ScalacheckShapeless close to where you want Arbitrary type classes to be automatically available for case classes / sealed hierarchies,

import org.scalacheck.ScalacheckShapeless._

//  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

implicitly[Arbitrary[Foo]]
implicitly[Arbitrary[Bar]]
implicitly[Arbitrary[Base]]

and in particular, while writing property-based tests,

property("some property about Foo") {
  forAll { foo: Foo =>
    // Ensure foo has the required property
  }
}

without having to define yourself an Arbitrary for Foo.

See also

License

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

Code of Conduct

See the Code of Conduct

scalacheck-shapeless's People

Contributors

alexarchambault avatar benfradet avatar cvogt avatar dependabot[bot] avatar gitter-badger avatar howyp avatar ijuma avatar isomarcte avatar jorokr21 avatar rossabaker avatar scala-steward avatar timvw avatar xuwei-k avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.