Module Assertion

This module defines the datatype and operations for the Curry module tester "currytest".

Author: Michael Hanus

Version: May 2014

Summary of exported operations:

assertTrue :: String -> Bool -> Assertion ()   
(assertTrue s b) asserts (with name s) that b must be true.
assertEqual :: String -> a -> a -> Assertion a   
(assertEqual s e1 e2) asserts (with name s) that e1 and e2 must be equal (w.r.t.
assertValues :: String -> a -> [a] -> Assertion a   
(assertValues s e vs) asserts (with name s) that vs is the multiset of all values of e.
assertSolutions :: String -> (a -> Bool) -> [a] -> Assertion a   
(assertSolutions s c vs) asserts (with name s) that constraint abstraction c has the multiset of solutions vs.
assertIO :: String -> IO a -> a -> Assertion a   
(assertIO s a r) asserts (with name s) that I/O action a yields the result value r.
assertEqualIO :: String -> IO a -> IO a -> Assertion a   
(assertEqualIO s a1 a2) asserts (with name s) that I/O actions a1 and a2 yield equal (w.r.t.
seqStrActions :: IO (String,Bool) -> IO (String,Bool) -> IO (String,Bool)   
Combines two actions and combines their results.
checkAssertion :: (Eq a, Show a) => String -> ((String,Bool) -> IO (String,Bool)) -> Assertion a -> IO (String,Bool)   
Executes and checks an assertion, and process the result by an I/O action.
writeAssertResult :: (String,Bool) -> IO Int   
Prints the results of assertion checking.
showTestMod :: Int -> String -> IO ()   
Sends message to GUI for showing test of a module.
showTestCase :: Int -> (String,Bool) -> IO (String,Bool)   
Sends message to GUI for showing result of executing a test case.
showTestEnd :: Int -> IO ()   
Sends message to GUI for showing end of module test.
showTestCompileError :: Int -> IO ()   
Sends message to GUI for showing compilation errors in a module test.

Exported datatypes:


Assertion

Datatype for defining test cases.

Constructors:


ProtocolMsg

The messages sent to the test GUI. Used by the currytest tool.

Constructors:

  • TestModule :: String -> ProtocolMsg
  • TestCase :: String -> Bool -> ProtocolMsg
  • TestFinished :: ProtocolMsg
  • TestCompileError :: ProtocolMsg

Exported operations:

assertTrue :: String -> Bool -> Assertion ()   

(assertTrue s b) asserts (with name s) that b must be true.

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

assertEqual :: String -> a -> a -> Assertion a   

(assertEqual s e1 e2) asserts (with name s) that e1 and e2 must be equal (w.r.t. ==).

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

assertValues :: String -> a -> [a] -> Assertion a   

(assertValues s e vs) asserts (with name s) that vs is the multiset of all values of e. All values of e are compared with the elements in vs w.r.t. ==.

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

assertSolutions :: String -> (a -> Bool) -> [a] -> Assertion a   

(assertSolutions s c vs) asserts (with name s) that constraint abstraction c has the multiset of solutions vs. The solutions of c are compared with the elements in vs w.r.t. ==.

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

assertIO :: String -> IO a -> a -> Assertion a   

(assertIO s a r) asserts (with name s) that I/O action a yields the result value r.

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

assertEqualIO :: String -> IO a -> IO a -> Assertion a   

(assertEqualIO s a1 a2) asserts (with name s) that I/O actions a1 and a2 yield equal (w.r.t. ==) results.

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

seqStrActions :: IO (String,Bool) -> IO (String,Bool) -> IO (String,Bool)   

Combines two actions and combines their results. Used by the currytest tool.

Further infos:
  • defined as left-associative infix operator with precedence 1

checkAssertion :: (Eq a, Show a) => String -> ((String,Bool) -> IO (String,Bool)) -> Assertion a -> IO (String,Bool)   

Executes and checks an assertion, and process the result by an I/O action. Used by the currytest tool.

Example call:
(checkAssertion protocol assertion)
Parameters:
  • protocol : an action to be applied after test execution
  • assertion : an assertion to be tested
Returns:
a protocol string and a flag whether the test was successful

writeAssertResult :: (String,Bool) -> IO Int   

Prints the results of assertion checking. If failures occurred, the return code is positive. Used by the currytest tool.

showTestMod :: Int -> String -> IO ()   

Sends message to GUI for showing test of a module. Used by the currytest tool.

showTestCase :: Int -> (String,Bool) -> IO (String,Bool)   

Sends message to GUI for showing result of executing a test case. Used by the currytest tool.

showTestEnd :: Int -> IO ()   

Sends message to GUI for showing end of module test. Used by the currytest tool.

showTestCompileError :: Int -> IO ()   

Sends message to GUI for showing compilation errors in a module test. Used by the currytest tool.