Skip to content

Commit 828a8e1

Browse files
authored
Merge pull request #1042 from som-snytt/format/doc-comments
Prefer docstrings.style = AsteriskSpace
2 parents 8caf0b1 + 6004451 commit 828a8e1

File tree

22 files changed

+826
-824
lines changed

22 files changed

+826
-824
lines changed

.scalafmt.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ danglingParentheses {
1111
callSite = false
1212
}
1313

14+
docstrings.style = AsteriskSpace
15+
1416
newlines {
1517
source = keep
1618
}

bench/src/main/scala/org/scalacheck/bench/GenBench.scala

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,30 @@ import org.scalacheck.Gen
1717
import org.scalacheck.rng.Seed
1818

1919
/** Generator benchmarks
20-
*
21-
* Since generators may run very quickly (or very slowly) depending on the seed and size parameter used, we want to
22-
* make sure these are held constant across runs. Otherwise, we might believe a particular change made a given
23-
* generator faster (or slower) when in fact we just got lucky (or unlucky).
24-
*
25-
* We use `seedCount` to choose how many seeds we will benchmark with. For each seed, we run the given generator. So if
26-
* `seedCount` is 100, the average time we get is the time to generate values for the 100 seeds we started with.
27-
*
28-
* The size parameter also plays a major role in how long generators take. ScalaCheck's default parameters start with
29-
* 100. You can benchmark additional size parameters to see how changes to this parameter effect generator run time.
30-
*
31-
* Finally, a generator's `apply` method may fail to generate a value. This might allow a slow generator that fails 50%
32-
* of the time to appear faster than other generators that don't fail. Since we expect all generators to be able to
33-
* succeed, we benchmark using `pureApply`, which will retry up to 100 times before crashing. This way, there's no
34-
* chance that a flaky generator gets an advantage during benchmarking.
35-
*
36-
* In theory, we should do as much work as possible outside the benchmark methods to avoid benchmarking construction
37-
* time. However, since many generators are constructed inside of `flatMap` calls during generation we do want these
38-
* constructors to also run as quickly as possible. For that reason, we mostly choose to assemble our generators inside
39-
* the benchmark methods.
40-
*
41-
* Prefer to add new benchmarks instead of modifying existing ones. This will enable us to compare the results for a
42-
* given benchmark over time.
43-
*/
20+
*
21+
* Since generators may run very quickly (or very slowly) depending on the seed and size parameter used, we want to
22+
* make sure these are held constant across runs. Otherwise, we might believe a particular change made a given
23+
* generator faster (or slower) when in fact we just got lucky (or unlucky).
24+
*
25+
* We use `seedCount` to choose how many seeds we will benchmark with. For each seed, we run the given generator. So if
26+
* `seedCount` is 100, the average time we get is the time to generate values for the 100 seeds we started with.
27+
*
28+
* The size parameter also plays a major role in how long generators take. ScalaCheck's default parameters start with
29+
* 100. You can benchmark additional size parameters to see how changes to this parameter effect generator run time.
30+
*
31+
* Finally, a generator's `apply` method may fail to generate a value. This might allow a slow generator that fails 50%
32+
* of the time to appear faster than other generators that don't fail. Since we expect all generators to be able to
33+
* succeed, we benchmark using `pureApply`, which will retry up to 100 times before crashing. This way, there's no
34+
* chance that a flaky generator gets an advantage during benchmarking.
35+
*
36+
* In theory, we should do as much work as possible outside the benchmark methods to avoid benchmarking construction
37+
* time. However, since many generators are constructed inside of `flatMap` calls during generation we do want these
38+
* constructors to also run as quickly as possible. For that reason, we mostly choose to assemble our generators inside
39+
* the benchmark methods.
40+
*
41+
* Prefer to add new benchmarks instead of modifying existing ones. This will enable us to compare the results for a
42+
* given benchmark over time.
43+
*/
4444
@State(Scope.Benchmark)
4545
@BenchmarkMode(Array(Mode.AverageTime))
4646
@OutputTimeUnit(TimeUnit.MICROSECONDS)

core/jvm/src/test/scala/org/scalacheck/ChooseSpecification.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ object ChooseSpecification extends Properties("Choose") with time.OrderingVersio
6161
property("choose[ZonedDateTime]") = chooseProp[ZonedDateTime]
6262

