Performs a configured property checks by applying property check functions passed to its apply
methods to arguments
supplied by implicitly passed generators, modifying the values in the
PropertyGenConfig
object passed implicitly to its apply
methods with parameter values passed to its constructor.
Performs a configured property checks by applying property check functions passed to its apply
methods to arguments
supplied by implicitly passed generators, modifying the values in the
PropertyGenConfig
object passed implicitly to its apply
methods with parameter values passed to its constructor.
Instances of this class are returned by trait GeneratorDrivenPropertyChecks
forAll
method that accepts a variable length
argument list of PropertyCheckConfigParam
objects. Thus it is used with functions of all six arities.
Here are some examples:
forAll (minSize(1), sizeRange(9)) { (a: String) => a.length should equal ((a).length) } forAll (minSize(1), sizeRange(9)) { (a: String, b: String) => a.length + b.length should equal ((a + b).length) } forAll (minSize(1), sizeRange(9)) { (a: String, b: String, c: String) => a.length + b.length + c.length should equal ((a + b + c).length) } forAll (minSize(1), sizeRange(9)) { (a: String, b: String, c: String, d: String) => a.length + b.length + c.length + d.length should equal ((a + b + c + d).length) } forAll (minSize(1), sizeRange(9)) { (a: String, b: String, c: String, d: String, e: String) => a.length + b.length + c.length + d.length + e.length should equal ((a + b + c + d + e).length) } forAll (minSize(1), sizeRange(9)) { (a: String, b: String, c: String, d: String, e: String, f: String) => a.length + b.length + c.length + d.length + e.length + f.length should equal ((a + b + c + d + e + f).length) }
In the first example above, the ConfiguredPropertyCheck
object is returned by:
forAll (minSize(1), sizeRange(9))
The code that follows is an invocation of one of the ConfiguredPropertyCheck
apply
methods:
{ (a: String) => a.length should equal ((a).length) }
A PropertyCheckConfigParam that specifies how many generated values may be discarded, as a multiple of the successful attempts, before the property check is considered to be org.scalatest.prop.PropertyCheckResult.Exhausted.
A PropertyCheckConfigParam that specifies how many generated values may be discarded, as a multiple of the successful attempts, before the property check is considered to be org.scalatest.prop.PropertyCheckResult.Exhausted.
In GeneratorDrivenPropertyChecks
, a property evaluation is discarded if it throws
DiscardedEvaluationException
, which is produced by a whenever
clause that
evaluates to false. For example, consider this ScalaTest property check:
// forAll defined in GeneratorDrivenPropertyChecks
forAll { (n: Int) =>
whenever (n > 0) {
doubleIt(n) should equal (n * 2)
}
}
In the above code, whenever a non-positive n
is passed, the property function will complete abruptly
with DiscardedEvaluationException
.
Similarly, in Checkers
, a property evaluation is discarded if the expression to the left
of ScalaCheck's ==>
operator is false. Here's an example:
// forAll defined in Checkers
forAll { (n: Int) =>
(n > 0) ==> doubleIt(n) == (n * 2)
}
For either kind of property check, MaxDiscardedFactor
indicates the maximum fraction of
total tests that may be discarded, relative to the number of successful tests. For example, if this
is set to 4.0, and you are running 100 tests, it may discard up to 400 tries before considering the
test to be org.scalatest.prop.PropertyCheckResult.Exhausted.
the permitted number of discarded tests, as a multiple of successful ones.
A PropertyCheckConfigParam
that specifies the minimum size parameter to
provide to ScalaCheck, which it will use when generating objects for which size matters (such as
strings or lists).
A PropertyCheckConfigParam
that specifies the minimum size parameter to
provide to ScalaCheck, which it will use when generating objects for which size matters (such as
strings or lists).
A PropertyCheckConfigParam
that specifies the minimum number of successful
property evaluations required for the property to pass.
A PropertyCheckConfigParam
that specifies the minimum number of successful
property evaluations required for the property to pass.
Once this many evaluations have passed, the property will return PropertyCheckResult.Success.
Abstract class defining a family of configuration parameters for property checks.
Abstract class defining a family of configuration parameters for property checks.
The subclasses of this abstract class are used to pass configuration information to
the forAll
methods of traits PropertyChecks
(for ScalaTest-style
property checks) and Checkers
(for ScalaCheck-style property checks).
Describes the configuration to use when evaluating a property.
Describes the configuration to use when evaluating a property.
the minimum number of successful property evaluations required for the property to pass; see MinSuccessful
how many generated values may be discarded, as a multiple of the successful attempts, before the property check is considered to be org.scalatest.prop.PropertyCheckResult.Exhausted; see MaxDiscardedFactor
the minimum size parameter to provide to ScalaCheck, which it will use when generating objects for which size matters (such as strings or lists); see MinSize
the maximum size parameter to provide to ScalaCheck, which it will use when generating objects for which size matters (such as strings or lists); see SizeRange
number of worker threads to use when evaluating a property; see Workers
A PropertyCheckConfigParam
that (with minSize) specifies the maximum size parameter to
provide to ScalaCheck, which it will use when generating objects for which size matters (such as
strings or lists).
A PropertyCheckConfigParam
that (with minSize) specifies the maximum size parameter to
provide to ScalaCheck, which it will use when generating objects for which size matters (such as
strings or lists).
Note that the size range is added to minSize in order to calculate the maximum size passed to ScalaCheck. Using a range allows compile-time checking of a non-negative number being specified.
A PropertyCheckConfigParam
that specifies the number of worker threads
to use when evaluating a property.
A PropertyCheckConfigParam
that specifies the number of worker threads
to use when evaluating a property.
Property evaluation runs on a single thread by default, but may run multiple threads if desired. If so, the evaluation will generally run faster. However, be careful not to use this if there is any risk of deadlocks, race conditions, or other hazards of multi-threaded code in evaluating this property or the code under test.
Internal utility functions for configuration management.
Internal utility functions for configuration management.
Object containing one apply
factory method for each TableFor<n>
class.
Object containing one apply
factory method for each TableFor<n>
class.
For example, you could create a table of 5 rows and 2 colums like this:
import org.scalatest.prop.Tables._ val examples = Table( ("a", "b"), ( 1, 2), ( 2, 4), ( 4, 8), ( 8, 16), ( 16, 32) )
Because you supplied 2 members in each tuple, the type you'll get back will be a TableFor2
. If
you wanted a table with just one column you could write this:
val moreExamples = Table( "powerOfTwo", 1, 2, 4, 8, 16 )
Or if you wanted a table with 10 columns and 10 rows, you could do this:
val multiplicationTable = Table( ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j"), ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), ( 2, 4, 6, 8, 10, 12, 14, 16, 18, 20), ( 3, 6, 9, 12, 15, 18, 21, 24, 27, 30), ( 4, 8, 12, 16, 20, 24, 28, 32, 36, 40), ( 5, 10, 15, 20, 25, 30, 35, 40, 45, 50), ( 6, 12, 18, 24, 30, 36, 42, 48, 54, 60), ( 7, 14, 21, 28, 35, 42, 49, 56, 63, 70), ( 8, 16, 24, 32, 40, 48, 56, 64, 72, 80), ( 9, 18, 27, 36, 45, 54, 63, 72, 81, 90), ( 10, 20, 30, 40, 50, 60, 70, 80, 90, 100) )
The type of multiplicationTable
would be TableFor10
. You can pass the resulting
tables to a forAll
method (defined in trait PropertyChecks
), to perform a property
check with the data in the table. Or, because tables are sequences of tuples, you can treat them as a Seq
.
Create a Generator that returns values in the specified range.
Create a Generator that returns values in the specified range.
This is the general-purpose function that underlies all of the other xxsBetween()
functions in
CommonGenerators. It works with any type for which there is an Ordering, a Generator, and
a Chooser, making it easy to create Generators for ranges within that type.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
. (However "less than or equal"
is defined for this type.)
The "edges" -- the edge case values -- for this type will be taken from the implicit
Generator. This function then filters out any that aren't within the specified range,
and adds the from
and to
values as edges.
The implicit Chooser is used to pick random values of the type. That should do most of the heavy lifting.
Since this underlies the more-specific xxsBetween()
functions, you may use either those
or this when appropriate. For example, this:
intsBetween(1, 100)
and
between(1, 100)
are functionally identical so long as the types of the parameters are clear to the compiler. Use whichever suits your project's coding style better.
the type to choose a value from
the lower bound of the range to choose from
the upper bound of the range to choose from
an instance of Ordering[T]
, which should usually be in implicit scope
an instance of Chooser[T]
, which should usually be in implicit scope
an instance of Generator[T]
, which should usually be in implicit scope
a new Generator, that produces values in the specified range
A Generator that produces Boolean values.
A Generator that produces Boolean values.
A Generator that produces Byte values.
A Generator that produces Byte values.
Create a Generator that returns Bytes in the specified range.
Create a Generator that returns Bytes in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces Char values.
A Generator that produces Char values.
Create a Generator that returns Chars in the specified range.
Create a Generator that returns Chars in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
Generate a bunch of values from a Generator, and distribute them into buckets.
Generate a bunch of values from a Generator, and distribute them into buckets.
This function mainly exists for the purpose of testing your Generator, and making sure that it is actually creating data with the sort of distribution you expect. You provide the Generator, the number of values to create, and a function that "classifies" each value with a String; it returns a Classification that collates all of the results. You can then look at the Classification to see if the proportions match your expectations.
For example, consider this simple classification of small numbers:
val classification: Classification = CommonGenerators.classify(10000, CommonGenerators.intsBetween(0, 9)) { case x if (x % 2) == 0 => "even" case _ => "odd" }
As expected, the results come out evenly:
classification: org.scalatest.prop.Classification = 50% odd 50% even
The options provided in the PartialFunction do not have to be comprehensive; it is legal for some generated values to not match any of the choices. In this case, those values will not be accounted for in the resulting Classification.
the type to be generated
the number of values to generate
the Generator to use
a PartialFunction that takes the generated values, and sorts them into "buckets" by String names
statistics on how many values wound up in each bucket
A Generator that produces Double values.
A Generator that produces Double values.
Create a Generator that returns Doubles in the specified range.
Create a Generator that returns Doubles in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
Given Generators for two types, L and R, this provides one for Either[L, R]
.
Given Generators for two types, L and R, this provides one for Either[L, R]
.
the Left type for an Either
the Right type for an Either
a Generator that produces type L
a Generator that produces type R
a Generator that produces Either[L, R]
Given a number of Generators, this creates one that invokes each of its constituents with roughly the same frequency.
Given a number of Generators, this creates one that invokes each of its constituents with roughly the same frequency.
Consider this example:
val numbers: Generator[Char] = ... // generates only digits val letters: Generator[Char] = ... // generates only letters val punct: Generator[Char] = ... // generates only punctuation val chars: Generator[Char] = evenly(numbers, letters, punct)
The chars
Generator should produce numbers, letters and punctuation, each about a third
of the time.
Keep in mind that the distribution is invoked randomly, so these are rough proportions. As you invoke the Generator more times, you should see results that are closer and closer to an equal distribution, but the random element will generally keep it inexact.
As usual, the resulting Generator will use the Randomizer passed in to Generator.next() to choose which of the constituent Generators to invoke. So if you use the same seed to initialize your Randomizer, you should get the same results.
Note that all of the constituent Generators must produce the same type.
the type to be produced
a Generator to choose from
another Generator to choose from
any number of additional Generators to choose from
a single Generator that invokes each of its constituents roughly the same number of times
Performs a property check by applying the specified property check function to each row
of the specified TableFor22
and succeeding if at least one element satisfies the property check.
Performs a property check by applying the specified property check function to each row
of the specified TableFor22
and succeeding if at least one element satisfies the property check.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor21
and succeeding if at least one element satisfies the property check.
Performs a property check by applying the specified property check function to each row
of the specified TableFor21
and succeeding if at least one element satisfies the property check.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor20
and succeeding if at least one element satisfies the property check.
Performs a property check by applying the specified property check function to each row
of the specified TableFor20
and succeeding if at least one element satisfies the property check.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor19
and succeeding if at least one element satisfies the property check.
Performs a property check by applying the specified property check function to each row
of the specified TableFor19
and succeeding if at least one element satisfies the property check.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor18
and succeeding if at least one element satisfies the property check.
Performs a property check by applying the specified property check function to each row
of the specified TableFor18
and succeeding if at least one element satisfies the property check.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor17
and succeeding if at least one element satisfies the property check.
Performs a property check by applying the specified property check function to each row
of the specified TableFor17
and succeeding if at least one element satisfies the property check.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor16
and succeeding if at least one element satisfies the property check.
Performs a property check by applying the specified property check function to each row
of the specified TableFor16
and succeeding if at least one element satisfies the property check.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor15
and succeeding if at least one element satisfies the property check.
Performs a property check by applying the specified property check function to each row
of the specified TableFor15
and succeeding if at least one element satisfies the property check.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor14
and succeeding if at least one element satisfies the property check.
Performs a property check by applying the specified property check function to each row
of the specified TableFor14
and succeeding if at least one element satisfies the property check.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor13
and succeeding if at least one element satisfies the property check.
Performs a property check by applying the specified property check function to each row
of the specified TableFor13
and succeeding if at least one element satisfies the property check.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor12
and succeeding if at least one element satisfies the property check.
Performs a property check by applying the specified property check function to each row
of the specified TableFor12
and succeeding if at least one element satisfies the property check.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor11
and succeeding if at least one element satisfies the property check.
Performs a property check by applying the specified property check function to each row
of the specified TableFor11
and succeeding if at least one element satisfies the property check.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor10
and succeeding if at least one element satisfies the property check.
Performs a property check by applying the specified property check function to each row
of the specified TableFor10
and succeeding if at least one element satisfies the property check.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor9
and succeeding if at least one element satisfies the property check.
Performs a property check by applying the specified property check function to each row
of the specified TableFor9
and succeeding if at least one element satisfies the property check.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor8
and succeeding if at least one element satisfies the property check.
Performs a property check by applying the specified property check function to each row
of the specified TableFor8
and succeeding if at least one element satisfies the property check.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor7
and succeeding if at least one element satisfies the property check.
Performs a property check by applying the specified property check function to each row
of the specified TableFor7
and succeeding if at least one element satisfies the property check.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor6
and succeeding if at least one element satisfies the property check.
Performs a property check by applying the specified property check function to each row
of the specified TableFor6
and succeeding if at least one element satisfies the property check.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor5
and succeeding if at least one element satisfies the property check.
Performs a property check by applying the specified property check function to each row
of the specified TableFor5
and succeeding if at least one element satisfies the property check.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor4
and succeeding if at least one element satisfies the property check.
Performs a property check by applying the specified property check function to each row
of the specified TableFor4
and succeeding if at least one element satisfies the property check.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor3
and succeeding if at least one element satisfies the property check.
Performs a property check by applying the specified property check function to each row
of the specified TableFor3
and succeeding if at least one element satisfies the property check.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor2
and succeeding if at least one element satisfies the property check.
Performs a property check by applying the specified property check function to each row
of the specified TableFor2
and succeeding if at least one element satisfies the property check.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor1
and succeeding if at least one element satisfies the property check.
Performs a property check by applying the specified property check function to each row
of the specified TableFor1
and succeeding if at least one element satisfies the property check.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
A Generator that produces Double values, including zero but not including infinities or NaN
.
A Generator that produces Double values, including zero but not including infinities or NaN
.
A Generator that produces FiniteDouble values.
A Generator that produces FiniteDouble values.
Create a Generator that returns FiniteDoubles in the specified range.
Create a Generator that returns FiniteDoubles in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces Float values, including zero but not including infinities or NaN
.
A Generator that produces Float values, including zero but not including infinities or NaN
.
A Generator that produces FiniteFloat values.
A Generator that produces FiniteFloat values.
Create a Generator that returns FiniteFloats in the specified range.
Create a Generator that returns FiniteFloats in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator of prime numbers.
A Generator of prime numbers.
As the name implies, this doesn't try to generate entirely arbitrary prime numbers. Instead, it takes the simpler and more efficient approach of choosing randomly from a hard-coded table of the first 1000 primes. As a result, the largest number that can be produced from this is 7919.
a Generator that will produce smallish prime numbers
A Generator that produces Float values.
A Generator that produces Float values.
Create a Generator that returns Floats in the specified range.
Create a Generator that returns Floats in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
Performs a property check by applying the specified property check function to arguments
supplied by implicitly passed generators, modifying the values in the implicitly passed
PropertyGenConfig
object with explicitly passed parameter values.
Performs a property check by applying the specified property check function to arguments
supplied by implicitly passed generators, modifying the values in the implicitly passed
PropertyGenConfig
object with explicitly passed parameter values.
This method creates a ConfiguredPropertyCheck
object that has six overloaded apply methods
that take a function. Thus it is used with functions of all six arities.
Here are some examples:
forAll (minSize(1), sizeRange(9)) { (a: String) => a.length should equal ((a).length) } forAll (minSize(1), sizeRange(9)) { (a: String, b: String) => a.length + b.length should equal ((a + b).length) } forAll (minSize(1), sizeRange(9)) { (a: String, b: String, c: String) => a.length + b.length + c.length should equal ((a + b + c).length) } forAll (minSize(1), sizeRange(9)) { (a: String, b: String, c: String, d: String) => a.length + b.length + c.length + d.length should equal ((a + b + c + d).length) } forAll (minSize(1), sizeRange(9)) { (a: String, b: String, c: String, d: String, e: String) => a.length + b.length + c.length + d.length + e.length should equal ((a + b + c + d + e).length) } forAll (minSize(1), sizeRange(9)) { (a: String, b: String, c: String, d: String, e: String, f: String) => a.length + b.length + c.length + d.length + e.length + f.length should equal ((a + b + c + d + e + f).length) }
a variable length list of PropertyCheckConfigParam
objects that should override corresponding
values in the PropertyCheckConfiguration
implicitly passed to the apply
methods of the ConfiguredPropertyCheck
object returned by this method.
Performs a property check by applying the specified property check function to each row
of the specified TableFor22
.
Performs a property check by applying the specified property check function to each row
of the specified TableFor22
.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor21
.
Performs a property check by applying the specified property check function to each row
of the specified TableFor21
.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor20
.
Performs a property check by applying the specified property check function to each row
of the specified TableFor20
.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor19
.
Performs a property check by applying the specified property check function to each row
of the specified TableFor19
.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor18
.
Performs a property check by applying the specified property check function to each row
of the specified TableFor18
.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor17
.
Performs a property check by applying the specified property check function to each row
of the specified TableFor17
.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor16
.
Performs a property check by applying the specified property check function to each row
of the specified TableFor16
.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor15
.
Performs a property check by applying the specified property check function to each row
of the specified TableFor15
.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor14
.
Performs a property check by applying the specified property check function to each row
of the specified TableFor14
.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor13
.
Performs a property check by applying the specified property check function to each row
of the specified TableFor13
.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor12
.
Performs a property check by applying the specified property check function to each row
of the specified TableFor12
.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor11
.
Performs a property check by applying the specified property check function to each row
of the specified TableFor11
.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor10
.
Performs a property check by applying the specified property check function to each row
of the specified TableFor10
.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor9
.
Performs a property check by applying the specified property check function to each row
of the specified TableFor9
.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor8
.
Performs a property check by applying the specified property check function to each row
of the specified TableFor8
.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor7
.
Performs a property check by applying the specified property check function to each row
of the specified TableFor7
.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor6
.
Performs a property check by applying the specified property check function to each row
of the specified TableFor6
.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor5
.
Performs a property check by applying the specified property check function to each row
of the specified TableFor5
.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor4
.
Performs a property check by applying the specified property check function to each row
of the specified TableFor4
.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor3
.
Performs a property check by applying the specified property check function to each row
of the specified TableFor3
.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor2
.
Performs a property check by applying the specified property check function to each row
of the specified TableFor2
.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor1
.
Performs a property check by applying the specified property check function to each row
of the specified TableFor1
.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor22
and reporting every error.
Performs a property check by applying the specified property check function to each row
of the specified TableFor22
and reporting every error.
The difference between forEvery
and forAll
is that
forEvery
will continue to inspect all elements after first failure, and report all failures,
whereas forAll
will stop on (and only report) the first failure.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor21
and reporting every error.
Performs a property check by applying the specified property check function to each row
of the specified TableFor21
and reporting every error.
The difference between forEvery
and forAll
is that
forEvery
will continue to inspect all elements after first failure, and report all failures,
whereas forAll
will stop on (and only report) the first failure.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor20
and reporting every error.
Performs a property check by applying the specified property check function to each row
of the specified TableFor20
and reporting every error.
The difference between forEvery
and forAll
is that
forEvery
will continue to inspect all elements after first failure, and report all failures,
whereas forAll
will stop on (and only report) the first failure.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor19
and reporting every error.
Performs a property check by applying the specified property check function to each row
of the specified TableFor19
and reporting every error.
The difference between forEvery
and forAll
is that
forEvery
will continue to inspect all elements after first failure, and report all failures,
whereas forAll
will stop on (and only report) the first failure.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor18
and reporting every error.
Performs a property check by applying the specified property check function to each row
of the specified TableFor18
and reporting every error.
The difference between forEvery
and forAll
is that
forEvery
will continue to inspect all elements after first failure, and report all failures,
whereas forAll
will stop on (and only report) the first failure.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor17
and reporting every error.
Performs a property check by applying the specified property check function to each row
of the specified TableFor17
and reporting every error.
The difference between forEvery
and forAll
is that
forEvery
will continue to inspect all elements after first failure, and report all failures,
whereas forAll
will stop on (and only report) the first failure.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor16
and reporting every error.
Performs a property check by applying the specified property check function to each row
of the specified TableFor16
and reporting every error.
The difference between forEvery
and forAll
is that
forEvery
will continue to inspect all elements after first failure, and report all failures,
whereas forAll
will stop on (and only report) the first failure.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor15
and reporting every error.
Performs a property check by applying the specified property check function to each row
of the specified TableFor15
and reporting every error.
The difference between forEvery
and forAll
is that
forEvery
will continue to inspect all elements after first failure, and report all failures,
whereas forAll
will stop on (and only report) the first failure.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor14
and reporting every error.
Performs a property check by applying the specified property check function to each row
of the specified TableFor14
and reporting every error.
The difference between forEvery
and forAll
is that
forEvery
will continue to inspect all elements after first failure, and report all failures,
whereas forAll
will stop on (and only report) the first failure.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor13
and reporting every error.
Performs a property check by applying the specified property check function to each row
of the specified TableFor13
and reporting every error.
The difference between forEvery
and forAll
is that
forEvery
will continue to inspect all elements after first failure, and report all failures,
whereas forAll
will stop on (and only report) the first failure.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor12
and reporting every error.
Performs a property check by applying the specified property check function to each row
of the specified TableFor12
and reporting every error.
The difference between forEvery
and forAll
is that
forEvery
will continue to inspect all elements after first failure, and report all failures,
whereas forAll
will stop on (and only report) the first failure.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor11
and reporting every error.
Performs a property check by applying the specified property check function to each row
of the specified TableFor11
and reporting every error.
The difference between forEvery
and forAll
is that
forEvery
will continue to inspect all elements after first failure, and report all failures,
whereas forAll
will stop on (and only report) the first failure.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor10
and reporting every error.
Performs a property check by applying the specified property check function to each row
of the specified TableFor10
and reporting every error.
The difference between forEvery
and forAll
is that
forEvery
will continue to inspect all elements after first failure, and report all failures,
whereas forAll
will stop on (and only report) the first failure.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor9
and reporting every error.
Performs a property check by applying the specified property check function to each row
of the specified TableFor9
and reporting every error.
The difference between forEvery
and forAll
is that
forEvery
will continue to inspect all elements after first failure, and report all failures,
whereas forAll
will stop on (and only report) the first failure.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor8
and reporting every error.
Performs a property check by applying the specified property check function to each row
of the specified TableFor8
and reporting every error.
The difference between forEvery
and forAll
is that
forEvery
will continue to inspect all elements after first failure, and report all failures,
whereas forAll
will stop on (and only report) the first failure.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor7
and reporting every error.
Performs a property check by applying the specified property check function to each row
of the specified TableFor7
and reporting every error.
The difference between forEvery
and forAll
is that
forEvery
will continue to inspect all elements after first failure, and report all failures,
whereas forAll
will stop on (and only report) the first failure.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor6
and reporting every error.
Performs a property check by applying the specified property check function to each row
of the specified TableFor6
and reporting every error.
The difference between forEvery
and forAll
is that
forEvery
will continue to inspect all elements after first failure, and report all failures,
whereas forAll
will stop on (and only report) the first failure.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor5
and reporting every error.
Performs a property check by applying the specified property check function to each row
of the specified TableFor5
and reporting every error.
The difference between forEvery
and forAll
is that
forEvery
will continue to inspect all elements after first failure, and report all failures,
whereas forAll
will stop on (and only report) the first failure.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor4
and reporting every error.
Performs a property check by applying the specified property check function to each row
of the specified TableFor4
and reporting every error.
The difference between forEvery
and forAll
is that
forEvery
will continue to inspect all elements after first failure, and report all failures,
whereas forAll
will stop on (and only report) the first failure.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor3
and reporting every error.
Performs a property check by applying the specified property check function to each row
of the specified TableFor3
and reporting every error.
The difference between forEvery
and forAll
is that
forEvery
will continue to inspect all elements after first failure, and report all failures,
whereas forAll
will stop on (and only report) the first failure.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor2
and reporting every error.
Performs a property check by applying the specified property check function to each row
of the specified TableFor2
and reporting every error.
The difference between forEvery
and forAll
is that
forEvery
will continue to inspect all elements after first failure, and report all failures,
whereas forAll
will stop on (and only report) the first failure.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Performs a property check by applying the specified property check function to each row
of the specified TableFor1
and reporting every error.
Performs a property check by applying the specified property check function to each row
of the specified TableFor1
and reporting every error.
The difference between forEvery
and forAll
is that
forEvery
will continue to inspect all elements after first failure, and report all failures,
whereas forAll
will stop on (and only report) the first failure.
the table of data with which to perform the property check
the property check function to apply to each row of data in the table
Given a number of Generators, and the weightings for each one, this creates a Generator that invokes each of its components according to its weighting.
Given a number of Generators, and the weightings for each one, this creates a Generator that invokes each of its components according to its weighting.
For example, consider this:
val evens: Generator[Int] = ... // generates even Ints val odds: Generator[Int] = ... // generates odd Ints val zeros: Generator[Int] = specificValue(0) val mixed: Generator[Int] = frequency( (5, evens), (4, odds), (1, zeros) )
The total weighting is (5 + 4 + 1) = 10. So the resulting Generator will produce an even number (10 / 5) = 50% the time, an odd number (10 / 4) = 40% of the time, and zero (10 / 1) = 10% of the time.
Keep in mind that the distribution is invoked randomly, so these are rough proportions. As you invoke the Generator more times, you should see results that are closer and closer to the specified proportions, but the random element will generally keep it inexact.
As usual, the resulting Generator will use the Randomizer passed in to Generator.next() to choose which of the constituent Generators to invoke. So if you use the same seed to initialize your Randomizer, you should get the same results.
Note that all of the constituent Generators must produce the same type.
the type being produced by all of these Generators
a Generator and its weight
another Generator and its weight
as many more Generator and weight pairs as you like
a single Generator, that invokes its constituents according to their weights
Given a Generator that produces values of type A, this returns one that produces functions that return a T.
Given a Generator that produces values of type A, this returns one that produces functions that return a T.
The functions produced here are nullary -- they take no parameters, they just spew out values of type A.
the type to return from the generated functions
a Generator that produces functions that return values of type A
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
Create a Generator of functions from type A to type B.
Create a Generator of functions from type A to type B.
Note that the generated functions are, necessarily, pretty random. In practice, the function you get from a function1s call (and its variations, up through function22s) takes the hashes of its input values, combines those with a randomly-chosen number, and combines them in order to choose the generated value B.
That said, each of the generated functions is deterministic: given the same input parameters and the same
randomly-chosen number, you will always get the same B result. And the toString
function on the generated
function will show the formula you need to use in order to recreate that, which will look something like:
(a: Int, b: String, c: Float) => org.scalatest.prop.valueOf[String](a, b, c)(131)
The number and type of the a
, b
, c
, etc, parameters, as well as the type parameter of valueOf, will depend
on the function type you are generating, but they will always follow this pattern. valueOf is the underlying
function that takes these parameters and the randomly-chosen number, and returns a value of the specified type.
So if a property evaluation fails, the display of the generated function will tell you how to call valueOf to recreate the failure.
The typeInfo
parameters are automatically created via macros; you should generally not try to pass them manually.
the input type for the generated functions
the result type for the generated functions
a Generator for the desired result type B
automatically-created type information for type A
automatically-created type information for type B
a Generator that produces functions that take values of A and returns values of B
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
See function1s.
Implicit PropertyCheckConfig
value providing default configuration values.
Implicit PropertyCheckConfig
value providing default configuration values.
Given some optional PropertyCheckConfigParams and a PropertyCheckConfiguration, compute the resulting Configuration.Parameter.
Given some optional PropertyCheckConfigParams and a PropertyCheckConfiguration, compute the resulting Configuration.Parameter.
This function deals with resolving the various forms of these configuration values, into a consistent form suitable for using in properties.
Duplicate PropertyCheckConfigParam entries are not permitted in the configParams
list.
TODO: should this function be public? It feels like an internal implementation detail -- I think it should be private.
optionally, some parameters that differ from the provided c
a fully-set-up Configuration.Parameter object, ready to evaluate properties with.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
See the simple [A, B]
version of instancesOf()
for details.
The instancesOf
function (which has overloads depending on how many parameters you need)
is one way to create a Generator for case classes and other situations where you
want to build a type out of other types.
The instancesOf
function (which has overloads depending on how many parameters you need)
is one way to create a Generator for case classes and other situations where you
want to build a type out of other types.
To understand how it works, look at this example:
case class Person(name: String, age: Int) implicit val persons: Generator[Person] = instancesOf(Person) { p => (p.name, p.age) } (strings, posZIntValues)
What's going on here? instancesOf
is taking two types (String and Int),
a function (a case class constructor) that turns those types into a third type (Person
),
and a second function that takes a Person
and deconstructs it back to its component
pieces. From those, it creates a Generator.
The last parameters -- the (strings, posZIntValues)
-- are the Generators for
the component types. If you are good with using the default Generators for those types,
you can just let those parameters be resolved implicitly. (But in this case, that
could result in negative ages, which doesn't make any sense.)
After creating a Generator this way, you can use it like any other Generator in your property checks.
Alternatively, you can construct Generators for case classes using for comprehensions, like this:
implicit val persons: Generator[Person] = for { name <- strings age <- posZIntValues } yield Person(name, age)
Which approach you use is mainly up to personal taste and the coding standards of your project.
the input type
the target type to be generated
a constructor that builds the target type from its constituents; most often, a case class constructor
a deconstructor function that takes the target type and breaks is down into its constituents
a Generator for the input type
a Generator for the target type
A Generator that produces Int values.
A Generator that produces Int values.
Create a Generator that returns Ints in the specified range.
Create a Generator that returns Ints in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
Given an existing Generator[T]
, this creates a Generator[List[T]]
.
Given an existing Generator[T]
, this creates a Generator[List[T]]
.
the type that we are producing a List of
a Generator that produces values of type T
a List of values of type T
A Generator that produces Long values.
A Generator that produces Long values.
Create a Generator that returns Longs in the specified range.
Create a Generator that returns Longs in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
Given a Generator that produces Tuples of key/value pairs, this gives you one that produces Maps with those pairs.
Given a Generator that produces Tuples of key/value pairs, this gives you one that produces Maps with those pairs.
If you are simply looking for random pairing of the key and value types, this is pretty easy to use: if both the key and value types have Generators, then the Tuple and Map ones will be automatically and implicitly created when you need them.
The resulting Generator also has the HavingSize trait, so you can use it to generate Maps with specific sizes.
the type of the keys for the Map
the type of the values for the Map
a Generator of Maps from K to V
Returns a MaxDiscardedFactor
property check configuration parameter containing the passed value, which specifies the factor of discarded
property evaluations allowed during property evaluation.
Returns a MaxDiscardedFactor
property check configuration parameter containing the passed value, which specifies the factor of discarded
property evaluations allowed during property evaluation.
Returns a MinSize
property check configuration parameter containing the passed value, which specifies the minimum size parameter to
provide to ScalaCheck, which it will use when generating objects for which size matters (such as
strings or lists).
Returns a MinSize
property check configuration parameter containing the passed value, which specifies the minimum size parameter to
provide to ScalaCheck, which it will use when generating objects for which size matters (such as
strings or lists).
Returns a MinSuccessful
property check configuration parameter containing the passed value, which specifies the minimum number of successful
property evaluations required for the property to pass.
Returns a MinSuccessful
property check configuration parameter containing the passed value, which specifies the minimum number of successful
property evaluations required for the property to pass.
A Generator that produces negative Double values, not including zero but including
infinity and NaN
.
A Generator that produces negative Double values, not including zero but including
infinity and NaN
.
A Generator that produces NegDouble values.
A Generator that produces NegDouble values.
Create a Generator that returns NegDoubles in the specified range.
Create a Generator that returns NegDoubles in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces negative Double values, not including zero, infinity or
NaN
.
A Generator that produces negative Double values, not including zero, infinity or
NaN
.
A Generator that produces NegFiniteDouble values.
A Generator that produces NegFiniteDouble values.
Create a Generator that returns NegFiniteDoubles in the specified range.
Create a Generator that returns NegFiniteDoubles in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces negative Float values, not including zero, infinity
or NaN
.
A Generator that produces negative Float values, not including zero, infinity
or NaN
.
A Generator that produces NegFiniteFloat values.
A Generator that produces NegFiniteFloat values.
Create a Generator that returns NegFiniteFloats in the specified range.
Create a Generator that returns NegFiniteFloats in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces negative Float values, not including zero but including
infinity and NaN
.
A Generator that produces negative Float values, not including zero but including
infinity and NaN
.
A Generator that produces NegFloat values.
A Generator that produces NegFloat values.
Create a Generator that returns NegFloats in the specified range.
Create a Generator that returns NegFloats in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces negative Int values, not including zero.
A Generator that produces negative Int values, not including zero.
A Generator that produces NegInt values.
A Generator that produces NegInt values.
Create a Generator that returns NegInts in the specified range.
Create a Generator that returns NegInts in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces negative Long values, not including zero.
A Generator that produces negative Long values, not including zero.
A Generator that produces NegLong values.
A Generator that produces NegLong values.
Create a Generator that returns NegLongs in the specified range.
Create a Generator that returns NegLongs in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces negative Double values, including zero, infinity and NaN
.
A Generator that produces negative Double values, including zero, infinity and NaN
.
A Generator that produces NegZDouble values.
A Generator that produces NegZDouble values.
Create a Generator that returns NegZDoubles in the specified range.
Create a Generator that returns NegZDoubles in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces negative Double values, including zero but not including
infinity or NaN
.
A Generator that produces negative Double values, including zero but not including
infinity or NaN
.
A Generator that produces NegZFiniteDouble values.
A Generator that produces NegZFiniteDouble values.
Create a Generator that returns NegZFiniteDoubles in the specified range.
Create a Generator that returns NegZFiniteDoubles in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces negative Float values, including zero but not
including infinity or NaN
.
A Generator that produces negative Float values, including zero but not
including infinity or NaN
.
A Generator that produces NegZFiniteFloat values.
A Generator that produces NegZFiniteFloat values.
Create a Generator that returns NegZFiniteFloats in the specified range.
Create a Generator that returns NegZFiniteFloats in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces negative Float values, including zero, infinity
and NaN
.
A Generator that produces negative Float values, including zero, infinity
and NaN
.
A Generator that produces NegZFloat values.
A Generator that produces NegZFloat values.
Create a Generator that returns NegZFloats in the specified range.
Create a Generator that returns NegZFloats in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces negative Int values, including zero.
A Generator that produces negative Int values, including zero.
A Generator that produces NegZInt values.
A Generator that produces NegZInt values.
Create a Generator that returns NegZInts in the specified range.
Create a Generator that returns NegZInts in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces negative Long values, including zero.
A Generator that produces negative Long values, including zero.
A Generator that produces NegZLong values.
A Generator that produces NegZLong values.
Create a Generator that returns NegZLongs in the specified range.
Create a Generator that returns NegZLongs in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces non-zero Double values, including infinity and NaN
.
A Generator that produces non-zero Double values, including infinity and NaN
.
A Generator that produces NonZeroDouble values.
A Generator that produces NonZeroDouble values.
Create a Generator that returns NonZeroDoubles in the specified range.
Create a Generator that returns NonZeroDoubles in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces non-zero Double values, not including infinity and NaN
.
A Generator that produces non-zero Double values, not including infinity and NaN
.
A Generator that produces NonZeroFiniteDouble values.
A Generator that produces NonZeroFiniteDouble values.
Create a Generator that returns NonZeroFiniteDoubles in the specified range.
Create a Generator that returns NonZeroFiniteDoubles in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces non-zero Float values, not including infinity
or NaN
.
A Generator that produces non-zero Float values, not including infinity
or NaN
.
A Generator that produces NonZeroFiniteFloat values.
A Generator that produces NonZeroFiniteFloat values.
Create a Generator that returns NonZeroFiniteFloats in the specified range.
Create a Generator that returns NonZeroFiniteFloats in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces non-zero Float values, including infinity and NaN
.
A Generator that produces non-zero Float values, including infinity and NaN
.
A Generator that produces NonZeroFloat values.
A Generator that produces NonZeroFloat values.
Create a Generator that returns NonZeroFloats in the specified range.
Create a Generator that returns NonZeroFloats in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces non-zero Int values.
A Generator that produces non-zero Int values.
A Generator that produces NonZeroInt values.
A Generator that produces NonZeroInt values.
Create a Generator that returns NonZeroInts in the specified range.
Create a Generator that returns NonZeroInts in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces non-zero Long values.
A Generator that produces non-zero Long values.
A Generator that produces NonZeroLong values.
A Generator that produces NonZeroLong values.
Create a Generator that returns NonZeroLongs in the specified range.
Create a Generator that returns NonZeroLongs in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces digit Chars.
A Generator that produces digit Chars.
A Generator that produces NumericChar values.
A Generator that produces NumericChar values.
Given an existing Generator[T]
, this creates a Generator[Option[T]]
.
Given an existing Generator[T]
, this creates a Generator[Option[T]]
.
the type that we are producing an Option of
a Generator that produces values of type T
a Generator that produces Option[T]
Given Generators for two types, G and B, this provides one for G Or B
.
Given Generators for two types, G and B, this provides one for G Or B
.
the "good" type for an Or
the "bad" type for an Or
a Generator that produces type G
a Generator that produces type B
a Generator that produces G Or B
A Generator that produces positive Double values, not including zero but
including infinity and NaN
.
A Generator that produces positive Double values, not including zero but
including infinity and NaN
.
A Generator that produces PosDouble values.
A Generator that produces PosDouble values.
Create a Generator that returns PosDoubles in the specified range.
Create a Generator that returns PosDoubles in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces positive Double values, not including zero,
infinity or NaN
.
A Generator that produces positive Double values, not including zero,
infinity or NaN
.
A Generator that produces PosFiniteDouble values.
A Generator that produces PosFiniteDouble values.
Create a Generator that returns PosFiniteDoubles in the specified range.
Create a Generator that returns PosFiniteDoubles in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces positive Float values, not including zero,
infinity or NaN
.
A Generator that produces positive Float values, not including zero,
infinity or NaN
.
A Generator that produces PosFiniteFloat values.
A Generator that produces PosFiniteFloat values.
Create a Generator that returns PosFiniteFloats in the specified range.
Create a Generator that returns PosFiniteFloats in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces positive Float values, not including zero
but including infinites and NaN
.
A Generator that produces positive Float values, not including zero
but including infinites and NaN
.
A Generator that produces PosFloat values.
A Generator that produces PosFloat values.
Create a Generator that returns PosFloats in the specified range.
Create a Generator that returns PosFloats in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces positive Int values, not including zero.
A Generator that produces positive Int values, not including zero.
A Generator that produces PosInt values.
A Generator that produces PosInt values.
Create a Generator that returns PosInts in the specified range.
Create a Generator that returns PosInts in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces positive Long values, not including zero.
A Generator that produces positive Long values, not including zero.
A Generator that produces PosLong values.
A Generator that produces PosLong values.
Create a Generator that returns PosLongs in the specified range.
Create a Generator that returns PosLongs in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces positive Double values, including zero, infinity
and NaN
.
A Generator that produces positive Double values, including zero, infinity
and NaN
.
A Generator that produces PosZDouble values.
A Generator that produces PosZDouble values.
Create a Generator that returns PosZDoubles in the specified range.
Create a Generator that returns PosZDoubles in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces positive Int values.
A Generator that produces positive Int values.
A Generator that produces PosZFiniteDouble values.
A Generator that produces PosZFiniteDouble values.
Create a Generator that returns PosZFiniteDoubles in the specified range.
Create a Generator that returns PosZFiniteDoubles in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces positive Float values, including zero but not
including infinity or NaN
.
A Generator that produces positive Float values, including zero but not
including infinity or NaN
.
A Generator that produces PosZFiniteFloat values.
A Generator that produces PosZFiniteFloat values.
Create a Generator that returns PosZFiniteFloats in the specified range.
Create a Generator that returns PosZFiniteFloats in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces positive Float values, including zero, infinity
and NaN
.
A Generator that produces positive Float values, including zero, infinity
and NaN
.
A Generator that produces PosZFloat values.
A Generator that produces PosZFloat values.
Create a Generator that returns PosZFloats in the specified range.
Create a Generator that returns PosZFloats in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces positive Int values, including zero.
A Generator that produces positive Int values, including zero.
A Generator that produces PosZInt values.
A Generator that produces PosZInt values.
Create a Generator that returns PosZInts in the specified range.
Create a Generator that returns PosZInts in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
A Generator that produces positive Long values, including zero.
A Generator that produces positive Long values, including zero.
A Generator that produces PosZLong values.
A Generator that produces PosZLong values.
Create a Generator that returns PosZLongs in the specified range.
Create a Generator that returns PosZLongs in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
Given a Generator that produces values of type T, this creates one for a Set of T.
Given a Generator that produces values of type T, this creates one for a Set of T.
Note that the Set type is considered to have a "size", so you can use the configuration parameters
Configuration.minSize and Configuration.sizeRange to constrain the sizes of the resulting Set
s
when you use this Generator.
The resulting Generator also has the HavingSize trait, so you can use it to generate Sets with specific sizes.
the type to produce
a Generator that produces values of type T
a Generator that produces Set[T]
.
A Generator that produces Short values.
A Generator that produces Short values.
Create a Generator that returns Shorts in the specified range.
Create a Generator that returns Shorts in the specified range.
The range is inclusive: both from and to may be produced by this Generator. Moreover, from and to are considered to be edge cases, so they usually will be produced in a typical run.
The value of from
must be less than or equal to the value of to
.
one end of the desired range
the other end of the desired range
a value within that range, inclusive of the bounds
Returns a SizeRange
property check configuration parameter containing the passed value, that (with minSize) specifies the maximum size parameter to
provide to ScalaCheck, which it will use when generating objects for which size matters (such as
strings or lists).
Returns a SizeRange
property check configuration parameter containing the passed value, that (with minSize) specifies the maximum size parameter to
provide to ScalaCheck, which it will use when generating objects for which size matters (such as
strings or lists).
Note that the size range is added to minSize in order to calculate the maximum size passed to ScalaCheck. Using a range allows compile-time checking of a non-negative number being specified.
Given a Generator that produces Tuples of key/value pairs, this gives you one that produces SortedMaps with those pairs.
Given a Generator that produces Tuples of key/value pairs, this gives you one that produces SortedMaps with those pairs.
If you are simply looking for random pairing of the key and value types, this is pretty easy to use: if both the key and value types have Generators, then the Tuple and SortedMap ones will be automatically and implicitly created when you need them.
The resulting Generator also has the HavingSize trait, so you can use it to generate SortedMaps with specific sizes.
the type of the keys for the SortedMap
the type of the values for the SortedMap
a Generator of SortedMaps from K to V
Given a Generator that produces values of type T, this creates one for a SortedSet of T.
Given a Generator that produces values of type T, this creates one for a SortedSet of T.
Note that the SortedSet type is considered to have a "size", so you can use the configuration parameters
Configuration.minSize and Configuration.sizeRange to constrain the sizes of the resulting SortedSet
s
when you use this Generator.
The resulting Generator also has the HavingSize trait, so you can use it to generate SortedSets with specific sizes.
the type to produce
a Generator that produces values of type T
a Generator that produces SortedSet[T]
.
Creates a Generator that will always return exactly the same value.
Creates a Generator that will always return exactly the same value.
This is specialized, but occasionally useful. It is mainly appropriate when you have a function that requires a Generator, but only one value makes sense for the Property you are evaluating.
the type of that value
the value to produce
a Generator that will always produce that value
Given a list of values of type T, this creates a Generator that will only produce those values.
Given a list of values of type T, this creates a Generator that will only produce those values.
The order in which the values are produced is random, based on the Randomizer passed
in to the next
function. It may produce the same value multiple times.
the type that will be produced by the resulting Generator
a value of type T
another value of type T
more values of type T, as many as you wish
a Generator that produces exactly the specified values
A Generator that produces String values.
A Generator that produces String values.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
Given Generators for types A and B, get one that produces Tuples of those types.
Given Generators for types A and B, get one that produces Tuples of those types.
tuple2s (and its variants, up through tuple22s) will create Generators on demand for essentially arbitrary Tuples, so long as you have Generators in implicit scope for all of the component types.
the first type in the Tuple
the second type in the Tuple
a Generator for type A
a Generator for type B
a Generator that produces the desired types, Tupled together.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
See tuple2s.
Given a Generator for type T, this creates one for a Vector of T.
Given a Generator for type T, this creates one for a Vector of T.
Note that the Vector type is considered to have a "size", so you can use the configuration parameters
Configuration.minSize and Configuration.sizeRange to constrain the sizes of the resulting Vector
s
when you use this Generator.
The resulting Generator also has the HavingLength trait, so you can use it to generate Vectors with specific lengths.
the type to produce
a Generator that produces values of type T
a Generator that produces values of type Vector[T]
Evaluates the passed code block if the passed boolean condition is true, else throws DiscardedEvaluationException
.
Evaluates the passed code block if the passed boolean condition is true, else throws DiscardedEvaluationException
.
The whenever
method can be used inside property check functions to discard invocations of the function with
data for which it is known the property would fail. For example, given the following Fraction
class:
class Fraction(n: Int, d: Int) { require(d != 0) require(d != Integer.MIN_VALUE) require(n != Integer.MIN_VALUE) val numer = if (d < 0) -1 * n else n val denom = d.abs override def toString = numer + " / " + denom }
import org.scalatest.prop.TableDrivenPropertyChecks._ val fractions = Table( ("n", "d"), ( 1, 2), ( -1, 2), ( 1, -2), ( -1, -2), ( 3, 1), ( -3, 1), ( -3, 0), ( 3, -1), ( 3, Integer.MIN_VALUE), (Integer.MIN_VALUE, 3), ( -3, -1) )
Imagine you wanted to check a property against this class with data that includes some
value that are rejected by the constructor, such as a denominator of zero, which should
result in an IllegalArgumentException
. You could use whenever
to discard any rows in the fraction
that represent illegal arguments, like this:
import org.scalatest.matchers.Matchers._ forAll (fractions) { (n: Int, d: Int) => whenever (d != 0 && d != Integer.MIN_VALUE && n != Integer.MIN_VALUE) { val f = new Fraction(n, d) if (n < 0 && d < 0 || n > 0 && d > 0) f.numer should be > 0 else if (n != 0) f.numer should be < 0 else f.numer should === (0) f.denom should be > 0 } }
In this example, rows 6, 8, and 9 have values that would cause a false to be passed
to whenever
. (For example, in row 6, d
is 0, which means d
!=
0
will be false.) For those rows, whenever
will throw DiscardedEvaluationException
,
which will cause the forAll
method to discard that row.
the boolean condition that determines whether whenever
will evaluate the
fun
function (condition
is true) or throws DiscardedEvaluationException
(condition
is false)
the function to evaluate if the specified condition
is true
Returns a Workers
property check configuration parameter containing the passed value, which specifies the number of worker threads
to use when evaluating a property.
Returns a Workers
property check configuration parameter containing the passed value, which specifies the number of worker threads
to use when evaluating a property.
These functions let you create Generators that only return specific values
These cover types from both the Scala Standard Library and Scalactic
Scalactic has many highly-precise numeric types such as NonZeroLong,
PosZFloat or FiniteDouble. These help you make sure your code is using
exactly the numbers you intend, and they are very convenient for using with
Generators. But if the code under test is not using Scalactic, you
sometimes find that you need to type .value
a lot. These Generators do that
for so: you can choose a precise numeric Generator, but get the conventional
numeric type from it.
These functions take one or more types T
, and create Generators that
produce collections of T
.
Functions that create Generators for values in a specific range of a specific type.
These functions create Generators that produce random functions with specified parameter and return types.
These functions are one way to create Generators for case class instances.
Companion object that facilitates the importing of
PropertyChecks
members as an alternative to mixing it in. One use case is to importPropertyChecks
members so you can use them in the Scala interpreter.