Package io.vavr.test
Class Property
- java.lang.Object
-
- io.vavr.test.Property
-
public class Property extends java.lang.ObjectA property builder which provides a fluent API to build checkable properties.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classProperty.CheckErrorInternally used to provide more specific error messages.(package private) static classProperty.ConditionInternally used to model conditions composed of pre- and post-condition.static classProperty.ForAll1<T1>Represents a logical for all quantor.static classProperty.ForAll2<T1,T2>Represents a logical for all quantor.static classProperty.ForAll3<T1,T2,T3>Represents a logical for all quantor.static classProperty.ForAll4<T1,T2,T3,T4>Represents a logical for all quantor.static classProperty.ForAll5<T1,T2,T3,T4,T5>Represents a logical for all quantor.static classProperty.ForAll6<T1,T2,T3,T4,T5,T6>Represents a logical for all quantor.static classProperty.ForAll7<T1,T2,T3,T4,T5,T6,T7>Represents a logical for all quantor.static classProperty.ForAll8<T1,T2,T3,T4,T5,T6,T7,T8>Represents a logical for all quantor.static classProperty.Property1<T1>Represents a 1-ary checkable property.static classProperty.Property2<T1,T2>Represents a 2-ary checkable property.static classProperty.Property3<T1,T2,T3>Represents a 3-ary checkable property.static classProperty.Property4<T1,T2,T3,T4>Represents a 4-ary checkable property.static classProperty.Property5<T1,T2,T3,T4,T5>Represents a 5-ary checkable property.static classProperty.Property6<T1,T2,T3,T4,T5,T6>Represents a 6-ary checkable property.static classProperty.Property7<T1,T2,T3,T4,T5,T6,T7>Represents a 7-ary checkable property.static classProperty.Property8<T1,T2,T3,T4,T5,T6,T7,T8>Represents a 8-ary checkable property.
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Stringname
-
Constructor Summary
Constructors Modifier Constructor Description privateProperty(java.lang.String name)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static Property.CheckErrorarbitraryError(int position, int size, java.lang.Throwable cause)Creates a CheckError caused by an exception when obtaining a generator.static Propertydef(java.lang.String name)Defines a new Property.<T1> Property.ForAll1<T1>forAll(Arbitrary<T1> a1)Returns a logical for all quantor of 1 given variables.<T1,T2>
Property.ForAll2<T1,T2>forAll(Arbitrary<T1> a1, Arbitrary<T2> a2)Returns a logical for all quantor of 2 given variables.<T1,T2,T3>
Property.ForAll3<T1,T2,T3>forAll(Arbitrary<T1> a1, Arbitrary<T2> a2, Arbitrary<T3> a3)Returns a logical for all quantor of 3 given variables.<T1,T2,T3,T4>
Property.ForAll4<T1,T2,T3,T4>forAll(Arbitrary<T1> a1, Arbitrary<T2> a2, Arbitrary<T3> a3, Arbitrary<T4> a4)Returns a logical for all quantor of 4 given variables.<T1,T2,T3,T4,T5>
Property.ForAll5<T1,T2,T3,T4,T5>forAll(Arbitrary<T1> a1, Arbitrary<T2> a2, Arbitrary<T3> a3, Arbitrary<T4> a4, Arbitrary<T5> a5)Returns a logical for all quantor of 5 given variables.<T1,T2,T3,T4,T5,T6>
Property.ForAll6<T1,T2,T3,T4,T5,T6>forAll(Arbitrary<T1> a1, Arbitrary<T2> a2, Arbitrary<T3> a3, Arbitrary<T4> a4, Arbitrary<T5> a5, Arbitrary<T6> a6)Returns a logical for all quantor of 6 given variables.<T1,T2,T3,T4,T5,T6,T7>
Property.ForAll7<T1,T2,T3,T4,T5,T6,T7>forAll(Arbitrary<T1> a1, Arbitrary<T2> a2, Arbitrary<T3> a3, Arbitrary<T4> a4, Arbitrary<T5> a5, Arbitrary<T6> a6, Arbitrary<T7> a7)Returns a logical for all quantor of 7 given variables.<T1,T2,T3,T4,T5,T6,T7,T8>
Property.ForAll8<T1,T2,T3,T4,T5,T6,T7,T8>forAll(Arbitrary<T1> a1, Arbitrary<T2> a2, Arbitrary<T3> a3, Arbitrary<T4> a4, Arbitrary<T5> a5, Arbitrary<T6> a6, Arbitrary<T7> a7, Arbitrary<T8> a8)Returns a logical for all quantor of 8 given variables.private static Property.CheckErrorgenError(int position, int size, java.lang.Throwable cause)Creates a CheckError caused by an exception when generating a value.private static voidlog(java.lang.String msg)private static voidlogErroneous(java.lang.String name, int currentTry, long millis, java.lang.String errorMessage)private static voidlogFalsified(java.lang.String name, int currentTry, long millis)private static voidlogSatisfied(java.lang.String name, int tries, long millis, boolean exhausted)private static Property.CheckErrorpredicateError(java.lang.Throwable cause)Creates a CheckError caused by an exception when testing a Predicate.
-
-
-
Method Detail
-
def
public static Property def(java.lang.String name)
Defines a new Property.- Parameters:
name- property name- Returns:
- a new
Property - Throws:
java.lang.NullPointerException- if name is null.java.lang.IllegalArgumentException- if name is empty or consists of whitespace only
-
logSatisfied
private static void logSatisfied(java.lang.String name, int tries, long millis, boolean exhausted)
-
logFalsified
private static void logFalsified(java.lang.String name, int currentTry, long millis)
-
logErroneous
private static void logErroneous(java.lang.String name, int currentTry, long millis, java.lang.String errorMessage)
-
log
private static void log(java.lang.String msg)
-
arbitraryError
private static Property.CheckError arbitraryError(int position, int size, java.lang.Throwable cause)
Creates a CheckError caused by an exception when obtaining a generator.- Parameters:
position- The position of the argument within the argument list of the property, starting with 1.size- The size hint passed to the Arbitrary which caused the error.cause- The error which occurred when the Arbitrary tried to obtain the generator Gen.- Returns:
- a new CheckError instance.
-
genError
private static Property.CheckError genError(int position, int size, java.lang.Throwable cause)
Creates a CheckError caused by an exception when generating a value.- Parameters:
position- The position of the argument within the argument list of the property, starting with 1.size- The size hint of the arbitrary which called the generator Gen which caused the error.cause- The error which occurred when the Gen tried to generate a random value.- Returns:
- a new CheckError instance.
-
predicateError
private static Property.CheckError predicateError(java.lang.Throwable cause)
Creates a CheckError caused by an exception when testing a Predicate.- Parameters:
cause- The error which occurred when applying the Predicate.- Returns:
- a new CheckError instance.
-
forAll
public <T1> Property.ForAll1<T1> forAll(Arbitrary<T1> a1)
Returns a logical for all quantor of 1 given variables.- Type Parameters:
T1- 1st variable type of this for all quantor- Parameters:
a1- 1st variable of this for all quantor- Returns:
- a new
ForAll1instance of 1 variables
-
forAll
public <T1,T2> Property.ForAll2<T1,T2> forAll(Arbitrary<T1> a1, Arbitrary<T2> a2)
Returns a logical for all quantor of 2 given variables.- Type Parameters:
T1- 1st variable type of this for all quantorT2- 2nd variable type of this for all quantor- Parameters:
a1- 1st variable of this for all quantora2- 2nd variable of this for all quantor- Returns:
- a new
ForAll2instance of 2 variables
-
forAll
public <T1,T2,T3> Property.ForAll3<T1,T2,T3> forAll(Arbitrary<T1> a1, Arbitrary<T2> a2, Arbitrary<T3> a3)
Returns a logical for all quantor of 3 given variables.- Type Parameters:
T1- 1st variable type of this for all quantorT2- 2nd variable type of this for all quantorT3- 3rd variable type of this for all quantor- Parameters:
a1- 1st variable of this for all quantora2- 2nd variable of this for all quantora3- 3rd variable of this for all quantor- Returns:
- a new
ForAll3instance of 3 variables
-
forAll
public <T1,T2,T3,T4> Property.ForAll4<T1,T2,T3,T4> forAll(Arbitrary<T1> a1, Arbitrary<T2> a2, Arbitrary<T3> a3, Arbitrary<T4> a4)
Returns a logical for all quantor of 4 given variables.- Type Parameters:
T1- 1st variable type of this for all quantorT2- 2nd variable type of this for all quantorT3- 3rd variable type of this for all quantorT4- 4th variable type of this for all quantor- Parameters:
a1- 1st variable of this for all quantora2- 2nd variable of this for all quantora3- 3rd variable of this for all quantora4- 4th variable of this for all quantor- Returns:
- a new
ForAll4instance of 4 variables
-
forAll
public <T1,T2,T3,T4,T5> Property.ForAll5<T1,T2,T3,T4,T5> forAll(Arbitrary<T1> a1, Arbitrary<T2> a2, Arbitrary<T3> a3, Arbitrary<T4> a4, Arbitrary<T5> a5)
Returns a logical for all quantor of 5 given variables.- Type Parameters:
T1- 1st variable type of this for all quantorT2- 2nd variable type of this for all quantorT3- 3rd variable type of this for all quantorT4- 4th variable type of this for all quantorT5- 5th variable type of this for all quantor- Parameters:
a1- 1st variable of this for all quantora2- 2nd variable of this for all quantora3- 3rd variable of this for all quantora4- 4th variable of this for all quantora5- 5th variable of this for all quantor- Returns:
- a new
ForAll5instance of 5 variables
-
forAll
public <T1,T2,T3,T4,T5,T6> Property.ForAll6<T1,T2,T3,T4,T5,T6> forAll(Arbitrary<T1> a1, Arbitrary<T2> a2, Arbitrary<T3> a3, Arbitrary<T4> a4, Arbitrary<T5> a5, Arbitrary<T6> a6)
Returns a logical for all quantor of 6 given variables.- Type Parameters:
T1- 1st variable type of this for all quantorT2- 2nd variable type of this for all quantorT3- 3rd variable type of this for all quantorT4- 4th variable type of this for all quantorT5- 5th variable type of this for all quantorT6- 6th variable type of this for all quantor- Parameters:
a1- 1st variable of this for all quantora2- 2nd variable of this for all quantora3- 3rd variable of this for all quantora4- 4th variable of this for all quantora5- 5th variable of this for all quantora6- 6th variable of this for all quantor- Returns:
- a new
ForAll6instance of 6 variables
-
forAll
public <T1,T2,T3,T4,T5,T6,T7> Property.ForAll7<T1,T2,T3,T4,T5,T6,T7> forAll(Arbitrary<T1> a1, Arbitrary<T2> a2, Arbitrary<T3> a3, Arbitrary<T4> a4, Arbitrary<T5> a5, Arbitrary<T6> a6, Arbitrary<T7> a7)
Returns a logical for all quantor of 7 given variables.- Type Parameters:
T1- 1st variable type of this for all quantorT2- 2nd variable type of this for all quantorT3- 3rd variable type of this for all quantorT4- 4th variable type of this for all quantorT5- 5th variable type of this for all quantorT6- 6th variable type of this for all quantorT7- 7th variable type of this for all quantor- Parameters:
a1- 1st variable of this for all quantora2- 2nd variable of this for all quantora3- 3rd variable of this for all quantora4- 4th variable of this for all quantora5- 5th variable of this for all quantora6- 6th variable of this for all quantora7- 7th variable of this for all quantor- Returns:
- a new
ForAll7instance of 7 variables
-
forAll
public <T1,T2,T3,T4,T5,T6,T7,T8> Property.ForAll8<T1,T2,T3,T4,T5,T6,T7,T8> forAll(Arbitrary<T1> a1, Arbitrary<T2> a2, Arbitrary<T3> a3, Arbitrary<T4> a4, Arbitrary<T5> a5, Arbitrary<T6> a6, Arbitrary<T7> a7, Arbitrary<T8> a8)
Returns a logical for all quantor of 8 given variables.- Type Parameters:
T1- 1st variable type of this for all quantorT2- 2nd variable type of this for all quantorT3- 3rd variable type of this for all quantorT4- 4th variable type of this for all quantorT5- 5th variable type of this for all quantorT6- 6th variable type of this for all quantorT7- 7th variable type of this for all quantorT8- 8th variable type of this for all quantor- Parameters:
a1- 1st variable of this for all quantora2- 2nd variable of this for all quantora3- 3rd variable of this for all quantora4- 4th variable of this for all quantora5- 5th variable of this for all quantora6- 6th variable of this for all quantora7- 7th variable of this for all quantora8- 8th variable of this for all quantor- Returns:
- a new
ForAll8instance of 8 variables
-
-