6363
/** Generate a duration which is at least 1 second smaller than the max duration the type can support. We use this to
64-
* avoid the incredibly unlikely event of overflowing in the handle-min-nanos-duration test.
65-
*/
64+
* avoid the incredibly unlikely event of overflowing in the handle-min-nanos-duration test.
65+
*/
6666
lazy val genOneSecondLessThanMaxDuration: Gen[Duration] =
6767
Gen.choose(Duration.ofSeconds(Long.MinValue), Duration.ofSeconds(Long.MaxValue - 1L, 999999999L))
6868

@@ -80,8 +80,8 @@ object ChooseSpecification extends Properties("Choose") with time.OrderingVersio
8080
}
8181

8282
/** Generate an Instant which is at least 1 second smaller than the max Instant the type can support. We use this to
83-
* avoid the incredibly unlikely event of overflowing in the handle-min-nanos-instant test.
84-
*/
83+
* avoid the incredibly unlikely event of overflowing in the handle-min-nanos-instant test.
84+
*/
8585
lazy val genOneSecondLessThanMaxInstant: Gen[Instant] =
8686
Gen.choose(Instant.MIN, Instant.MAX.minusSeconds(1L))
8787

core/jvm/src/test/scala/org/scalacheck/GenSpecification.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,13 @@ object GenSpecification extends Properties("Gen") with GenSpecificationVersionSp
273273
}
274274

275275
/** Expect:
276-
* {{{
277-
* 25% 1, 2, 3
278-
* 25% 1, 2, 4
279-
* 25% 1, 4, 3
280-
* 25% 4, 2, 3
281-
* }}}
282-
*/
276+
* {{{
277+
* 25% 1, 2, 3
278+
* 25% 1, 2, 4
279+
* 25% 1, 4, 3
280+
* 25% 4, 2, 3
281+
* }}}
282+
*/
283283
property("distributed pick") = {
284284
val lst = (1 to 4).toIterable
285285
val n = 3
@@ -640,10 +640,10 @@ object GenSpecification extends Properties("Gen") with GenSpecificationVersionSp
640640
}
641641

