-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable lazy construction of label strings
- Loading branch information
Showing
5 changed files
with
70 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* ScalaCheck | ||
* Copyright (c) 2007-2021 Rickard Nilsson. All rights reserved. | ||
* http://www.scalacheck.org | ||
* | ||
* This software is released under the terms of the Revised BSD License. | ||
* There is NO WARRANTY. See the file LICENSE for the full text. | ||
*/ | ||
|
||
package org.scalacheck | ||
|
||
object `package` { | ||
implicit class `by-name label :|`(private val prop: Prop) extends AnyVal { | ||
/** Label this property. | ||
* | ||
* The label is evaluated lazily. | ||
* The operator name is chosen for its precedence btween | ||
* boolean operators and others. | ||
*/ | ||
def =|= (label: => String): Prop = prop.map(_.label(label)) | ||
} | ||
// chained implicit for true =|= label | ||
implicit class `by-name label bool :| label`(private val bool: Boolean) extends AnyVal { | ||
def =|= (label: => String): Prop = (bool: Prop).=|=(label) | ||
} | ||
implicit class `by-name label |: prop`(label: => String) { | ||
def =|= (prop: Prop): Prop = prop.=|=(label) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* ScalaCheck | ||
* Copyright (c) 2007-2021 Rickard Nilsson. All rights reserved. | ||
* http://www.scalacheck.org | ||
* | ||
* This software is released under the terms of the Revised BSD License. | ||
* There is NO WARRANTY. See the file LICENSE for the full text. | ||
*/ | ||
|
||
package org.scalacheck | ||
|
||
object `package` { | ||
|
||
/** Label this property. The label is evaluated lazily. | ||
* | ||
* The operator name is chosen for its precedence between boolean operators and others. | ||
*/ | ||
extension (prop: Prop) def =|=(label: => String): Prop = prop.map(_.label(label)) | ||
|
||
extension (label: => String) def =|=(prop: Prop): Prop = prop.map(_.label(label)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters