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

Defer evaluation of Prop labels #979

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") {

Expand Down Expand Up @@ -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))
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") {

Expand Down Expand Up @@ -146,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 =
Expand All @@ -168,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

Expand All @@ -191,7 +193,7 @@ object TestSpecification extends Properties("Test") {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
* 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
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading