Module Test.EasyCheck.Exec

EasyCheck is a library for automated, property-based testing of Curry programs. The ideas behind EasyCheck are described in this paper. This module implements the operations to actually execute the tests.

Author: Sebastian Fischer (with extensions by Michael Hanus)

Version: January 2024

Summary of exported operations:

setMaxTest :: Int -> Config -> Config  Deterministic 
Sets the maximum number of tests in a test configuration.
setMaxFail :: Int -> Config -> Config  Deterministic 
Sets the maximum number of condition failures in a test configuration.
easyConfig :: Config  Deterministic 
The default configuration for EasyCheck shows and deletes the number for each test.
verboseConfig :: Config  Deterministic 
A verbose configuration which shows the arguments of every test.
quietConfig :: Config  Deterministic 
A quiet configuration which shows nothing but failed tests.
check0 :: Config -> String -> Prop -> IO Bool  Deterministic 
Checks a unit test with a given configuration (first argument) and a name for the test (second argument).
checkWithValues0 :: Config -> String -> Prop -> IO Bool  Deterministic 
Checks a unit test with a given configuration (first argument) and a name for the test (second argument).
checkWithValues1 :: Show a => Config -> String -> [a] -> (a -> Prop) -> IO Bool  Deterministic 
Checks a property parameterized over a single argument with a given configuration (first argument), a name for the test (second argument), and all values given in the third argument.
checkWithValues2 :: (Show a, Show b) => Config -> String -> [a] -> [b] -> (a -> b -> Prop) -> IO Bool  Deterministic 
Checks a property parameterized over two arguments with a given configuration (first argument) a name for the test (second argument), and all values given in the third and fourth argument.
checkWithValues3 :: (Show a, Show b, Show c) => Config -> String -> [a] -> [b] -> [c] -> (a -> b -> c -> Prop) -> IO Bool  Deterministic 
Checks a property parameterized over three arguments with a given configuration (first argument) a name for the test (second argument), and all values given in the third, fourth and fifth argument.
checkWithValues4 :: (Show a, Show b, Show c, Show d) => Config -> String -> [a] -> [b] -> [c] -> [d] -> (a -> b -> c -> d -> Prop) -> IO Bool  Deterministic 
Checks a property parameterized over four arguments with a given configuration (first argument) a name for the test (second argument), and all values given in the further arguments.
checkWithValues5 :: (Show a, Show b, Show c, Show d, Show e) => Config -> String -> [a] -> [b] -> [c] -> [d] -> [e] -> (a -> b -> c -> d -> e -> Prop) -> IO Bool  Deterministic 
Checks a property parameterized over five arguments with a given configuration (first argument) a name for the test (second argument), and all values given in the further arguments.
check1 :: (Data a, Show a) => Config -> String -> (a -> Prop) -> IO Bool  Non-deterministic 
Checks a property parameterized over a single argument with a given configuration (first argument) and a name for the test (second argument).
check2 :: (Data a, Show a, Data b, Show b) => Config -> String -> (a -> b -> Prop) -> IO Bool  Non-deterministic 
Checks a property parameterized over two arguments with a given configuration (first argument) and a name for the test (second argument).
check3 :: (Data a, Show a, Data b, Show b, Data c, Show c) => Config -> String -> (a -> b -> c -> Prop) -> IO Bool  Non-deterministic 
Checks a property parameterized over three arguments with a given configuration (first argument) and a name for the test (second argument).
check4 :: (Data a, Show a, Data b, Show b, Data c, Show c, Data d, Show d) => Config -> String -> (a -> b -> c -> d -> Prop) -> IO Bool  Non-deterministic 
Checks a property parameterized over four arguments with a given configuration (first argument) and a name for the test (second argument).
check5 :: (Data a, Show a, Data b, Show b, Data c, Show c, Data d, Show d, Data e, Show e) => Config -> String -> (a -> b -> c -> d -> e -> Prop) -> IO Bool  Non-deterministic 
Checks a property parameterized over five arguments with a given configuration (first argument) and a name for the test (second argument).
easyCheck0 :: String -> Prop -> IO Bool  Deterministic 
Checks a unit test according to the default configuration and a name for the test (first argument).
easyCheck1 :: (Data a, Show a) => String -> (a -> Prop) -> IO Bool  Non-deterministic 
Checks a property parameterized over a single argument according to the default configuration and a name for the test (first argument).
easyCheck2 :: (Data a, Show a, Data b, Show b) => String -> (a -> b -> Prop) -> IO Bool  Non-deterministic 
Checks a property parameterized over two arguments according to the default configuration and a name for the test (first argument).
easyCheck3 :: (Data a, Show a, Data b, Show b, Data c, Show c) => String -> (a -> b -> c -> Prop) -> IO Bool  Non-deterministic 
Checks a property parameterized over three arguments according to the default configuration and a name for the test (first argument).
easyCheck4 :: (Data a, Show a, Data b, Show b, Data c, Show c, Data d, Show d) => String -> (a -> b -> c -> d -> Prop) -> IO Bool  Non-deterministic 
Checks a property parameterized over four arguments according to the default configuration and a name for the test (first argument).
easyCheck5 :: (Data a, Show a, Data b, Show b, Data c, Show c, Data d, Show d, Data e, Show e) => String -> (a -> b -> c -> d -> e -> Prop) -> IO Bool  Non-deterministic 
Checks a property parameterized over five arguments according to the default configuration and a name for the test (first argument).
verboseCheck0 :: String -> Prop -> IO Bool  Deterministic 
Checks a unit test according to the verbose configuration and a name for the test (first argument).
verboseCheck1 :: (Data a, Show a) => String -> (a -> Prop) -> IO Bool  Non-deterministic 
Checks a property parameterized over a single argument according to the verbose configuration and a name for the test (first argument).
verboseCheck2 :: (Data a, Show a, Data b, Show b) => String -> (a -> b -> Prop) -> IO Bool  Non-deterministic 
Checks a property parameterized over two arguments according to the verbose configuration and a name for the test (first argument).
verboseCheck3 :: (Data a, Show a, Data b, Show b, Data c, Show c) => String -> (a -> b -> c -> Prop) -> IO Bool  Non-deterministic 
Checks a property parameterized over three arguments according to the verbose configuration and a name for the test (first argument).
verboseCheck4 :: (Data a, Show a, Data b, Show b, Data c, Show c, Data d, Show d) => String -> (a -> b -> c -> d -> Prop) -> IO Bool  Non-deterministic 
Checks a property parameterized over four arguments according to the verbose configuration and a name for the test (first argument).
verboseCheck5 :: (Data a, Show a, Data b, Show b, Data c, Show c, Data d, Show d, Data e, Show e) => String -> (a -> b -> c -> d -> e -> Prop) -> IO Bool  Non-deterministic 
Checks a property parameterized over five arguments according to the verbose configuration and a name for the test (first argument).
checkPropWithMsg :: String -> IO Bool -> IO (Maybe String)  Deterministic 
Safely checks a property, i.e., catch all exceptions that might occur and return appropriate error message in case of a failed test.
checkPropIOWithMsg :: Config -> String -> PropIO -> IO (Maybe String)  Deterministic 
Safely checks an IO property, i.e., catch all exceptions that might occur and return appropriate error message in case of a failed test.

