A library for automated testing. Tests can be combined into test suites. Running a test suite performs all tests in it and gives a summary of the outcomes.
Example of a test suite for function naturals:
define naturals_suite =
test_suite("Function 'naturals'", [
test("should produce the empty list for 0", () ->
naturals(0) = []
),
test("should produce the first 5 naturals", () ->
naturals(5) = [0, 1, 2, 3, 4]
)
]);
is_suite_focused :: (TestSuite) -> Boole is_test_focused :: (Test) -> Boole random_test :: (String, () -> Maybe(Boole)) -> Test random_test_focus :: (String, () -> Maybe(Boole)) -> Test run_test :: (Test) -> Boole run_test_suites :: (List(TestSuite)) -> Void suite_description :: (TestSuite) -> String suite_tests :: (TestSuite) -> List(Test) test :: (String, () -> Boole) -> Test test_description :: (Test) -> String test_focus :: (String, () -> Boole) -> Test test_suite :: (String, List(Test)) -> TestSuite test_suite_focus :: (String, List(Test)) -> TestSuite
TestSuite
A test suite is a collection of tests. Use function test_suite
to create a test suite.
Test
A test is a tuple (description, check, focused).
The desciption explains the test in one line. The check is the actual test. The focused flag indicates whether this test is marked as 'focused'.
:: (TestSuite) -> Boole
Is the test suite marked as 'focused'
:: (Test) -> Boole
Is the test marked as 'focused'.
:: (String, () -> Maybe(Boole)) -> Test
Creates a random test.
The first argument is a description of the test case. The second argument is a Maybe with a condition that that test must satisfy.
The test evaluates the condition repeatedly until hunderd successes have been achieved, or until a faillure occurs. The test also fails after thousand attempts.
When the condition is the nothing Maybe then it doesn't count as test. This can be used as a pre-condition for the test.
:: (String, () -> Maybe(Boole)) -> Test
Creates a random test, just like function random_test, but marks
it as 'focused'.
When at least one test is marked as 'focused' then function run_test_suites
will only run the marked tests and skip all others.
:: (Test) -> Boole
Executes the test.
:: (List(TestSuite)) -> Void
Runs all tests from a list of test suites. Prints output to the terminal. Returns the result as triple (nr_tests, nr_failures, nr_skipped).
When at least one of the tests is marked as 'focused' then it will only run the marked tests and skip all others.
:: (TestSuite) -> String
Getter for record TestSuite
:: (TestSuite) -> List(Test)
Getter for record TestSuite
:: (String, () -> Boole) -> Test
Creates a test.
The first argument is a description of the test case. The second argument is a condition that that test must satisfy.
:: (Test) -> String
Getter for record Test
:: (String, () -> Boole) -> Test
Creates a test, just like function test, but marks it as 'focused'.
When at least one test is marked as 'focused' then function run_test_suites
will only run the marked tests and skip all others.
:: (String, List(Test)) -> TestSuite
Creates a test suite.
The first argument is a description of the test suite. The second argument is a list of tests to include in the suite.
Example of a test suite for function naturals:
define naturals_suite =
test_suite("Function 'naturals'", [
test("should produce the empty list for 0", () ->
naturals(0) = []
),
test("should produce the first 5 naturals", () ->
naturals(5) = [0, 1, 2, 3, 4]
)
]);
:: (String, List(Test)) -> TestSuite
Creates a test suite, just like function test_suite, but
marks it as 'focused'
Version v0.6.0, 2026-03-05T15:49:28.020089406+01:00[Europe/Amsterdam]