]> gitweb.factorcode.org Git - factor.git/blob - library/test/test.factor
working on the test suite
[factor.git] / library / test / test.factor
1 ! Factor test suite.
2
3 ! Some of these words should be moved to the standard library.
4
5 IN: test
6 USE: arithmetic
7 USE: combinators
8 USE: compiler
9 USE: errors
10 USE: kernel
11 USE: lists
12 USE: namespaces
13 USE: parser
14 USE: prettyprint
15 USE: stack
16 USE: stdio
17 USE: strings
18 USE: words
19 USE: unparser
20 USE: vocabularies
21
22 : assert ( t -- )
23     [ "Assertion failed!" throw ] unless ;
24
25 : print-test ( input output -- )
26     "TESTING: " write 2list . ;
27
28 : unit-test ( output input -- )
29     2dup print-test
30     swap >r >r clear r> call datastack vector>list r> = assert ;
31
32 : test-word ( output input word -- )
33     #! Old-style test.
34     append unit-test ;
35
36 : do-not-test-word ( output input word -- )
37     #! Flag for tests that are known not to work.
38     3drop ;
39
40 : time ( code -- )
41     #! Evaluates the given code and prints the time taken to
42     #! execute it.
43     millis >r call millis r> - . ;
44
45 : test ( name -- )
46     ! Run the given test.
47     "/library/test/" swap ".factor" cat3 run-resource ;
48
49 : all-tests ( -- )
50     "Running Factor test suite..." print
51     "vocabularies" get [ f "scratchpad" set ] bind
52     [
53         "lists/all"
54         "combinators"
55         "continuations"
56         "hashtables"
57         "strings"
58         "namespaces/all"
59         "format"
60         "prettyprint"
61         !
62         "html"
63         "auxiliary"
64         "compiler"
65         "compiler-types"
66         "dictionary"
67         "httpd"
68         "inference"
69         "math"
70         "miscellaneous"
71         "parse-number"
72         "primitives"
73         "random"
74         "reader"
75         "recompile"
76         "stack"
77         "tail"
78         "types"
79         "vectors"
80     ] [
81         test
82     ] each ;