Exported datatypes:


Config

The configuration of property testing. The configuration contains

  • the maximum number of tests,
  • the maximum number of condition failures before giving up,
  • an operation that shows the number and arguments of each test,
  • a status whether it should work quietly.

Constructors:

  • Config :: Int -> Int -> (Int -> [String] -> String) -> Bool -> Config

    Fields:

    • maxTest :: Int
    • maxFail :: Int
    • every :: (Int -> [String] -> String)
    • isQuiet :: Bool

Exported operations:

setMaxTest :: Int -> Config -> Config  Deterministic 

Sets the maximum number of tests in a test configuration.

Further infos:
  • solution complete, i.e., able to compute all solutions

setMaxFail :: Int -> Config -> Config  Deterministic 

Sets the maximum number of condition failures in a test configuration.

Further infos:
  • solution complete, i.e., able to compute all solutions

easyConfig :: Config  Deterministic 

The default configuration for EasyCheck shows and deletes the number for each test.

verboseConfig :: Config  Deterministic 

A verbose configuration which shows the arguments of every test.

quietConfig :: Config  Deterministic 

A quiet configuration which shows nothing but failed tests.

Properties:

forAllValues n (valuesOf unknown) (suc)

check0 :: Config -> String -> Prop -> IO Bool  Deterministic 

