From 7ab14ced77cfa6d7cae7759bbdbf3f9511465d77 Mon Sep 17 00:00:00 2001 From: Matt Dziuban Date: Wed, 5 Jul 2023 17:34:23 -0400 Subject: [PATCH] Move tests to `scalacheck.tests` package. --- .../tests}/ArbitrarySpecification.scala | 7 +-- .../tests}/ChooseSpecification.scala | 5 ++- .../tests}/CogenSpecification.scala | 5 ++- .../tests}/GenSpecification.scala | 23 +++++----- .../tests}/LazyPropertiesSpecification.scala | 4 +- .../tests}/PropertyFilterSpecification.scala | 7 +-- .../tests}/SerializabilitySpecification.scala | 8 ++-- .../tests}/ShrinkSpecificationJVM.scala | 11 ++--- .../tests}/TestAll.scala | 4 +- .../tests}/TestSpecification.scala | 44 +++++++++---------- .../CommandsShrinkSpecification.scala | 3 +- .../CommandsSpecification.scala | 3 +- .../tests}/examples/IntMapSpec.scala | 2 +- .../tests}/examples/StringUtils.scala | 2 +- .../tests}/rng/SeedSpecification.scala | 8 ++-- .../tests}/time/ShrinkSpecification.scala | 2 +- .../org/scalacheck/ScalaVersionSpecific.scala | 8 ---- .../org/scalacheck/ScalaVersionSpecific.scala | 2 - .../tests/ScalaVersionSpecific.scala | 23 ++++++++++ .../tests}/time/OrderingVersionSpecific.scala | 2 +- .../tests/ScalaVersionSpecific.scala | 14 ++++++ .../tests}/time/OrderingVersionSpecific.scala | 2 +- .../NoPropertyNestingSpecification.scala | 4 +- .../tests}/PropSpecification.scala | 18 ++++---- .../tests}/ShrinkSpecification.scala | 7 +-- .../tests}/StatsSpecification.scala | 7 +-- .../tests}/TestFingerprint.scala | 4 +- .../tests}/examples/Examples.scala | 2 +- .../tests}/examples/MathSpec.scala | 2 +- .../tests}/util/BuildableSpecification.scala | 4 +- .../tests}/util/PrettySpecification.scala | 3 +- 31 files changed, 147 insertions(+), 93 deletions(-) rename core/jvm/src/test/scala/{org/scalacheck => scalacheck/tests}/ArbitrarySpecification.scala (91%) rename core/jvm/src/test/scala/{org/scalacheck => scalacheck/tests}/ChooseSpecification.scala (98%) rename core/jvm/src/test/scala/{org/scalacheck => scalacheck/tests}/CogenSpecification.scala (98%) rename core/jvm/src/test/scala/{org/scalacheck => scalacheck/tests}/GenSpecification.scala (97%) rename core/jvm/src/test/scala/{org/scalacheck => scalacheck/tests}/LazyPropertiesSpecification.scala (89%) rename core/jvm/src/test/scala/{org/scalacheck => scalacheck/tests}/PropertyFilterSpecification.scala (93%) rename core/jvm/src/test/scala/{org/scalacheck => scalacheck/tests}/SerializabilitySpecification.scala (94%) rename core/jvm/src/test/scala/{org/scalacheck => scalacheck/tests}/ShrinkSpecificationJVM.scala (72%) rename core/jvm/src/test/scala/{org/scalacheck => scalacheck/tests}/TestAll.scala (90%) rename core/jvm/src/test/scala/{org/scalacheck => scalacheck/tests}/TestSpecification.scala (81%) rename core/jvm/src/test/scala/{org/scalacheck => scalacheck/tests}/commands/CommandsShrinkSpecification.scala (98%) rename core/jvm/src/test/scala/{org/scalacheck/commands => scalacheck/tests/commands/CommandsSpecification.scala}/CommandsSpecification.scala (97%) rename core/jvm/src/test/scala/{org/scalacheck => scalacheck/tests}/examples/IntMapSpec.scala (98%) rename core/jvm/src/test/scala/{org/scalacheck => scalacheck/tests}/examples/StringUtils.scala (98%) rename core/jvm/src/test/scala/{org/scalacheck => scalacheck/tests}/rng/SeedSpecification.scala (91%) rename core/jvm/src/test/scala/{org/scalacheck => scalacheck/tests}/time/ShrinkSpecification.scala (95%) create mode 100644 core/shared/src/test/scala-2.12-/scalacheck/tests/ScalaVersionSpecific.scala rename core/shared/src/test/scala-2.12-/{org/scalacheck => scalacheck/tests}/time/OrderingVersionSpecific.scala (96%) create mode 100644 core/shared/src/test/scala-2.13+/scalacheck/tests/ScalaVersionSpecific.scala rename core/shared/src/test/scala-2.13+/{org/scalacheck => scalacheck/tests}/time/OrderingVersionSpecific.scala (93%) rename core/shared/src/test/scala/{org/scalacheck => scalacheck/tests}/NoPropertyNestingSpecification.scala (93%) rename core/shared/src/test/scala/{org/scalacheck => scalacheck/tests}/PropSpecification.scala (95%) rename core/shared/src/test/scala/{org/scalacheck => scalacheck/tests}/ShrinkSpecification.scala (96%) rename core/shared/src/test/scala/{org/scalacheck => scalacheck/tests}/StatsSpecification.scala (93%) rename core/shared/src/test/scala/{org/scalacheck => scalacheck/tests}/TestFingerprint.scala (87%) rename core/shared/src/test/scala/{org/scalacheck => scalacheck/tests}/examples/Examples.scala (97%) rename core/shared/src/test/scala/{org/scalacheck => scalacheck/tests}/examples/MathSpec.scala (93%) rename core/shared/src/test/scala/{org/scalacheck => scalacheck/tests}/util/BuildableSpecification.scala (94%) rename core/shared/src/test/scala/{org/scalacheck => scalacheck/tests}/util/PrettySpecification.scala (96%) diff --git a/core/jvm/src/test/scala/org/scalacheck/ArbitrarySpecification.scala b/core/jvm/src/test/scala/scalacheck/tests/ArbitrarySpecification.scala similarity index 91% rename from core/jvm/src/test/scala/org/scalacheck/ArbitrarySpecification.scala rename to core/jvm/src/test/scala/scalacheck/tests/ArbitrarySpecification.scala index 6249fced..8253d754 100644 --- a/core/jvm/src/test/scala/org/scalacheck/ArbitrarySpecification.scala +++ b/core/jvm/src/test/scala/scalacheck/tests/ArbitrarySpecification.scala @@ -7,12 +7,13 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck +package scalacheck.tests import java.util.concurrent.TimeUnit -import Prop._ -import Arbitrary._ +import org.scalacheck.{Arbitrary, Gen, Prop, Properties} +import org.scalacheck.Prop._ +import org.scalacheck.Arbitrary._ object ArbitrarySpecification extends Properties("Arbitrary") { val genOptionUnits = diff --git a/core/jvm/src/test/scala/org/scalacheck/ChooseSpecification.scala b/core/jvm/src/test/scala/scalacheck/tests/ChooseSpecification.scala similarity index 98% rename from core/jvm/src/test/scala/org/scalacheck/ChooseSpecification.scala rename to core/jvm/src/test/scala/scalacheck/tests/ChooseSpecification.scala index f3e28f4b..7f5f156a 100644 --- a/core/jvm/src/test/scala/org/scalacheck/ChooseSpecification.scala +++ b/core/jvm/src/test/scala/scalacheck/tests/ChooseSpecification.scala @@ -7,7 +7,7 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck +package scalacheck.tests import java.time._ import java.time.temporal.ChronoUnit @@ -16,7 +16,8 @@ import scala.util.Failure import scala.util.Success import scala.util.Try -import Gen._ +import org.scalacheck.{Arbitrary, Gen, Prop, Properties} +import org.scalacheck.Gen._ object ChooseSpecification extends Properties("Choose") with time.OrderingVersionSpecific { diff --git a/core/jvm/src/test/scala/org/scalacheck/CogenSpecification.scala b/core/jvm/src/test/scala/scalacheck/tests/CogenSpecification.scala similarity index 98% rename from core/jvm/src/test/scala/org/scalacheck/CogenSpecification.scala rename to core/jvm/src/test/scala/scalacheck/tests/CogenSpecification.scala index 7446e727..631e586b 100644 --- a/core/jvm/src/test/scala/org/scalacheck/CogenSpecification.scala +++ b/core/jvm/src/test/scala/scalacheck/tests/CogenSpecification.scala @@ -7,11 +7,11 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck +package scalacheck.tests +import org.scalacheck.{Arbitrary, Cogen, Prop, Properties} import org.scalacheck.Arbitrary.arbitrary import org.scalacheck.Gen.listOfN -import org.scalacheck.GenSpecification.arbSeed import org.scalacheck.Prop.forAll import org.scalacheck.rng.Seed @@ -22,6 +22,7 @@ import scala.collection.immutable.SortedSet import scala.concurrent.duration.Duration import scala.concurrent.duration.FiniteDuration import scala.util.Try +import GenSpecification.arbSeed import ScalaVersionSpecific._ object CogenSpecification extends Properties("Cogen") { diff --git a/core/jvm/src/test/scala/org/scalacheck/GenSpecification.scala b/core/jvm/src/test/scala/scalacheck/tests/GenSpecification.scala similarity index 97% rename from core/jvm/src/test/scala/org/scalacheck/GenSpecification.scala rename to core/jvm/src/test/scala/scalacheck/tests/GenSpecification.scala index 02ff200e..4fb2a6d8 100644 --- a/core/jvm/src/test/scala/org/scalacheck/GenSpecification.scala +++ b/core/jvm/src/test/scala/scalacheck/tests/GenSpecification.scala @@ -7,17 +7,18 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck +package scalacheck.tests import scala.util.Failure import scala.util.Success import scala.util.Try -import rng.Seed -import Gen._ -import Prop.{forAll, forAllNoShrink, someFailing, noneFailing, sizedProp, secure, propBoolean} -import Arbitrary._ -import Shrink._ +import org.scalacheck.{Arbitrary, Cogen, Gen, Prop, Properties} +import org.scalacheck.rng.Seed +import org.scalacheck.Gen._ +import org.scalacheck.Prop.{forAll, forAllNoShrink, someFailing, noneFailing, sizedProp, secure, propBoolean} +import org.scalacheck.Arbitrary._ +import org.scalacheck.Shrink._ object GenSpecification extends Properties("Gen") with GenSpecificationVersionSpecific { @@ -574,7 +575,7 @@ object GenSpecification extends Properties("Gen") with GenSpecificationVersionSp forAllNoShrink(Gen.choose(1000000, 2000000)) { n => var i = 0 var sum = 0d - var seed = rng.Seed(n.toLong) + var seed = Seed(n.toLong) while (i < n) { val (d, s1) = seed.double sum += d @@ -582,7 +583,7 @@ object GenSpecification extends Properties("Gen") with GenSpecificationVersionSp seed = s1 } val avg = sum / n - (avg >= 0.49 && avg <= 0.51).labelImpl2(s"average = $avg") + s"average = $avg" |: avg >= 0.49 && avg <= 0.51 } property("uniform long #209") = { @@ -590,7 +591,7 @@ object GenSpecification extends Properties("Gen") with GenSpecificationVersionSp forAllNoShrink(Gen.choose(1000000, 2000000)) { n => var i = 0 var sum = 0d - var seed = rng.Seed(n.toLong) + var seed = Seed(n.toLong) while (i < n) { val (l, s1) = seed.long sum += math.abs(l).toDouble * scale @@ -598,7 +599,7 @@ object GenSpecification extends Properties("Gen") with GenSpecificationVersionSp seed = s1 } val avg = sum / n - (avg >= 0.49 && avg <= 0.51).labelImpl2(s"average = $avg") + s"average = $avg" |: avg >= 0.49 && avg <= 0.51 } } //// @@ -651,7 +652,7 @@ object GenSpecification extends Properties("Gen") with GenSpecificationVersionSp val s0 = (1 to 30).map(_ => g(params0, Seed.random())).toSet val s1 = (1 to 30).map(_ => g(params1, Seed.random())).toSet val s2 = (1 to 30).map(_ => g(params0, seed)).toSet - (s0.size > 1).labelImpl2(s"$s0") && (s1.size == 1).labelImpl2(s"$s1") && (s2.size == 1).labelImpl2(s"$s2") + (s"$s0" |: s0.size > 1) && (s"$s1" |: s1.size == 1) && (s"$s2" |: s2.size == 1) } property("arbitrary[Boolean] is deterministic") = diff --git a/core/jvm/src/test/scala/org/scalacheck/LazyPropertiesSpecification.scala b/core/jvm/src/test/scala/scalacheck/tests/LazyPropertiesSpecification.scala similarity index 89% rename from core/jvm/src/test/scala/org/scalacheck/LazyPropertiesSpecification.scala rename to core/jvm/src/test/scala/scalacheck/tests/LazyPropertiesSpecification.scala index 613a4db5..9d198369 100644 --- a/core/jvm/src/test/scala/org/scalacheck/LazyPropertiesSpecification.scala +++ b/core/jvm/src/test/scala/scalacheck/tests/LazyPropertiesSpecification.scala @@ -7,7 +7,9 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck +package scalacheck.tests + +import org.scalacheck.{Prop, Properties} object LazyPropertiesSpecification extends Properties("Properties.lazy registration") { diff --git a/core/jvm/src/test/scala/org/scalacheck/PropertyFilterSpecification.scala b/core/jvm/src/test/scala/scalacheck/tests/PropertyFilterSpecification.scala similarity index 93% rename from core/jvm/src/test/scala/org/scalacheck/PropertyFilterSpecification.scala rename to core/jvm/src/test/scala/scalacheck/tests/PropertyFilterSpecification.scala index 2d3994d7..e6f538b8 100644 --- a/core/jvm/src/test/scala/org/scalacheck/PropertyFilterSpecification.scala +++ b/core/jvm/src/test/scala/scalacheck/tests/PropertyFilterSpecification.scala @@ -7,9 +7,10 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck +package scalacheck.tests -import Prop.propBoolean +import org.scalacheck.{Gen, Prop, Properties, Test} +import org.scalacheck.Prop.propBoolean object PropertyFilterSampleSpecification extends Properties("PropertyFilterSample") { @@ -43,7 +44,7 @@ object PropertyFilterSpecification extends Properties("PropertyFilter") { def props = actualNames.forall(expectedNames.contains) - (lengthProp && props).labelImpl2(diff(filter, actualNames, expectedNames)) + (lengthProp && props) :| diff(filter, actualNames, expectedNames) } property("filter properties by predicate") = diff --git a/core/jvm/src/test/scala/org/scalacheck/SerializabilitySpecification.scala b/core/jvm/src/test/scala/scalacheck/tests/SerializabilitySpecification.scala similarity index 94% rename from core/jvm/src/test/scala/org/scalacheck/SerializabilitySpecification.scala rename to core/jvm/src/test/scala/scalacheck/tests/SerializabilitySpecification.scala index 9f7bf080..67f6b0fc 100644 --- a/core/jvm/src/test/scala/org/scalacheck/SerializabilitySpecification.scala +++ b/core/jvm/src/test/scala/scalacheck/tests/SerializabilitySpecification.scala @@ -7,13 +7,15 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck +package scalacheck.tests import org.apache.commons.lang3.SerializationUtils import java.io.Serializable -import util.SerializableCanBuildFroms._ +import org.scalacheck.{Arbitrary, Cogen, Gen, Properties, Shrink} +import org.scalacheck.rng.Seed +import org.scalacheck.util.SerializableCanBuildFroms._ object SerializabilitySpecification extends Properties("Serializability") { @@ -156,7 +158,7 @@ object SerializabilitySpecification extends Properties("Serializability") { serializableShrink[List[(String, Int)]]("List[(String,Int)]") property("Seed(1L)") = { - serializable(rng.Seed(1L)) + serializable(Seed(1L)) } } diff --git a/core/jvm/src/test/scala/org/scalacheck/ShrinkSpecificationJVM.scala b/core/jvm/src/test/scala/scalacheck/tests/ShrinkSpecificationJVM.scala similarity index 72% rename from core/jvm/src/test/scala/org/scalacheck/ShrinkSpecificationJVM.scala rename to core/jvm/src/test/scala/scalacheck/tests/ShrinkSpecificationJVM.scala index 8deb1e06..764cf2e0 100644 --- a/core/jvm/src/test/scala/org/scalacheck/ShrinkSpecificationJVM.scala +++ b/core/jvm/src/test/scala/scalacheck/tests/ShrinkSpecificationJVM.scala @@ -7,10 +7,11 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck +package scalacheck.tests -import Prop.{forAll, propBoolean} -import Shrink.shrink +import org.scalacheck.Properties +import org.scalacheck.Prop.{forAll, propBoolean} +import org.scalacheck.Shrink.shrink import ShrinkSpecification.shrinkClosure /** @todo @@ -25,14 +26,14 @@ object ShrinkSpecificationJVM extends Properties("Shrink JVM") { property("non-empty list") = forAll { (l: List[Int]) => (!l.isEmpty && l != List(0)) ==> { val ls = shrinkClosure(l) - (ls.contains(Nil) && ls.contains(List(0))).labelImpl2(ls.toList.toString) + ls.toList.toString |: (ls.contains(Nil) && ls.contains(List(0))) } } property("xmap vector from list") = forAll { (v: Vector[Int]) => (!v.isEmpty && v != Vector(0)) ==> { val vs = shrinkClosure(v) - (vs.contains(Vector.empty) && vs.contains(Vector(0))).labelImpl2(Vector(vs: _*).toString) + Vector(vs: _*).toString |: (vs.contains(Vector.empty) && vs.contains(Vector(0))) } } diff --git a/core/jvm/src/test/scala/org/scalacheck/TestAll.scala b/core/jvm/src/test/scala/scalacheck/tests/TestAll.scala similarity index 90% rename from core/jvm/src/test/scala/org/scalacheck/TestAll.scala rename to core/jvm/src/test/scala/scalacheck/tests/TestAll.scala index ae017e2d..02103812 100644 --- a/core/jvm/src/test/scala/org/scalacheck/TestAll.scala +++ b/core/jvm/src/test/scala/scalacheck/tests/TestAll.scala @@ -7,7 +7,9 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck +package scalacheck.tests + +import org.scalacheck.Properties object TestAll { object ScalaCheckSpecification extends Properties("ScalaCheck") { diff --git a/core/jvm/src/test/scala/org/scalacheck/TestSpecification.scala b/core/jvm/src/test/scala/scalacheck/tests/TestSpecification.scala similarity index 81% rename from core/jvm/src/test/scala/org/scalacheck/TestSpecification.scala rename to core/jvm/src/test/scala/scalacheck/tests/TestSpecification.scala index f7850f3c..14513c9e 100644 --- a/core/jvm/src/test/scala/org/scalacheck/TestSpecification.scala +++ b/core/jvm/src/test/scala/scalacheck/tests/TestSpecification.scala @@ -7,12 +7,14 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck +package scalacheck.tests -import Gen._ -import Prop._ -import Test._ -import Arbitrary._ +import org.scalacheck.{Gen, Prop, Properties, Shrink, Test} +import org.scalacheck.Gen._ +import org.scalacheck.Prop._ +import org.scalacheck.Test._ +import org.scalacheck.Arbitrary._ +import org.scalacheck.rng.Seed object TestSpecification extends Properties("Test") { @@ -53,13 +55,11 @@ object TestSpecification extends Properties("Test") { private def resultInvariant(f: (Test.Parameters, Test.Result) => Boolean): Prop = forAll { (prms: Test.Parameters, p: Prop) => val r = Test.check(prms, p) - f(prms, r).labelImpl2( - s"${r.status}, s=${r.succeeded}, d=${r.discarded}, " + - s"minSuccessful=${prms.minSuccessfulTests}, " + - s"maxDiscardRatio=${prms.maxDiscardRatio}, " + - s"actualDiscardRatio=${r.discarded.toFloat / r.succeeded}, " + - s"workers=${prms.workers}" - ) + s"${r.status}, s=${r.succeeded}, d=${r.discarded}, " + + s"minSuccessful=${prms.minSuccessfulTests}, " + + s"maxDiscardRatio=${prms.maxDiscardRatio}, " + + s"actualDiscardRatio=${r.discarded.toFloat / r.succeeded}, " + + s"workers=${prms.workers}" |: f(prms, r) } property("stopCondition") = resultInvariant { (prms, r) => @@ -112,8 +112,8 @@ object TestSpecification extends Properties("Test") { property("propGenException") = forAll { (prms: Test.Parameters) => Test.check(prms, genException).status match { - case x: PropException => true.labelImpl2(x.toString) - case x => false.labelImpl2(x.toString) + case x: PropException => true :| x.toString + case x => false :| x.toString } } @@ -148,8 +148,8 @@ object TestSpecification extends Properties("Test") { property("Properties.overrideParameters overrides Test.Parameters") = { - val seed0 = rng.Seed.fromBase64("aaaaa_mr05Z_DCbd2PyUolC0h93iH1MQwIdnH2UuI4L=").get - val seed1 = rng.Seed.fromBase64("zzzzz_mr05Z_DCbd2PyUolC0h93iH1MQwIdnH2UuI4L=").get + val seed0 = Seed.fromBase64("aaaaa_mr05Z_DCbd2PyUolC0h93iH1MQwIdnH2UuI4L=").get + val seed1 = Seed.fromBase64("zzzzz_mr05Z_DCbd2PyUolC0h93iH1MQwIdnH2UuI4L=").get val myProps = new Properties("MyProps") { override def overrideParameters(prms: Test.Parameters): Test.Parameters = @@ -170,7 +170,7 @@ object TestSpecification extends Properties("Test") { } property("initialSeed is used and then updated") = { - val seed = rng.Seed.fromBase64("aaaaa_mr05Z_DCbd2PyUolC0h93iH1MQwIdnH2UuI4L=").get + val seed = Seed.fromBase64("aaaaa_mr05Z_DCbd2PyUolC0h93iH1MQwIdnH2UuI4L=").get val gen = Gen.choose(Int.MinValue, Int.MaxValue) val expected = gen(Gen.Parameters.default, seed).get @@ -187,13 +187,13 @@ object TestSpecification extends Properties("Test") { val res = Test.check(prms, prop) val n = xs.size val unique = xs.toSet - val p0 = Prop(unique(expected)).labelImpl2(s"did not see $expected in $unique") - val p1 = Prop(unique.size > 1).labelImpl2(s"saw $n duplicate values: $unique") + val p0 = Prop(unique(expected)) :| s"did not see $expected in $unique" + val p1 = Prop(unique.size > 1) :| s"saw $n duplicate values: $unique" p0 && p1 } property("initialSeed is used and then updated when varying RNG spins") = { - val seed = rng.Seed.fromBase64("aaaaa_mr05Z_DCbd2PyUolC0h93iH1MQwIdnH2UuI4L=").get + val seed = Seed.fromBase64("aaaaa_mr05Z_DCbd2PyUolC0h93iH1MQwIdnH2UuI4L=").get val gen = Gen.choose(Int.MinValue, Int.MaxValue) val expected = gen(Gen.Parameters.default, seed).get @@ -211,8 +211,8 @@ object TestSpecification extends Properties("Test") { Test.check_(prms, prop) val n = xs.size val unique = xs.toSet - val p0 = Prop(unique(expected)).labelImpl2(s"did not see $expected in $unique") - val p1 = Prop(unique.size > 1).labelImpl2(s"saw $n duplicate values: $unique") + val p0 = Prop(unique(expected)) :| s"did not see $expected in $unique" + val p1 = Prop(unique.size > 1) :| s"saw $n duplicate values: $unique" p0 && p1 } } diff --git a/core/jvm/src/test/scala/org/scalacheck/commands/CommandsShrinkSpecification.scala b/core/jvm/src/test/scala/scalacheck/tests/commands/CommandsShrinkSpecification.scala similarity index 98% rename from core/jvm/src/test/scala/org/scalacheck/commands/CommandsShrinkSpecification.scala rename to core/jvm/src/test/scala/scalacheck/tests/commands/CommandsShrinkSpecification.scala index 910e1236..f5e869b4 100644 --- a/core/jvm/src/test/scala/org/scalacheck/commands/CommandsShrinkSpecification.scala +++ b/core/jvm/src/test/scala/scalacheck/tests/commands/CommandsShrinkSpecification.scala @@ -7,7 +7,7 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck.commands +package scalacheck.tests.commands import org.scalacheck.Arbitrary import org.scalacheck.Gen @@ -15,6 +15,7 @@ import org.scalacheck.Prop import org.scalacheck.Prop.forAll import org.scalacheck.Properties import org.scalacheck.Shrink +import org.scalacheck.commands.Commands import org.scalacheck.rng.Seed import scala.reflect.ClassTag diff --git a/core/jvm/src/test/scala/org/scalacheck/commands/CommandsSpecification.scala b/core/jvm/src/test/scala/scalacheck/tests/commands/CommandsSpecification.scala/CommandsSpecification.scala similarity index 97% rename from core/jvm/src/test/scala/org/scalacheck/commands/CommandsSpecification.scala rename to core/jvm/src/test/scala/scalacheck/tests/commands/CommandsSpecification.scala/CommandsSpecification.scala index 0bd7309d..d3aa5bb8 100644 --- a/core/jvm/src/test/scala/org/scalacheck/commands/CommandsSpecification.scala +++ b/core/jvm/src/test/scala/scalacheck/tests/commands/CommandsSpecification.scala/CommandsSpecification.scala @@ -7,9 +7,10 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck.commands +package scalacheck.tests.commands import org.scalacheck._ +import org.scalacheck.commands._ object CommandsSpecification extends Properties("Commands") { diff --git a/core/jvm/src/test/scala/org/scalacheck/examples/IntMapSpec.scala b/core/jvm/src/test/scala/scalacheck/tests/examples/IntMapSpec.scala similarity index 98% rename from core/jvm/src/test/scala/org/scalacheck/examples/IntMapSpec.scala rename to core/jvm/src/test/scala/scalacheck/tests/examples/IntMapSpec.scala index 86d6c281..be3fa077 100644 --- a/core/jvm/src/test/scala/org/scalacheck/examples/IntMapSpec.scala +++ b/core/jvm/src/test/scala/scalacheck/tests/examples/IntMapSpec.scala @@ -7,7 +7,7 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck +package scalacheck.tests import org.scalacheck.Prop.AnyOperators import org.scalacheck.Prop.forAll diff --git a/core/jvm/src/test/scala/org/scalacheck/examples/StringUtils.scala b/core/jvm/src/test/scala/scalacheck/tests/examples/StringUtils.scala similarity index 98% rename from core/jvm/src/test/scala/org/scalacheck/examples/StringUtils.scala rename to core/jvm/src/test/scala/scalacheck/tests/examples/StringUtils.scala index 0ac49ad2..da8a6cb2 100644 --- a/core/jvm/src/test/scala/org/scalacheck/examples/StringUtils.scala +++ b/core/jvm/src/test/scala/scalacheck/tests/examples/StringUtils.scala @@ -7,7 +7,7 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck.example +package scalacheck.tests.example import org.scalacheck._ diff --git a/core/jvm/src/test/scala/org/scalacheck/rng/SeedSpecification.scala b/core/jvm/src/test/scala/scalacheck/tests/rng/SeedSpecification.scala similarity index 91% rename from core/jvm/src/test/scala/org/scalacheck/rng/SeedSpecification.scala rename to core/jvm/src/test/scala/scalacheck/tests/rng/SeedSpecification.scala index a26b95cb..a6b0b8f6 100644 --- a/core/jvm/src/test/scala/org/scalacheck/rng/SeedSpecification.scala +++ b/core/jvm/src/test/scala/scalacheck/tests/rng/SeedSpecification.scala @@ -7,13 +7,15 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck +package scalacheck.tests package rng import scala.util.Try -import Prop.forAll -import Arbitrary.arbitrary +import org.scalacheck.{Arbitrary, Gen, Prop, Properties} +import org.scalacheck.rng.Seed +import org.scalacheck.Prop.forAll +import org.scalacheck.Arbitrary.arbitrary object SeedSpecification extends Properties("Seed") { diff --git a/core/jvm/src/test/scala/org/scalacheck/time/ShrinkSpecification.scala b/core/jvm/src/test/scala/scalacheck/tests/time/ShrinkSpecification.scala similarity index 95% rename from core/jvm/src/test/scala/org/scalacheck/time/ShrinkSpecification.scala rename to core/jvm/src/test/scala/scalacheck/tests/time/ShrinkSpecification.scala index fe362cb0..b3e96e76 100644 --- a/core/jvm/src/test/scala/org/scalacheck/time/ShrinkSpecification.scala +++ b/core/jvm/src/test/scala/scalacheck/tests/time/ShrinkSpecification.scala @@ -7,7 +7,7 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck.time +package scalacheck.tests.time import org.scalacheck.Prop._ import org.scalacheck.Shrink._ diff --git a/core/shared/src/main/scala-2.12-/org/scalacheck/ScalaVersionSpecific.scala b/core/shared/src/main/scala-2.12-/org/scalacheck/ScalaVersionSpecific.scala index 7cdcb298..26e1035b 100644 --- a/core/shared/src/main/scala-2.12-/org/scalacheck/ScalaVersionSpecific.scala +++ b/core/shared/src/main/scala-2.12-/org/scalacheck/ScalaVersionSpecific.scala @@ -16,9 +16,6 @@ import scala.collection.TraversableOnce private[scalacheck] object ScalaVersionSpecific { def toLazyList[T](i: TraversableOnce[T]) = i.toStream - type LazyList[+A] = Stream[A] - val LazyList = Stream - implicit class StreamExt[+A](val s: Stream[A]) extends AnyVal { def lazyAppendedAll[B >: A](rest: => TraversableOnce[B]): Stream[B] = s.append(rest) } @@ -33,9 +30,4 @@ private[scalacheck] object ScalaVersionSpecific { private[scalacheck] trait GenVersionSpecific private[scalacheck] trait CogenVersionSpecific -// Used in tests -private[scalacheck] trait GenSpecificationVersionSpecific { - def infiniteLazyList[T](g: => Gen[T]): Gen[Stream[T]] = Gen.infiniteStream(g) -} - private[scalacheck] trait ShrinkVersionSpecific diff --git a/core/shared/src/main/scala-2.13+/org/scalacheck/ScalaVersionSpecific.scala b/core/shared/src/main/scala-2.13+/org/scalacheck/ScalaVersionSpecific.scala index ab7bc499..296c5d50 100644 --- a/core/shared/src/main/scala-2.13+/org/scalacheck/ScalaVersionSpecific.scala +++ b/core/shared/src/main/scala-2.13+/org/scalacheck/ScalaVersionSpecific.scala @@ -32,8 +32,6 @@ private[scalacheck] trait GenVersionSpecific { } } -private[scalacheck] trait GenSpecificationVersionSpecific - private[scalacheck] trait CogenVersionSpecific { implicit def cogenLazyList[A: Cogen]: Cogen[LazyList[A]] = Cogen.it(_.iterator) diff --git a/core/shared/src/test/scala-2.12-/scalacheck/tests/ScalaVersionSpecific.scala b/core/shared/src/test/scala-2.12-/scalacheck/tests/ScalaVersionSpecific.scala new file mode 100644 index 00000000..4275ce1f --- /dev/null +++ b/core/shared/src/test/scala-2.12-/scalacheck/tests/ScalaVersionSpecific.scala @@ -0,0 +1,23 @@ +/* + * ScalaCheck + * Copyright (c) 2007-2021 Rickard Nilsson. All rights reserved. + * http://www.scalacheck.org + * + * This software is released under the terms of the Revised BSD License. + * There is NO WARRANTY. See the file LICENSE for the full text. + */ + +package scalacheck.tests + +import scala.collection.immutable.Stream + +import org.scalacheck.Gen + +private[tests] object ScalaVersionSpecific { + type LazyList[+A] = Stream[A] + val LazyList = Stream +} + +private[tests] trait GenSpecificationVersionSpecific { + def infiniteLazyList[T](g: => Gen[T]): Gen[Stream[T]] = Gen.infiniteStream(g) +} diff --git a/core/shared/src/test/scala-2.12-/org/scalacheck/time/OrderingVersionSpecific.scala b/core/shared/src/test/scala-2.12-/scalacheck/tests/time/OrderingVersionSpecific.scala similarity index 96% rename from core/shared/src/test/scala-2.12-/org/scalacheck/time/OrderingVersionSpecific.scala rename to core/shared/src/test/scala-2.12-/scalacheck/tests/time/OrderingVersionSpecific.scala index 9e1c2933..2c3e298d 100644 --- a/core/shared/src/test/scala-2.12-/org/scalacheck/time/OrderingVersionSpecific.scala +++ b/core/shared/src/test/scala-2.12-/scalacheck/tests/time/OrderingVersionSpecific.scala @@ -7,7 +7,7 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck.time +package scalacheck.tests.time import java.time._ import java.time.chrono._ diff --git a/core/shared/src/test/scala-2.13+/scalacheck/tests/ScalaVersionSpecific.scala b/core/shared/src/test/scala-2.13+/scalacheck/tests/ScalaVersionSpecific.scala new file mode 100644 index 00000000..ad71f7f7 --- /dev/null +++ b/core/shared/src/test/scala-2.13+/scalacheck/tests/ScalaVersionSpecific.scala @@ -0,0 +1,14 @@ +/* + * ScalaCheck + * Copyright (c) 2007-2021 Rickard Nilsson. All rights reserved. + * http://www.scalacheck.org + * + * This software is released under the terms of the Revised BSD License. + * There is NO WARRANTY. See the file LICENSE for the full text. + */ + +package scalacheck.tests + +private[tests] object ScalaVersionSpecific + +private[tests] trait GenSpecificationVersionSpecific diff --git a/core/shared/src/test/scala-2.13+/org/scalacheck/time/OrderingVersionSpecific.scala b/core/shared/src/test/scala-2.13+/scalacheck/tests/time/OrderingVersionSpecific.scala similarity index 93% rename from core/shared/src/test/scala-2.13+/org/scalacheck/time/OrderingVersionSpecific.scala rename to core/shared/src/test/scala-2.13+/scalacheck/tests/time/OrderingVersionSpecific.scala index a41aa2c4..34fd47c7 100644 --- a/core/shared/src/test/scala-2.13+/org/scalacheck/time/OrderingVersionSpecific.scala +++ b/core/shared/src/test/scala-2.13+/scalacheck/tests/time/OrderingVersionSpecific.scala @@ -7,7 +7,7 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck.time +package scalacheck.tests.time /** This is unused on Scala >= 2.13. * diff --git a/core/shared/src/test/scala/org/scalacheck/NoPropertyNestingSpecification.scala b/core/shared/src/test/scala/scalacheck/tests/NoPropertyNestingSpecification.scala similarity index 93% rename from core/shared/src/test/scala/org/scalacheck/NoPropertyNestingSpecification.scala rename to core/shared/src/test/scala/scalacheck/tests/NoPropertyNestingSpecification.scala index 327aa854..d8ca0926 100644 --- a/core/shared/src/test/scala/org/scalacheck/NoPropertyNestingSpecification.scala +++ b/core/shared/src/test/scala/scalacheck/tests/NoPropertyNestingSpecification.scala @@ -7,7 +7,9 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck +package scalacheck.tests + +import org.scalacheck.{Gen, Prop, Properties} object NoPropertyNestingSpecification extends Properties("Properties.no nesting") { property("no nested properties") = { diff --git a/core/shared/src/test/scala/org/scalacheck/PropSpecification.scala b/core/shared/src/test/scala/scalacheck/tests/PropSpecification.scala similarity index 95% rename from core/shared/src/test/scala/org/scalacheck/PropSpecification.scala rename to core/shared/src/test/scala/scalacheck/tests/PropSpecification.scala index 662e5125..cf473291 100644 --- a/core/shared/src/test/scala/org/scalacheck/PropSpecification.scala +++ b/core/shared/src/test/scala/scalacheck/tests/PropSpecification.scala @@ -7,9 +7,10 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck +package scalacheck.tests -import Prop.{ +import org.scalacheck.{Gen, Prop, Properties, Shrink} +import org.scalacheck.Prop.{ forAll, falsified, undecided, @@ -33,7 +34,8 @@ import Prop.{ lzy, collect } -import Gen.{const, fail, oneOf, listOf, Parameters} +import org.scalacheck.Gen.{const, fail, oneOf, listOf, Parameters} +import org.scalacheck.rng.Seed object PropSpecification extends Properties("Prop") { @@ -218,26 +220,26 @@ object PropSpecification extends Properties("Prop") { val params = Gen.Parameters.default.withInitialSeed(999L) val x = p(params).success val set = (1 to 10).map(_ => p(params).success).toSet - Prop(set == Set(x)).labelImpl2(s"$set == Set($x)") + Prop(set == Set(x)) :| s"$set == Set($x)" } property("prop.useSeed is deterministic") = forAll { (p0: Prop, n: Long) => val params = Gen.Parameters.default - val p = p0.useSeed(rng.Seed(n)) + val p = p0.useSeed(Seed(n)) val x = p(params).success val set = (1 to 10).map(_ => p(params).success).toSet - Prop(set == Set(x)).labelImpl2(s"$set == Set($x)") + Prop(set == Set(x)) :| s"$set == Set($x)" } property("prop.useSeed is deterministic (pt. 2)") = forAll { (g1: Gen[Int], g2: Gen[Int], g3: Gen[Int], n: Long) => val params = Gen.Parameters.default val p0 = Prop.forAll(g1, g2, g3) { (x, y, z) => x == y && y == z } - val p = p0.useSeed(rng.Seed(n)) + val p = p0.useSeed(Seed(n)) val r1 = p(params).success val r2 = p(params).success - Prop(r1 == r2).labelImpl2(s"$r1 == $r2") + Prop(r1 == r2) :| s"$r1 == $r2" } property("disabling shrinking works") = { diff --git a/core/shared/src/test/scala/org/scalacheck/ShrinkSpecification.scala b/core/shared/src/test/scala/scalacheck/tests/ShrinkSpecification.scala similarity index 96% rename from core/shared/src/test/scala/org/scalacheck/ShrinkSpecification.scala rename to core/shared/src/test/scala/scalacheck/tests/ShrinkSpecification.scala index 0f79ef21..df933200 100644 --- a/core/shared/src/test/scala/org/scalacheck/ShrinkSpecification.scala +++ b/core/shared/src/test/scala/scalacheck/tests/ShrinkSpecification.scala @@ -7,13 +7,14 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck +package scalacheck.tests import scala.concurrent.duration.Duration import scala.concurrent.duration.FiniteDuration -import Prop.{forAll, forAllNoShrink, propBoolean} -import Shrink.shrink +import org.scalacheck.{Arbitrary, Gen, Prop, Properties, Shrink} +import org.scalacheck.Prop.{forAll, forAllNoShrink, propBoolean} +import org.scalacheck.Shrink.shrink object ShrinkSpecification extends Properties("Shrink") { diff --git a/core/shared/src/test/scala/org/scalacheck/StatsSpecification.scala b/core/shared/src/test/scala/scalacheck/tests/StatsSpecification.scala similarity index 93% rename from core/shared/src/test/scala/org/scalacheck/StatsSpecification.scala rename to core/shared/src/test/scala/scalacheck/tests/StatsSpecification.scala index b9acc830..ccbbe58c 100644 --- a/core/shared/src/test/scala/org/scalacheck/StatsSpecification.scala +++ b/core/shared/src/test/scala/scalacheck/tests/StatsSpecification.scala @@ -7,9 +7,10 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck +package scalacheck.tests -import Prop.{forAllNoShrink => forAll} +import org.scalacheck.{Gen, Prop, Properties, Test} +import org.scalacheck.Prop.{forAllNoShrink => forAll} object StatsSpecification extends Properties("Stats") { @@ -87,7 +88,7 @@ object StatsSpecification extends Properties("Stats") { case class Bounds(min: Double, max: Double) { def contains(x: Double): Prop = - Prop(min <= x && x <= max).labelImpl2(s"($min <= $x <= $max) was false") + Prop(min <= x && x <= max) :| s"($min <= $x <= $max) was false" } implicit class MakeBounds(val n: Double) extends AnyVal { diff --git a/core/shared/src/test/scala/org/scalacheck/TestFingerprint.scala b/core/shared/src/test/scala/scalacheck/tests/TestFingerprint.scala similarity index 87% rename from core/shared/src/test/scala/org/scalacheck/TestFingerprint.scala rename to core/shared/src/test/scala/scalacheck/tests/TestFingerprint.scala index 58f7fc50..50509738 100644 --- a/core/shared/src/test/scala/org/scalacheck/TestFingerprint.scala +++ b/core/shared/src/test/scala/scalacheck/tests/TestFingerprint.scala @@ -7,7 +7,9 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck +package scalacheck.tests + +import org.scalacheck.{Prop, Properties} class PropsClass extends Properties("TestFingerprint") { property("propclass") = Prop.proved diff --git a/core/shared/src/test/scala/org/scalacheck/examples/Examples.scala b/core/shared/src/test/scala/scalacheck/tests/examples/Examples.scala similarity index 97% rename from core/shared/src/test/scala/org/scalacheck/examples/Examples.scala rename to core/shared/src/test/scala/scalacheck/tests/examples/Examples.scala index 51a5ec0a..7e087d6a 100644 --- a/core/shared/src/test/scala/org/scalacheck/examples/Examples.scala +++ b/core/shared/src/test/scala/scalacheck/tests/examples/Examples.scala @@ -7,7 +7,7 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck.examples +package scalacheck.tests.examples import org.scalacheck.Prop import org.scalacheck.Properties diff --git a/core/shared/src/test/scala/org/scalacheck/examples/MathSpec.scala b/core/shared/src/test/scala/scalacheck/tests/examples/MathSpec.scala similarity index 93% rename from core/shared/src/test/scala/org/scalacheck/examples/MathSpec.scala rename to core/shared/src/test/scala/scalacheck/tests/examples/MathSpec.scala index 2407c3e6..0314990d 100644 --- a/core/shared/src/test/scala/org/scalacheck/examples/MathSpec.scala +++ b/core/shared/src/test/scala/scalacheck/tests/examples/MathSpec.scala @@ -7,7 +7,7 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck.examples +package scalacheck.tests.examples import org.scalacheck.Prop.forAll import org.scalacheck.Prop.propBoolean diff --git a/core/shared/src/test/scala/org/scalacheck/util/BuildableSpecification.scala b/core/shared/src/test/scala/scalacheck/tests/util/BuildableSpecification.scala similarity index 94% rename from core/shared/src/test/scala/org/scalacheck/util/BuildableSpecification.scala rename to core/shared/src/test/scala/scalacheck/tests/util/BuildableSpecification.scala index 98a599ff..67287938 100644 --- a/core/shared/src/test/scala/org/scalacheck/util/BuildableSpecification.scala +++ b/core/shared/src/test/scala/scalacheck/tests/util/BuildableSpecification.scala @@ -7,11 +7,13 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck +package scalacheck.tests package util import scala.collection._ +import org.scalacheck.Gen +import org.scalacheck.util.Buildable import ScalaVersionSpecific._ object BuildableSpecification { diff --git a/core/shared/src/test/scala/org/scalacheck/util/PrettySpecification.scala b/core/shared/src/test/scala/scalacheck/tests/util/PrettySpecification.scala similarity index 96% rename from core/shared/src/test/scala/org/scalacheck/util/PrettySpecification.scala rename to core/shared/src/test/scala/scalacheck/tests/util/PrettySpecification.scala index f5e5404d..dca8da82 100644 --- a/core/shared/src/test/scala/org/scalacheck/util/PrettySpecification.scala +++ b/core/shared/src/test/scala/scalacheck/tests/util/PrettySpecification.scala @@ -7,11 +7,12 @@ * There is NO WARRANTY. See the file LICENSE for the full text. */ -package org.scalacheck +package scalacheck.tests package util import org.scalacheck.{Gen, Prop, Properties} import org.scalacheck.Prop._ +import org.scalacheck.util.Pretty object PrettySpecification extends Properties("Pretty") {