Skip to content

Commit

Permalink
Merge pull request #170 from fthomas/topic/EqualArbitrary
Browse files Browse the repository at this point in the history
Add Arbitrary instance for Equal
  • Loading branch information
fthomas committed May 18, 2016
2 parents c888790 + 2260c6b commit acee516
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package eu.timepit.refined
package scalacheck

import eu.timepit.refined.api.RefType
import eu.timepit.refined.generic.Equal
import org.scalacheck.{ Arbitrary, Gen }
import shapeless.Witness

/** Module that provides `Arbitrary` instances for generic predicates. */
object generic {

implicit def equalArbitrary[F[_, _]: RefType, T, U <: T](
implicit
wu: Witness.Aux[U]
): Arbitrary[F[T, Equal[U]]] =
arbitraryRefType(Gen.const(wu.value))
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import org.scalacheck.Gen.Choose
import shapeless.{ Nat, Witness }
import shapeless.ops.nat.ToInt

/**
* Module that provides `Arbitrary` instances and generators for
* numeric predicates.
*/
object numeric {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package eu.timepit.refined
package scalacheck

import eu.timepit.refined.api.Refined
import eu.timepit.refined.generic.Equal
import eu.timepit.refined.scalacheck.generic._
import org.scalacheck.Properties

class GenericArbitrarySpec extends Properties("GenericArbitrary") {

property("Equal") =
checkArbitraryRefType[Refined, Int, Equal[W.`100`.T]]
}
2 changes: 2 additions & 0 deletions notes/0.4.1.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
val y: Int Refined Eval[W.`"(x: Int) => x > 0"`.T] = 1
```
([#153])
* Add `Arbitrary` instance for `Equal`. ([#170])

### Updates

Expand All @@ -24,3 +25,4 @@
[#155]: https://github.com/fthomas/refined/pull/155
[#160]: https://github.com/fthomas/refined/pull/160
[#165]: https://github.com/fthomas/refined/pull/165
[#170]: https://github.com/fthomas/refined/pull/170

0 comments on commit acee516

Please sign in to comment.