Checks a unit test with a given configuration (first argument) and a name for the test (second argument). Returns a flag whether the test was successful.

Properties:

forAllValues id xs p (forValues)

checkWithValues0 :: Config -> String -> Prop -> IO Bool  Deterministic 

Checks a unit test with a given configuration (first argument) and a name for the test (second argument). Returns a flag whether the test was successful.

checkWithValues1 :: Show a => Config -> String -> [a] -> (a -> Prop) -> IO Bool  Deterministic 

Checks a property parameterized over a single argument with a given configuration (first argument), a name for the test (second argument), and all values given in the third argument. Returns a flag whether the test was successful.

checkWithValues2 :: (Show a, Show b) => Config -> String -> [a] -> [b] -> (a -> b -> Prop) -> IO Bool  Deterministic 

Checks a property parameterized over two arguments with a given configuration (first argument) a name for the test (second argument), and all values given in the third and fourth argument. Returns a flag whether the test was successful.

checkWithValues3 :: (Show a, Show b, Show c) => Config -> String -> [a] -> [b] -> [c] -> (a -> b -> c -> Prop) -> IO Bool  Deterministic 

Checks a property parameterized over three arguments with a given configuration (first argument) a name for the test (second argument), and all values given in the third, fourth and fifth argument. Returns a flag whether the test was successful.

checkWithValues4 :: (Show a, Show b, Show c, Show d) => Config -> String -> [a] -> [b] -> [c] -> [d] -> (a -> b -> c -> d -> Prop) -> IO Bool  Deterministic 

Checks a property parameterized over four arguments with a given configuration (first argument) a name for the test (second argument), and all values given in the further arguments. Returns a flag whether the test was successful.

checkWithValues5 :: (Show a, Show b, Show c, Show d, Show e) => Config -> String -> [a] -> [b] -> [c] -> [d] -> [e] -> (a -> b -> c -> d -> e -> Prop) -> IO Bool  Deterministic 

Checks a property parameterized over five arguments with a given configuration (first argument) a name for the test (second argument), and all values given in the further arguments. Returns a flag whether the test was successful.

check1 :: (Data a, Show a) => Config -> String -> (a -> Prop) -> IO Bool  Non-deterministic 

Checks a property parameterized over a single argument with a given configuration (first argument) and a name for the test (second argument). Returns a flag whether the test was successful.

check2 :: (Data a, Show a, Data b, Show b) => Config -> String -> (a -> b -> Prop) -> IO Bool  Non-deterministic 

Checks a property parameterized over two arguments with a given configuration (first argument) and a name for the test (second argument). Returns a flag whether the test was successful.

check3 :: (Data a, Show a, Data b, Show b, Data c, Show c) => Config -> String -> (a -> b -> c -> Prop) -> IO Bool  Non-deterministic 

Checks a property parameterized over three arguments with a given configuration (first argument) and a name for the test (second argument). Returns a flag whether the test was successful.

check4 :: (Data a, Show a, Data b, Show b, Data c, Show c, Data d, Show d) => Config -> String -> (a -> b -> c -> d -> Prop) -> IO Bool  Non-deterministic 

Checks a property parameterized over four arguments with a given configuration (first argument) and a name for the test (second argument). Returns a flag whether the test was successful.

check5 :: (Data a, Show a, Data b, Show b, Data c, Show c, Data d, Show d, Data e, Show e) => Config -> String -> (a -> b -> c -> d -> e -> Prop) -> IO Bool  Non-deterministic 

