Skip to content

Commit a6dfec7

Browse files
committed
Move tests to scalacheck.tests package.
1 parent 2530585 commit a6dfec7

31 files changed

+147
-93
lines changed

core/jvm/src/test/scala/org/scalacheck/ArbitrarySpecification.scala renamed to core/jvm/src/test/scala/scalacheck/tests/ArbitrarySpecification.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
* There is NO WARRANTY. See the file LICENSE for the full text.
88
*/
99

10-
package org.scalacheck
10+
package scalacheck.tests
1111

1212
import java.util.concurrent.TimeUnit
1313

14-
import Prop._
15-
import Arbitrary._
14+
import org.scalacheck.{Arbitrary, Gen, Prop, Properties}
15+
import org.scalacheck.Prop._
16+
import org.scalacheck.Arbitrary._
1617

1718
object ArbitrarySpecification extends Properties("Arbitrary") {
1819
val genOptionUnits =

core/jvm/src/test/scala/org/scalacheck/ChooseSpecification.scala renamed to core/jvm/src/test/scala/scalacheck/tests/ChooseSpecification.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* There is NO WARRANTY. See the file LICENSE for the full text.
88
*/
99

10-
package org.scalacheck
10+
package scalacheck.tests
1111

1212
import java.time._
1313
import java.time.temporal.ChronoUnit
@@ -16,7 +16,8 @@ import scala.util.Failure
1616
import scala.util.Success
1717
import scala.util.Try
1818

19-
import Gen._
19+
import org.scalacheck.{Arbitrary, Gen, Prop, Properties}
20+
import org.scalacheck.Gen._
2021

2122
object ChooseSpecification extends Properties("Choose") with time.OrderingVersionSpecific {
2223

core/jvm/src/test/scala/org/scalacheck/CogenSpecification.scala renamed to core/jvm/src/test/scala/scalacheck/tests/CogenSpecification.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
* There is NO WARRANTY. See the file LICENSE for the full text.
88
*/
99

10-
package org.scalacheck
10+
package scalacheck.tests
1111

12+
import org.scalacheck.{Arbitrary, Cogen, Prop, Properties}
1213
import org.scalacheck.Arbitrary.arbitrary
1314
import org.scalacheck.Gen.listOfN
14-
import org.scalacheck.GenSpecification.arbSeed
1515
import org.scalacheck.Prop.forAll
1616
import org.scalacheck.rng.Seed
1717

@@ -22,6 +22,7 @@ import scala.collection.immutable.SortedSet
2222
import scala.concurrent.duration.Duration
2323
import scala.concurrent.duration.FiniteDuration
2424
import scala.util.Try
25+
import GenSpecification.arbSeed
2526
import ScalaVersionSpecific._
2627

2728
object CogenSpecification extends Properties("Cogen") {

core/jvm/src/test/scala/org/scalacheck/GenSpecification.scala renamed to core/jvm/src/test/scala/scalacheck/tests/GenSpecification.scala

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@
77
* There is NO WARRANTY. See the file LICENSE for the full text.
88
*/
99

10-
package org.scalacheck
10+
package scalacheck.tests
1111

1212
import scala.util.Failure
1313
import scala.util.Success
1414
import scala.util.Try
1515

16-
import rng.Seed
17-
import Gen._
18-
import Prop.{forAll, forAllNoShrink, someFailing, noneFailing, sizedProp, secure, propBoolean}
19-
import Arbitrary._
20-
import Shrink._
16+
import org.scalacheck.{Arbitrary, Cogen, Gen, Prop, Properties}
17+
import org.scalacheck.rng.Seed
18+
import org.scalacheck.Gen._
19+
import org.scalacheck.Prop.{forAll, forAllNoShrink, someFailing, noneFailing, sizedProp, secure, propBoolean}
20+
import org.scalacheck.Arbitrary._
21+
import org.scalacheck.Shrink._
2122

2223
object GenSpecification extends Properties("Gen") with GenSpecificationVersionSpecific {
2324

@@ -574,31 +575,31 @@ object GenSpecification extends Properties("Gen") with GenSpecificationVersionSp
574575
forAllNoShrink(Gen.choose(1000000, 2000000)) { n =>
575576
var i = 0
576577
var sum = 0d
577-
var seed = rng.Seed(n.toLong)
578+
var seed = Seed(n.toLong)
578579
while (i < n) {
579580
val (d, s1) = seed.double
580581
sum += d
581582
i += 1
582583
seed = s1
583584
}
584585
val avg = sum / n
585-
(avg >= 0.49 && avg <= 0.51).labelImpl2(s"average = $avg")
586+
s"average = $avg" |: avg >= 0.49 && avg <= 0.51
586587
}
587588

588589
property("uniform long #209") = {
589590
val scale = 1d / Long.MaxValue
590591
forAllNoShrink(Gen.choose(1000000, 2000000)) { n =>
591592
var i = 0
592593
var sum = 0d
593-
var seed = rng.Seed(n.toLong)
594+
var seed = Seed(n.toLong)
594595
while (i < n) {
595596
val (l, s1) = seed.long
596597
sum += math.abs(l).toDouble * scale
597598
i += 1
598599
seed = s1
599600
}
600601
val avg = sum / n
601-
(avg >= 0.49 && avg <= 0.51).labelImpl2(s"average = $avg")
602+
s"average = $avg" |: avg >= 0.49 && avg <= 0.51
602603
}
603604
}
604605
////
@@ -651,7 +652,7 @@ object GenSpecification extends Properties("Gen") with GenSpecificationVersionSp
651652
val s0 = (1 to 30).map(_ => g(params0, Seed.random())).toSet
652653
val s1 = (1 to 30).map(_ => g(params1, Seed.random())).toSet
653654
val s2 = (1 to 30).map(_ => g(params0, seed)).toSet
654-
(s0.size > 1).labelImpl2(s"$s0") && (s1.size == 1).labelImpl2(s"$s1") && (s2.size == 1).labelImpl2(s"$s2")
655+
(s"$s0" |: s0.size > 1) && (s"$s1" |: s1.size == 1) && (s"$s2" |: s2.size == 1)
655656
}
656657

657658
property("arbitrary[Boolean] is deterministic") =

core/jvm/src/test/scala/org/scalacheck/LazyPropertiesSpecification.scala renamed to core/jvm/src/test/scala/scalacheck/tests/LazyPropertiesSpecification.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
* There is NO WARRANTY. See the file LICENSE for the full text.
88
*/
99

10-
package org.scalacheck
10+
package scalacheck.tests
11+
12+
import org.scalacheck.{Prop, Properties}
1113

1214
object LazyPropertiesSpecification extends Properties("Properties.lazy registration") {
1315

core/jvm/src/test/scala/org/scalacheck/PropertyFilterSpecification.scala renamed to core/jvm/src/test/scala/scalacheck/tests/PropertyFilterSpecification.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
* There is NO WARRANTY. See the file LICENSE for the full text.
88
*/
99

10-
package org.scalacheck
10+
package scalacheck.tests
1111

12-
import Prop.propBoolean
12+
import org.scalacheck.{Gen, Prop, Properties, Test}
13+
import org.scalacheck.Prop.propBoolean
1314

1415
object PropertyFilterSampleSpecification extends Properties("PropertyFilterSample") {
1516

@@ -43,7 +44,7 @@ object PropertyFilterSpecification extends Properties("PropertyFilter") {
4344

4445
def props = actualNames.forall(expectedNames.contains)
4546

46-
(lengthProp && props).labelImpl2(diff(filter, actualNames, expectedNames))
47+
(lengthProp && props) :| diff(filter, actualNames, expectedNames)
4748
}
4849

4950
property("filter properties by predicate") =

core/jvm/src/test/scala/org/scalacheck/SerializabilitySpecification.scala renamed to core/jvm/src/test/scala/scalacheck/tests/SerializabilitySpecification.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
* There is NO WARRANTY. See the file LICENSE for the full text.
88
*/
99

10-
package org.scalacheck
10+
package scalacheck.tests
1111

1212
import org.apache.commons.lang3.SerializationUtils
1313

1414
import java.io.Serializable
1515

16-
import util.SerializableCanBuildFroms._
16+
import org.scalacheck.{Arbitrary, Cogen, Gen, Properties, Shrink}
17+
import org.scalacheck.rng.Seed
18+
import org.scalacheck.util.SerializableCanBuildFroms._
1719

1820
object SerializabilitySpecification extends Properties("Serializability") {
1921

@@ -156,7 +158,7 @@ object SerializabilitySpecification extends Properties("Serializability") {
156158
serializableShrink[List[(String, Int)]]("List[(String,Int)]")
157159

158160
property("Seed(1L)") = {
159-
serializable(rng.Seed(1L))
161+
serializable(Seed(1L))
160162
}
161163

162164
}

core/jvm/src/test/scala/org/scalacheck/ShrinkSpecificationJVM.scala renamed to core/jvm/src/test/scala/scalacheck/tests/ShrinkSpecificationJVM.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
* There is NO WARRANTY. See the file LICENSE for the full text.
88
*/
99

10-
package org.scalacheck
10+
package scalacheck.tests
1111

12-
import Prop.{forAll, propBoolean}
13-
import Shrink.shrink
12+
import org.scalacheck.Properties
13+
import org.scalacheck.Prop.{forAll, propBoolean}
14+
import org.scalacheck.Shrink.shrink
1415
import ShrinkSpecification.shrinkClosure
1516

1617
/** @todo
@@ -25,14 +26,14 @@ object ShrinkSpecificationJVM extends Properties("Shrink JVM") {
2526
property("non-empty list") = forAll { (l: List[Int]) =>
2627
(!l.isEmpty && l != List(0)) ==> {
2728
val ls = shrinkClosure(l)
28-
(ls.contains(Nil) && ls.contains(List(0))).labelImpl2(ls.toList.toString)
29+
ls.toList.toString |: (ls.contains(Nil) && ls.contains(List(0)))
2930
}
3031
}
3132

3233
property("xmap vector from list") = forAll { (v: Vector[Int]) =>
3334
(!v.isEmpty && v != Vector(0)) ==> {
3435
val vs = shrinkClosure(v)
35-
(vs.contains(Vector.empty) && vs.contains(Vector(0))).labelImpl2(Vector(vs: _*).toString)
36+
Vector(vs: _*).toString |: (vs.contains(Vector.empty) && vs.contains(Vector(0)))
3637
}
3738
}
3839

core/jvm/src/test/scala/org/scalacheck/TestAll.scala renamed to core/jvm/src/test/scala/scalacheck/tests/TestAll.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
* There is NO WARRANTY. See the file LICENSE for the full text.
88
*/
99

10-
package org.scalacheck
10+
package scalacheck.tests
11+
12+
import org.scalacheck.Properties
1113

1214
object TestAll {
1315
object ScalaCheckSpecification extends Properties("ScalaCheck") {

core/jvm/src/test/scala/org/scalacheck/TestSpecification.scala renamed to core/jvm/src/test/scala/scalacheck/tests/TestSpecification.scala

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
* There is NO WARRANTY. See the file LICENSE for the full text.
88
*/
99

10-
package org.scalacheck
10+
package scalacheck.tests
1111

12-
import Gen._
13-
import Prop._
14-
import Test._
15-
import Arbitrary._
12+
import org.scalacheck.{Gen, Prop, Properties, Shrink, Test}
13+
import org.scalacheck.Gen._
14+
import org.scalacheck.Prop._
15+
import org.scalacheck.Test._
16+
import org.scalacheck.Arbitrary._
17+
import org.scalacheck.rng.Seed
1618

1719
object TestSpecification extends Properties("Test") {
1820

@@ -53,13 +55,11 @@ object TestSpecification extends Properties("Test") {
5355
private def resultInvariant(f: (Test.Parameters, Test.Result) => Boolean): Prop =
5456
forAll { (prms: Test.Parameters, p: Prop) =>
5557
val r = Test.check(prms, p)
56-
f(prms, r).labelImpl2(
57-
s"${r.status}, s=${r.succeeded}, d=${r.discarded}, " +
58-
s"minSuccessful=${prms.minSuccessfulTests}, " +
59-
s"maxDiscardRatio=${prms.maxDiscardRatio}, " +
60-
s"actualDiscardRatio=${r.discarded.toFloat / r.succeeded}, " +
61-
s"workers=${prms.workers}"
62-
)
58+
s"${r.status}, s=${r.succeeded}, d=${r.discarded}, " +
59+
s"minSuccessful=${prms.minSuccessfulTests}, " +
60+
s"maxDiscardRatio=${prms.maxDiscardRatio}, " +
61+
s"actualDiscardRatio=${r.discarded.toFloat / r.succeeded}, " +
62+
s"workers=${prms.workers}" |: f(prms, r)
6363
}
6464

6565
property("stopCondition") = resultInvariant { (prms, r) =>
@@ -112,8 +112,8 @@ object TestSpecification extends Properties("Test") {
112112

113113
property("propGenException") = forAll { (prms: Test.Parameters) =>
114114
Test.check(prms, genException).status match {
115-
case x: PropException => true.labelImpl2(x.toString)
116-
case x => false.labelImpl2(x.toString)
115+
case x: PropException => true :| x.toString
116+
case x => false :| x.toString
117117
}
118118
}
119119

@@ -148,8 +148,8 @@ object TestSpecification extends Properties("Test") {
148148

149149
property("Properties.overrideParameters overrides Test.Parameters") = {
150150

151-
val seed0 = rng.Seed.fromBase64("aaaaa_mr05Z_DCbd2PyUolC0h93iH1MQwIdnH2UuI4L=").get
152-
val seed1 = rng.Seed.fromBase64("zzzzz_mr05Z_DCbd2PyUolC0h93iH1MQwIdnH2UuI4L=").get
151+
val seed0 = Seed.fromBase64("aaaaa_mr05Z_DCbd2PyUolC0h93iH1MQwIdnH2UuI4L=").get
152+
val seed1 = Seed.fromBase64("zzzzz_mr05Z_DCbd2PyUolC0h93iH1MQwIdnH2UuI4L=").get
153153

154154
val myProps = new Properties("MyProps") {
155155
override def overrideParameters(prms: Test.Parameters): Test.Parameters =
@@ -170,7 +170,7 @@ object TestSpecification extends Properties("Test") {
170170
}
171171

172172
property("initialSeed is used and then updated") = {
173-
val seed = rng.Seed.fromBase64("aaaaa_mr05Z_DCbd2PyUolC0h93iH1MQwIdnH2UuI4L=").get
173+
val seed = Seed.fromBase64("aaaaa_mr05Z_DCbd2PyUolC0h93iH1MQwIdnH2UuI4L=").get
174174
val gen = Gen.choose(Int.MinValue, Int.MaxValue)
175175
val expected = gen(Gen.Parameters.default, seed).get
176176

@@ -187,13 +187,13 @@ object TestSpecification extends Properties("Test") {
187187
val res = Test.check(prms, prop)
188188
val n = xs.size
189189
val unique = xs.toSet
190-
val p0 = Prop(unique(expected)).labelImpl2(s"did not see $expected in $unique")
191-
val p1 = Prop(unique.size > 1).labelImpl2(s"saw $n duplicate values: $unique")
190+
val p0 = Prop(unique(expected)) :| s"did not see $expected in $unique"
191+
val p1 = Prop(unique.size > 1) :| s"saw $n duplicate values: $unique"
192192
p0 && p1
193193
}
194194

195195
property("initialSeed is used and then updated when varying RNG spins") = {
196-
val seed = rng.Seed.fromBase64("aaaaa_mr05Z_DCbd2PyUolC0h93iH1MQwIdnH2UuI4L=").get
196+
val seed = Seed.fromBase64("aaaaa_mr05Z_DCbd2PyUolC0h93iH1MQwIdnH2UuI4L=").get
197197
val gen = Gen.choose(Int.MinValue, Int.MaxValue)
198198
val expected = gen(Gen.Parameters.default, seed).get
199199

@@ -211,8 +211,8 @@ object TestSpecification extends Properties("Test") {
211211
Test.check_(prms, prop)
212212
val n = xs.size
213213
val unique = xs.toSet
214-
val p0 = Prop(unique(expected)).labelImpl2(s"did not see $expected in $unique")
215-
val p1 = Prop(unique.size > 1).labelImpl2(s"saw $n duplicate values: $unique")
214+
val p0 = Prop(unique(expected)) :| s"did not see $expected in $unique"
215+
val p1 = Prop(unique.size > 1) :| s"saw $n duplicate values: $unique"
216216
p0 && p1
217217
}
218218
}

core/jvm/src/test/scala/org/scalacheck/commands/CommandsShrinkSpecification.scala renamed to core/jvm/src/test/scala/scalacheck/tests/commands/CommandsShrinkSpecification.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
* There is NO WARRANTY. See the file LICENSE for the full text.
88
*/
99

10-
package org.scalacheck.commands
10+
package scalacheck.tests.commands
1111

1212
import org.scalacheck.Arbitrary
1313
import org.scalacheck.Gen
1414
import org.scalacheck.Prop
1515
import org.scalacheck.Prop.forAll
1616
import org.scalacheck.Properties
1717
import org.scalacheck.Shrink
18+
import org.scalacheck.commands.Commands
1819
import org.scalacheck.rng.Seed
1920

2021
import scala.reflect.ClassTag

core/jvm/src/test/scala/org/scalacheck/commands/CommandsSpecification.scala renamed to core/jvm/src/test/scala/scalacheck/tests/commands/CommandsSpecification.scala/CommandsSpecification.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
* There is NO WARRANTY. See the file LICENSE for the full text.
88
*/
99

10-
package org.scalacheck.commands
10+
package scalacheck.tests.commands
1111

1212
import org.scalacheck._
13+
import org.scalacheck.commands._
1314

1415
object CommandsSpecification extends Properties("Commands") {
1516

core/jvm/src/test/scala/org/scalacheck/examples/IntMapSpec.scala renamed to core/jvm/src/test/scala/scalacheck/tests/examples/IntMapSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* There is NO WARRANTY. See the file LICENSE for the full text.
88
*/
99

10-
package org.scalacheck
10+
package scalacheck.tests
1111

1212
import org.scalacheck.Prop.AnyOperators
1313
import org.scalacheck.Prop.forAll

core/jvm/src/test/scala/org/scalacheck/examples/StringUtils.scala renamed to core/jvm/src/test/scala/scalacheck/tests/examples/StringUtils.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* There is NO WARRANTY. See the file LICENSE for the full text.
88
*/
99

10-
package org.scalacheck.example
10+
package scalacheck.tests.example
1111

1212
import org.scalacheck._
1313

core/jvm/src/test/scala/org/scalacheck/rng/SeedSpecification.scala renamed to core/jvm/src/test/scala/scalacheck/tests/rng/SeedSpecification.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
* There is NO WARRANTY. See the file LICENSE for the full text.
88
*/
99

10-
package org.scalacheck
10+
package scalacheck.tests
1111
package rng
1212

1313
import scala.util.Try
1414

15-
import Prop.forAll
16-
import Arbitrary.arbitrary
15+
import org.scalacheck.{Arbitrary, Gen, Prop, Properties}
16+
import org.scalacheck.rng.Seed
17+
import org.scalacheck.Prop.forAll
18+
import org.scalacheck.Arbitrary.arbitrary
1719

1820
object SeedSpecification extends Properties("Seed") {
1921

0 commit comments

Comments
 (0)