642642
/** Ensure that the given generator runs deterministically with the same initialSeed parameter or the same seed.
643-
*
644-
* This test should be run with a generator that can produce multiple values, and where the odds of 30 trials coming
645-
* back with the same result is low enough that the test won't produce many false positives.
646-
*/
643+
*
644+
* This test should be run with a generator that can produce multiple values, and where the odds of 30 trials coming
645+
* back with the same result is low enough that the test won't produce many false positives.
646+
*/
647647
def testDeterministicGen[A](g: Gen[A]): Prop = {
648648
val params0 = Gen.Parameters.default
649649
val params1 = params0.withInitialSeed(1248163264L)

core/jvm/src/test/scala/org/scalacheck/ShrinkSpecificationJVM.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import Shrink.shrink
1414
import ShrinkSpecification.shrinkClosure
1515

1616
/** @todo
17-
* should work not only JVM but also Scala.js
18-
*/
17+
* should work not only JVM but also Scala.js
18+
*/
1919
object ShrinkSpecificationJVM extends Properties("Shrink JVM") {
2020

2121
property("list") = forAll { (l: List[Int]) =>

core/shared/src/main/scala-2.12-/org/scalacheck/util/BuildableVersionSpecific.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private[util] class ArrayListBuilder[T] extends Builder[T, ArrayList[T]] {
3333
}
3434

3535
/** CanBuildFrom instances implementing Serializable, so that the objects capturing those can be serializable too.
36-
*/
36+
*/
3737
object SerializableCanBuildFroms {
3838
implicit def listCanBuildFrom[T]: CanBuildFrom[List[T], T, List[T]] =
3939
new CanBuildFrom[List[T], T, List[T]] with Serializable {

core/shared/src/main/scala-2.13+/org/scalacheck/util/BuildableVersionSpecific.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ private[util] class ArrayListBuilder[T] extends Builder[T, ArrayList[T]] {
3131
}
3232

3333
/** Factory instances implementing Serializable, so that the objects capturing those can be serializable too.
34-
*/
34+
*/
3535
// Named `...CanBuildFroms` for 2.12 source compatibility (`import SerializableCanBuildFroms._`)
3636
// Can be renamed to `SerializableFactories` in a major release.
3737
object SerializableCanBuildFroms {

core/shared/src/main/scala/org/scalacheck/Arbitrary.scala

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -20,65 +20,65 @@ import util.Buildable
2020
import util.SerializableCanBuildFroms._
2121

2222
/** Define an arbitrary generator for properties
23-
*
24-
* The [[Arbitrary]] module defines implicit generator instances for common types.
25-
*
26-
* The implicit definitions of [[Arbitrary]] provide type-directed [[Gen]]s so they are available for properties,
27-
* generators, or other definitions of [[Arbitrary]].
28-
*
29-
* ScalaCheck expects an implicit [[Arbitrary]] instance is in scope for [[Prop]]s that are defined with functions,
30-
* like [[Prop$.forAll[T1,P](g1* Prop.forAll]] and so on.
31-
*
32-
* For instance, the definition for `Arbitrary[Boolean]` is used by `Prop.forAll` to automatically provide a
33-
* `Gen[Boolean]` when one of the parameters is a `Boolean`:
34-
*
35-
* {{{
36-
* Prop.forAll { (b: Boolean) =>
37-
* b || !b
38-
* }
39-
* }}}
40-
*
41-
* Thanks to `Arbitrary`, you don't need to provide an explicit `Gen` instance to `Prop.forAll`. For instance, this is
42-
* unnecessary:
43-
*
44-
* {{{
45-
* val genBool: Gen[Boolean] = Gen.oneOf(true,false)
46-
* Prop.forAll(genBool) { (b: Boolean) =>
47-
* b || !b
48-
* }
49-
* }}}
50-
*
51-
* Since an arbitrary `Gen` for `Boolean` is defined in `Arbitrary`, it can be summoned with `Arbitrary.arbitrary` in
52-
* cases where you need to provide one explicitly:
53-
*
54-
* {{{
55-
* val genBool: Gen[Boolean] = Arbitrary.arbitrary[Boolean]
56-
* val genSmallInt: Gen[Int] = Gen.choose(0, 9)
57-
* Prop.forAll(genBool, genSmallInt) { (b: Boolean, i: Int) =>
58-
* i < 10 && b || !b
59-
* }
60-
* }}}
61-
*
62-
* For a user-defined `MyClass`, writing the following requires that there exists an implicit `Arbitrary[MyClass]`
63-
* instance:
64-
*
65-
* {{{
66-
* Prop.forAll { (myClass: MyClass) =>
67-
* ...
68-
* }
69-
* }}}
70-
*
71-
* The implicit definition of `Arbitrary[MyClass]` would look like:
72-
*
73-
* {{{
74-
* implicit val arbMyClass: Arbitrary[MyClass] = Arbitrary {
75-
* ...
76-
* }
77-
* }}}
78-
*
79-
* The factory method `Arbitrary(...)` expects a generator of type `Gen[MyClass]` then it will return an instance of
80-
* `Arbitrary[MyClass]`.
81-
*/
23+
*
24+
* The [[Arbitrary]] module defines implicit generator instances for common types.
25+
*
26+
* The implicit definitions of [[Arbitrary]] provide type-directed [[Gen]]s so they are available for properties,
27+
* generators, or other definitions of [[Arbitrary]].
28+
*
29+
* ScalaCheck expects an implicit [[Arbitrary]] instance is in scope for [[Prop]]s that are defined with functions,
30+
* like [[Prop$.forAll[T1,P](g1* Prop.forAll]] and so on.
31+
*
32+
* For instance, the definition for `Arbitrary[Boolean]` is used by `Prop.forAll` to automatically provide a
33+
* `Gen[Boolean]` when one of the parameters is a `Boolean`:
34+
*
35+
* {{{
36+
* Prop.forAll { (b: Boolean) =>
37+
* b || !b
38+
* }
39+
* }}}
40+
*
41+
* Thanks to `Arbitrary`, you don't need to provide an explicit `Gen` instance to `Prop.forAll`. For instance, this is
42+
* unnecessary:
43+
*
44+
* {{{
45+
* val genBool: Gen[Boolean] = Gen.oneOf(true,false)
46+
* Prop.forAll(genBool) { (b: Boolean) =>
47+
* b || !b
48+
* }
49+
* }}}
50+
*
51+
* Since an arbitrary `Gen` for `Boolean` is defined in `Arbitrary`, it can be summoned with `Arbitrary.arbitrary` in
52+
* cases where you need to provide one explicitly:
53+
*
54+
* {{{
55+
* val genBool: Gen[Boolean] = Arbitrary.arbitrary[Boolean]
56+
* val genSmallInt: Gen[Int] = Gen.choose(0, 9)
57+
* Prop.forAll(genBool, genSmallInt) { (b: Boolean, i: Int) =>
58+
* i < 10 && b || !b
59+
* }
60+
* }}}
61+
*
62+
* For a user-defined `MyClass`, writing the following requires that there exists an implicit `Arbitrary[MyClass]`
63+
* instance:
64+
*
65+
* {{{
66+
* Prop.forAll { (myClass: MyClass) =>
67+
* ...
68+
* }
69+
* }}}
70+
*
71+
* The implicit definition of `Arbitrary[MyClass]` would look like:
72+
*
73+
* {{{
74+
* implicit val arbMyClass: Arbitrary[MyClass] = Arbitrary {
75+
* ...
76+
* }
77+
* }}}
78+
*
79+
* The factory method `Arbitrary(...)` expects a generator of type `Gen[MyClass]` then it will return an instance of
80+
* `Arbitrary[MyClass]`.
81+
*/
8282
sealed abstract class Arbitrary[T] extends Serializable {
8383
def arbitrary: Gen[T]
8484
}
@@ -103,7 +103,7 @@ private[scalacheck] sealed trait ArbitraryLowPriority {
103103
def arbitrary[T](implicit a: Arbitrary[T]): Gen[T] = a.arbitrary
104104

105105
/** ** Arbitrary instances for each AnyVal ***
106-
*/
106+
*/
107107

108108
/** Arbitrary AnyVal */
109109
implicit lazy val arbAnyVal: Arbitrary[AnyVal] = Arbitrary(oneOf(
@@ -174,7 +174,7 @@ private[scalacheck] sealed trait ArbitraryLowPriority {
174174
Arbitrary(Gen.const(()))
175175

176176
/** Arbitrary instances of other common types
177-
*/
177+
*/
178178

179179
/** Arbitrary instance of String */
180180
implicit lazy val arbString: Arbitrary[String] =
@@ -307,10 +307,10 @@ private[scalacheck] sealed trait ArbitraryLowPriority {
307307
Arbitrary(Gen.finiteDuration)
308308

309309
/** Arbitrary instance of Duration.
310-
*
311-
* In addition to `FiniteDuration` values, this can generate `Duration.Inf`, `Duration.MinusInf`, and
312-
* `Duration.Undefined`.
313-
*/
310+
*
311+
* In addition to `FiniteDuration` values, this can generate `Duration.Inf`, `Duration.MinusInf`, and
312+
* `Duration.Undefined`.
313+
*/
314314
implicit lazy val arbDuration: Arbitrary[Duration] =
315315
Arbitrary(Gen.duration)
316316

@@ -385,17 +385,17 @@ private[scalacheck] sealed trait ArbitraryLowPriority {
385385
Arbitrary(Gen.oneOf(arbitrary[T].map(Success(_)), arbitrary[Throwable].map(Failure(_))))
386386

387387
/** Arbitrary instance of any [[org.scalacheck.util.Buildable]] container (such as lists, arrays, streams / lazy
388-
* lists, etc). The maximum size of the container depends on the size generation parameter.
389-
*/
388+
* lists, etc). The maximum size of the container depends on the size generation parameter.
389+
*/
390390
implicit def arbContainer[C[_], T](implicit
391391
a: Arbitrary[T],
392392
b: Buildable[T, C[T]],
393393
t: C[T] => Traversable[T]
394394
): Arbitrary[C[T]] = Arbitrary(buildableOf[C[T], T](arbitrary[T]))
395395

396396
/** Arbitrary instance of any [[org.scalacheck.util.Buildable]] container (such as maps). The maximum size of the
397-
* container depends on the size generation parameter.
398-
*/
397+
* container depends on the size generation parameter.
398+
*/
399399
implicit def arbContainer2[C[_, _], T, U](implicit
400400
a: Arbitrary[(T, U)],
401401
b: Buildable[(T, U), C[T, U]],

0 commit comments

Comments
 (0)