Checks a property parameterized over five arguments with a given configuration (first argument) and a name for the test (second argument). Returns a flag whether the test was successful.

easyCheck0 :: String -> Prop -> IO Bool  Deterministic 

Checks a unit test according to the default configuration and a name for the test (first argument). Returns a flag whether the test was successful.

easyCheck1 :: (Data a, Show a) => String -> (a -> Prop) -> IO Bool  Non-deterministic 

Checks a property parameterized over a single argument according to the default configuration and a name for the test (first argument). Returns a flag whether the test was successful.

easyCheck2 :: (Data a, Show a, Data b, Show b) => String -> (a -> b -> Prop) -> IO Bool  Non-deterministic 

Checks a property parameterized over two arguments according to the default configuration and a name for the test (first argument). Returns a flag whether the test was successful.

easyCheck3 :: (Data a, Show a, Data b, Show b, Data c, Show c) => String -> (a -> b -> c -> Prop) -> IO Bool  Non-deterministic 

Checks a property parameterized over three arguments according to the default configuration and a name for the test (first argument). Returns a flag whether the test was successful.

easyCheck4 :: (Data a, Show a, Data b, Show b, Data c, Show c, Data d, Show d) => String -> (a -> b -> c -> d -> Prop) -> IO Bool  Non-deterministic 

Checks a property parameterized over four arguments according to the default configuration and a name for the test (first argument). Returns a flag whether the test was successful.

easyCheck5 :: (Data a, Show a, Data b, Show b, Data c, Show c, Data d, Show d, Data e, Show e) => String -> (a -> b -> c -> d -> e -> Prop) -> IO Bool  Non-deterministic 

Checks a property parameterized over five arguments according to the default configuration and a name for the test (first argument). Returns a flag whether the test was successful.

verboseCheck0 :: String -> Prop -> IO Bool  Deterministic 

Checks a unit test according to the verbose configuration and a name for the test (first argument). Returns a flag whether the test was successful.

verboseCheck1 :: (Data a, Show a) => String -> (a -> Prop) -> IO Bool  Non-deterministic 

Checks a property parameterized over a single argument according to the verbose configuration and a name for the test (first argument). Returns a flag whether the test was successful.

verboseCheck2 :: (Data a, Show a, Data b, Show b) => String -> (a -> b -> Prop) -> IO Bool  Non-deterministic 

Checks a property parameterized over two arguments according to the verbose configuration and a name for the test (first argument). Returns a flag whether the test was successful.

verboseCheck3 :: (Data a, Show a, Data b, Show b, Data c, Show c) => String -> (a -> b -> c -> Prop) -> IO Bool  Non-deterministic 

Checks a property parameterized over three arguments according to the verbose configuration and a name for the test (first argument). Returns a flag whether the test was successful.

verboseCheck4 :: (Data a, Show a, Data b, Show b, Data c, Show c, Data d, Show d) => String -> (a -> b -> c -> d -> Prop) -> IO Bool  Non-deterministic 

Checks a property parameterized over four arguments according to the verbose configuration and a name for the test (first argument). Returns a flag whether the test was successful.

verboseCheck5 :: (Data a, Show a, Data b, Show b, Data c, Show c, Data d, Show d, Data e, Show e) => String -> (a -> b -> c -> d -> e -> Prop) -> IO Bool  Non-deterministic 

Checks a property parameterized over five arguments according to the verbose configuration and a name for the test (first argument). Returns a flag whether the test was successful.

checkPropWithMsg :: String -> IO Bool -> IO (Maybe String)  Deterministic 

Safely checks a property, i.e., catch all exceptions that might occur and return appropriate error message in case of a failed test.

checkPropIOWithMsg :: Config -> String -> PropIO -> IO (Maybe String)  Deterministic 

Safely checks an IO property, i.e., catch all exceptions that might occur and return appropriate error message in case of a failed test. This operation is used by the currycheck tool.