summaryrefslogtreecommitdiff
path: root/doc/api/libtestr/index.txt
blob: 774f3648c544be1b1f7eed4123839aed7f2c59b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{
        title:  libtestr
        description:    Myrddin Test Library
}

Libtestr
---------

    pkg testr =
            type ctx
            
            type spec = struct
            	name	: byte[:]
            	fn	: (ctx : ctx# -> void)
            ;;
            
            const run	: (specs : spec[:] -> void)
            const ok	: (ctx : ctx# -> void)
            const fail	: (ctx : ctx#, msg : byte[:] -> void)
    ;;

Overview
--------

The testr library provides a simple library for running
unit tests. It outputs subtest results in a format that mbld
will be able to understand, log, and report on.

Types
-----

    type ctx

The context for the current test. Used to record the state
of the set of tests currently running.

    type spec = struct
            name	: byte[:]
            fn	: (ctx : ctx# -> void)
    ;;	

The specification for a single test. Contains the name
of the test being run, and the code used to execute it.

Mutex.

Functions: Mutexes
------------------
            
    const run	: (specs : spec[:] -> void)

Runs a sequence of tests, recording the state of the test
and outputting an appropriate log for mtest to consume.

    const ok	: (ctx : ctx# -> void)

Records a test success. It does not leave the current
scope.

    const fail	: (ctx : ctx#, msg : byte[:] -> void)

Records a test failure. It does not leave the current
scope.