factor/library/test/test.factor

75 lines
1.5 KiB
Factor
Raw Normal View History

2004-07-16 02:26:21 -04:00
! Factor test suite.
! Some of these words should be moved to the standard library.
IN: test
USE: arithmetic
USE: combinators
USE: compiler
USE: errors
USE: kernel
USE: lists
USE: namespaces
USE: parser
USE: prettyprint
2004-07-16 02:26:21 -04:00
USE: stack
USE: stdio
USE: strings
USE: words
USE: unparser
USE: vocabularies
: assert ( t -- )
[ "Assertion failed!" throw ] unless ;
2004-08-04 03:12:55 -04:00
: print-test ( input output -- )
"TESTING: " write 2list . ;
2004-07-16 02:26:21 -04:00
2004-08-04 03:12:55 -04:00
: unit-test ( output input -- )
2dup print-test
swap >r >r clear r> call datastack vector>list r> = assert ;
2004-07-16 02:26:21 -04:00
: test-word ( output input word -- )
2004-08-04 03:12:55 -04:00
#! Old-style test.
append unit-test ;
2004-07-16 02:26:21 -04:00
: do-not-test-word ( output input word -- )
#! Flag for tests that are known not to work.
3drop ;
: time ( code -- )
#! Evaluates the given code and prints the time taken to
#! execute it.
millis >r call millis r> - . ;
: test ( name -- )
! Run the given test.
"/library/test/" swap ".factor" cat3 run-resource ;
: all-tests ( -- )
"Running Factor test suite..." print
"vocabularies" get [ f "scratchpad" set ] bind
[
2004-08-04 03:12:55 -04:00
"lists/all"
2004-07-16 02:26:21 -04:00
"combinators"
"continuations"
"hashtables"
2004-08-04 03:12:55 -04:00
"strings"
"namespaces/all"
"format"
"parser"
2004-08-04 03:12:55 -04:00
"prettyprint"
"inspector"
"vectors"
"unparser"
"random"
2004-08-04 03:12:55 -04:00
!
2004-07-16 02:26:21 -04:00
"html"
"httpd"
"math"
"parse-number"
"jvm-compiler/all"
2004-07-16 02:26:21 -04:00
] [
test
2004-08-04 03:12:55 -04:00
] each ;