Skip to content

Commit debc313

Browse files
committed
Make Prop.label argument by-name.
1 parent 2544e31 commit debc313

File tree

1 file changed

+9
-6
lines changed
  • core/shared/src/main/scala/org/scalacheck

1 file changed

+9
-6
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,19 +149,19 @@ sealed abstract class Prop extends Serializable { self =>
149149
override def toString = "Prop"
150150

151151
/** Put a label on the property to make test reports clearer */
152-
def label(l: String) = map(_.label(l))
152+
def label(l: => String) = map(_.label(l))
153153

154154
/** Put a label on the property to make test reports clearer */
155-
def :|(l: String) = label(l)
155+
def :|(l: => String) = label(l)
156156

157157
/** Put a label on the property to make test reports clearer */
158-
def |:(l: String) = label(l)
158+
def |:(l: => String) = label(l)
159159

160160
/** Put a label on the property to make test reports clearer */
161-
def :|(l: Symbol) = label(l.name)
161+
def :|(l: => Symbol)(implicit d: DummyImplicit) = label(l.name)
162162

163163
/** Put a label on the property to make test reports clearer */
164-
def |:(l: Symbol) = label(l.name)
164+
def |:(l: => Symbol)(implicit d: DummyImplicit) = label(l.name)
165165

166166
}
167167

@@ -214,7 +214,10 @@ object Prop {
214214

215215
def collect(x: Any) = copy(collected = collected + x)
216216

217-
def label(l: String) = copy(labels = labels + (() => l))
217+
def label(l: => String) = {
218+
lazy val label = l
219+
copy(labels = labels + (() => label))
220+
}
218221

219222
def &&(r: Result) = (this.status, r.status) match {
220223
case (Exception(_), _) => this

0 commit comments

Comments
 (0)