Skip to content

Commit 720b9b3

Browse files
authored
Merge pull request #367 from evis/gen_filternot
Add Gen.filterNot() method
2 parents 6441f45 + b21040c commit 720b9b3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/main/scala/org/scalacheck/Gen.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ sealed abstract class Gen[+T] extends Serializable { self =>
9393
* test property is side-effect free, eg it should not use external vars. */
9494
def filter(p: T => Boolean): Gen[T] = suchThat(p)
9595

96+
/** Create a new generator that uses this generator to produce a value
97+
* that doesn't fulfill the given condition. If the condition is fulfilled,
98+
* the generator fails (returns None). Also, make sure that the provided
99+
* test property is side-effect free, eg it should not use external vars. */
100+
def filterNot(p: T => Boolean): Gen[T] = suchThat(x => !p(x))
101+
96102
/** Create a new generator that fails if the specified partial function
97103
* is undefined for this generator's value, otherwise returns the result
98104
* of the partial function applied to this generator's value. */

0 commit comments

Comments
 (0)