factor/library/test/test.factor

137 lines
3.0 KiB
Factor
Raw Normal View History

2004-07-16 02:26:21 -04:00
! Factor test suite.
IN: test
2005-02-14 21:58:07 -05:00
USING: errors kernel lists math memory namespaces parser
2005-04-02 02:39:33 -05:00
prettyprint sequences stdio strings unparser vectors words ;
2004-07-16 02:26:21 -04:00
: assert ( t -- )
[ "Assertion failed!" throw ] unless ;
2004-08-04 03:12:55 -04:00
: print-test ( input output -- )
2004-08-26 22:21:17 -04:00
"TESTING: " write 2list . flush ;
2004-07-16 02:26:21 -04:00
2004-08-10 23:48:08 -04:00
: keep-datastack ( quot -- )
datastack >r call r> set-datastack drop ;
: time ( code -- )
#! Evaluates the given code and prints the time taken to
#! execute it.
2004-11-22 19:15:14 -05:00
millis >r gc-time >r call gc-time r> - millis r> -
unparse write " milliseconds run time" print
unparse write " milliseconds GC time" print ;
2004-08-04 03:12:55 -04:00
: unit-test ( output input -- )
2004-08-10 23:48:08 -04:00
[
[
2dup print-test
2005-04-02 02:39:33 -05:00
swap >r >r clear r> call datastack >list r>
= assert
] keep-datastack 2drop
] time ;
2004-07-16 02:26:21 -04:00
: unit-test-fails ( quot -- )
#! Assert that the quotation throws an error.
[ [ not ] catch ] cons [ f ] swap unit-test ;
2004-07-16 02:26:21 -04:00
: test ( name -- )
! Run the given test.
depth 1 - >r
"Testing " write dup write "..." print
2004-08-10 23:48:08 -04:00
"/library/test/" swap ".factor" cat3 run-resource
"Checking before/after depth..." print
depth r> = assert ;
2004-07-16 02:26:21 -04:00
: all-tests ( -- )
"Running Factor test suite..." print
vocabularies get [ "temporary" off ] bind
2004-07-16 02:26:21 -04:00
[
"lists/cons"
"lists/lists"
"lists/assoc"
"lists/namespaces"
2004-11-17 20:59:28 -05:00
"lists/combinators"
2004-07-16 02:26:21 -04:00
"combinators"
"continuations"
2004-08-10 23:48:08 -04:00
"errors"
2004-07-16 02:26:21 -04:00
"hashtables"
2004-08-04 03:12:55 -04:00
"strings"
2004-11-16 23:09:34 -05:00
"namespaces"
"generic"
2005-01-31 14:02:09 -05:00
"tuple"
"files"
"parser"
"parse-number"
2004-08-04 03:12:55 -04:00
"prettyprint"
"image"
2004-10-03 16:39:32 -04:00
"init"
"io/io"
"listener"
"vectors"
2004-08-19 19:36:28 -04:00
"words"
"unparser"
"random"
2004-10-03 16:39:32 -04:00
"stream"
2004-08-25 20:51:19 -04:00
"math/bignum"
2004-08-17 23:42:10 -04:00
"math/bitops"
2004-08-25 20:51:19 -04:00
"math/gcd"
"math/math-combinators"
"math/rational"
"math/float"
"math/complex"
"math/irrational"
"httpd/url-encoding"
"httpd/html"
"httpd/httpd"
2004-11-17 20:59:28 -05:00
"crashes"
"sbuf"
"threads"
"parsing-word"
"inference"
"dataflow"
2004-11-17 20:59:28 -05:00
"interpreter"
2004-12-23 01:14:07 -05:00
"alien"
2005-01-03 02:55:54 -05:00
"line-editor"
2005-01-31 22:32:06 -05:00
"gadgets"
2005-02-14 22:15:02 -05:00
"memory"
2005-03-26 20:40:29 -05:00
"redefine"
"annotate"
2004-11-16 23:09:34 -05:00
] [
test
] each
2005-02-12 02:23:38 -05:00
os "win32" = [
[
"buffer"
] [ test ] each
] when
cpu "unknown" = [
[
"io/buffer"
2004-12-05 21:17:09 -05:00
"compiler/optimizer"
2004-12-17 19:27:42 -05:00
"compiler/simplifier"
2004-12-05 21:17:09 -05:00
"compiler/simple"
"compiler/stack"
"compiler/ifte"
"compiler/generic"
"compiler/bail-out"
"compiler/linearizer"
] [
test
] each
] unless
2004-11-17 20:59:28 -05:00
[
"benchmark/empty-loop"
"benchmark/fac"
"benchmark/fib"
"benchmark/sort"
"benchmark/continuations"
"benchmark/ack"
"benchmark/hashtables"
"benchmark/strings"
"benchmark/vectors"
] [
test
] each ;