Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix implicits priority #198

Merged
merged 3 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions scalacheck/src/io/github/iltotore/iron/scalacheck/all.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.github.iltotore.iron.scalacheck

object all:
export any.given
object all extends AnyArbitrary:
export char.given
export collection.given
export numeric.given
Expand Down
8 changes: 5 additions & 3 deletions scalacheck/src/io/github/iltotore/iron/scalacheck/any.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import org.scalacheck.Arbitrary.arbitrary

import scala.compiletime.constValue

object any extends LowPriorityArbitrary:
object any extends AnyArbitrary

trait AnyArbitrary extends LowPriorityArbitrary:

inline given strictEqual[A, V <: A]: Arbitrary[A :| StrictEqual[V]] = Arbitrary(Gen.oneOf(Seq(constValue[V]))).asInstanceOf

inline given union[A, C](using IsUnion[C]): Arbitrary[A :| C] = Arbitrary(unionGen[A, C])

trait LowPriorityArbitrary extends LowPriorityArbitrary2:
Expand All @@ -22,4 +24,4 @@ trait LowPriorityArbitrary extends LowPriorityArbitrary2:
trait LowPriorityArbitrary2:

inline given fallback[A: Arbitrary, C](using inline constraint: Constraint[A, C]): Arbitrary[A :| C] =
Arbitrary(arbitrary.filter(constraint.test(_))).asInstanceOf
Arbitrary(arbitrary.filter(constraint.test(_))).asInstanceOf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object CollectionSuite extends TestSuite:
}
test("empty") {
test("seq") - testGen[Seq[Boolean], Empty]
test("string") - testGen[Seq[Boolean], Empty]
test("string") - testGen[String, Empty]
}
test("contain") {
test("seq") - testGen[Seq[Boolean], Contain[true]]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.github.iltotore.iron.scalacheck

import io.github.iltotore.iron.constraint.all.*
import io.github.iltotore.iron.scalacheck.all.given
import utest.*

object ImplicitsOrderingSuite extends TestSuite:

val tests: Tests = Tests {
test("should resolve implicits using all.given import") - testGen[String, Empty]
}
Loading