@@ -20,65 +20,65 @@ import util.Buildable
20
20
import util .SerializableCanBuildFroms ._
21
21
22
22
/** 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
+ */
82
82
sealed abstract class Arbitrary [T ] extends Serializable {
83
83
def arbitrary : Gen [T ]
84
84
}
@@ -103,7 +103,7 @@ private[scalacheck] sealed trait ArbitraryLowPriority {
103
103
def arbitrary [T ](implicit a : Arbitrary [T ]): Gen [T ] = a.arbitrary
104
104
105
105
/** ** Arbitrary instances for each AnyVal ***
106
- */
106
+ */
107
107
108
108
/** Arbitrary AnyVal */
109
109
implicit lazy val arbAnyVal : Arbitrary [AnyVal ] = Arbitrary (oneOf(
@@ -174,7 +174,7 @@ private[scalacheck] sealed trait ArbitraryLowPriority {
174
174
Arbitrary (Gen .const(()))
175
175
176
176
/** Arbitrary instances of other common types
177
- */
177
+ */
178
178
179
179
/** Arbitrary instance of String */
180
180
implicit lazy val arbString : Arbitrary [String ] =
@@ -307,10 +307,10 @@ private[scalacheck] sealed trait ArbitraryLowPriority {
307
307
Arbitrary (Gen .finiteDuration)
308
308
309
309
/** 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
+ */
314
314
implicit lazy val arbDuration : Arbitrary [Duration ] =
315
315
Arbitrary (Gen .duration)
316
316
@@ -385,17 +385,17 @@ private[scalacheck] sealed trait ArbitraryLowPriority {
385
385
Arbitrary (Gen .oneOf(arbitrary[T ].map(Success (_)), arbitrary[Throwable ].map(Failure (_))))
386
386
387
387
/** 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
+ */
390
390
implicit def arbContainer [C [_], T ](implicit
391
391
a : Arbitrary [T ],
392
392
b : Buildable [T , C [T ]],
393
393
t : C [T ] => Traversable [T ]
394
394
): Arbitrary [C [T ]] = Arbitrary (buildableOf[C [T ], T ](arbitrary[T ]))
395
395
396
396
/** 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
+ */
399
399
implicit def arbContainer2 [C [_, _], T , U ](implicit
400
400
a : Arbitrary [(T , U )],
401
401
b : Buildable [(T , U ), C [T , U ]],
0 commit comments