From 6f0598993c035b057ebd3fd4e845a087bc132691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20W=C3=B3jcik?= Date: Tue, 19 Dec 2023 15:31:53 +0100 Subject: [PATCH 1/3] Add test case --- .../iron/scalacheck/ImplicitsOrderingSuite.scala | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 scalacheck/test/src/io/github/iltotore/iron/scalacheck/ImplicitsOrderingSuite.scala diff --git a/scalacheck/test/src/io/github/iltotore/iron/scalacheck/ImplicitsOrderingSuite.scala b/scalacheck/test/src/io/github/iltotore/iron/scalacheck/ImplicitsOrderingSuite.scala new file mode 100644 index 00000000..8c6bc213 --- /dev/null +++ b/scalacheck/test/src/io/github/iltotore/iron/scalacheck/ImplicitsOrderingSuite.scala @@ -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] + } From f854a2654441bf60c89cee291a52f28105558f30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20W=C3=B3jcik?= Date: Tue, 19 Dec 2023 15:32:07 +0100 Subject: [PATCH 2/3] Fix empty string test case --- .../io/github/iltotore/iron/scalacheck/CollectionSuite.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scalacheck/test/src/io/github/iltotore/iron/scalacheck/CollectionSuite.scala b/scalacheck/test/src/io/github/iltotore/iron/scalacheck/CollectionSuite.scala index 3b10c624..ac46858c 100644 --- a/scalacheck/test/src/io/github/iltotore/iron/scalacheck/CollectionSuite.scala +++ b/scalacheck/test/src/io/github/iltotore/iron/scalacheck/CollectionSuite.scala @@ -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]] From 12991b00f42d86ce2c3c447d9ed1687a32c364b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20W=C3=B3jcik?= Date: Tue, 19 Dec 2023 15:33:23 +0100 Subject: [PATCH 3/3] Fixes implicits ordering --- .../src/io/github/iltotore/iron/scalacheck/all.scala | 3 +-- .../src/io/github/iltotore/iron/scalacheck/any.scala | 8 +++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/scalacheck/src/io/github/iltotore/iron/scalacheck/all.scala b/scalacheck/src/io/github/iltotore/iron/scalacheck/all.scala index ef27aeff..5b0a05dd 100644 --- a/scalacheck/src/io/github/iltotore/iron/scalacheck/all.scala +++ b/scalacheck/src/io/github/iltotore/iron/scalacheck/all.scala @@ -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 diff --git a/scalacheck/src/io/github/iltotore/iron/scalacheck/any.scala b/scalacheck/src/io/github/iltotore/iron/scalacheck/any.scala index 2049c461..5be904d2 100644 --- a/scalacheck/src/io/github/iltotore/iron/scalacheck/any.scala +++ b/scalacheck/src/io/github/iltotore/iron/scalacheck/any.scala @@ -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: @@ -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 \ No newline at end of file + Arbitrary(arbitrary.filter(constraint.test(_))).asInstanceOf