File tree Expand file tree Collapse file tree 3 files changed +36
-1
lines changed
jvm/src/test/scala/org/scalacheck
src/main/scala/org/scalacheck Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change
1
+ /* -------------------------------------------------------------------------*\
2
+ ** ScalaCheck **
3
+ ** Copyright (c) 2007-2016 Rickard Nilsson. All rights reserved. **
4
+ ** http://www.scalacheck.org **
5
+ ** **
6
+ ** This software is released under the terms of the Revised BSD License. **
7
+ ** There is NO WARRANTY. See the file LICENSE for the full text. **
8
+ \*------------------------------------------------------------------------ */
9
+
10
+ package org .scalacheck
11
+
12
+ object LazyPropertiesSpecification extends Properties (" Properties.lazy registration" ) {
13
+
14
+ property(" properties registered lazily" ) = {
15
+ var evaluated = false
16
+ val p = new Properties (" P" ) {
17
+ property(" p" ) = {
18
+ evaluated = true
19
+ Prop .proved
20
+ }
21
+ }
22
+ evaluated == false
23
+ }
24
+
25
+ }
26
+
Original file line number Diff line number Diff line change @@ -301,6 +301,9 @@ object Prop {
301
301
/** Create a property from a boolean value */
302
302
def apply (b : Boolean ): Prop = if (b) proved else falsified
303
303
304
+ /** Create a prop that evaluates the by-name argument on each application. */
305
+ def suspend (p : => Prop ): Prop = apply(prms => p(prms))
306
+
304
307
305
308
// Implicits
306
309
Original file line number Diff line number Diff line change @@ -84,7 +84,13 @@ class Properties(val name: String) extends Prop {
84
84
* }}}
85
85
*/
86
86
class PropertySpecifier () {
87
- def update (propName : String , p : Prop ) = props += ((name+ " ." + propName, p))
87
+ // TODO: Delete this in 1.14 -- kept for binary compat with 1.13.3 and prior
88
+ protected def update (propName : String , p : Prop ) = {
89
+ props += ((name+ " ." + propName, p))
90
+ }
91
+ def update (propName : String , p : => Prop ) = {
92
+ props += ((name+ " ." + propName, Prop .suspend(p)))
93
+ }
88
94
}
89
95
90
96
lazy val property = new PropertySpecifier ()
You can’t perform that action at this time.
0 commit comments