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
|
2004-07-21 19:26:41 -04:00
|
|
|
USE: prettyprint
|
2004-07-16 02:26:21 -04:00
|
|
|
USE: stack
|
|
|
|
USE: stdio
|
|
|
|
USE: strings
|
|
|
|
USE: words
|
|
|
|
USE: unparser
|
|
|
|
|
|
|
|
: 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-10 23:48:08 -04:00
|
|
|
: keep-datastack ( quot -- )
|
|
|
|
datastack >r call r> set-datastack drop ;
|
|
|
|
|
2004-08-04 03:12:55 -04:00
|
|
|
: unit-test ( output input -- )
|
2004-08-10 23:48:08 -04:00
|
|
|
[
|
|
|
|
2dup print-test
|
|
|
|
swap >r >r clear r> call datastack vector>list r>
|
|
|
|
= assert
|
|
|
|
] keep-datastack 2drop ;
|
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.
|
2004-08-10 23:48:08 -04:00
|
|
|
depth pred >r
|
2004-08-08 17:20:54 -04:00
|
|
|
"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 [ f "scratchpad" set ] bind
|
|
|
|
[
|
2004-08-10 21:32:10 -04:00
|
|
|
"crashes"
|
2004-08-08 17:20:54 -04:00
|
|
|
"lists/cons"
|
|
|
|
"lists/lists"
|
|
|
|
"lists/assoc"
|
|
|
|
"lists/destructive"
|
|
|
|
"lists/namespaces"
|
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-08-08 17:20:54 -04:00
|
|
|
"namespaces/namespaces"
|
2004-08-04 03:12:55 -04:00
|
|
|
"format"
|
2004-08-04 18:25:29 -04:00
|
|
|
"parser"
|
2004-08-06 18:40:44 -04:00
|
|
|
"parse-number"
|
2004-08-04 03:12:55 -04:00
|
|
|
"prettyprint"
|
2004-08-04 18:25:29 -04:00
|
|
|
"inspector"
|
|
|
|
"vectors"
|
|
|
|
"unparser"
|
|
|
|
"random"
|
2004-08-06 18:40:44 -04:00
|
|
|
"math/rational"
|
|
|
|
"math/float"
|
|
|
|
"math/complex"
|
|
|
|
"math/irrational"
|
2004-08-11 01:30:44 -04:00
|
|
|
"math/simpson"
|
2004-08-08 17:20:54 -04:00
|
|
|
"httpd/url-encoding"
|
|
|
|
"httpd/html"
|
|
|
|
"httpd/httpd"
|
2004-07-16 02:26:21 -04:00
|
|
|
] [
|
|
|
|
test
|
2004-08-08 17:20:54 -04:00
|
|
|
] each
|
|
|
|
|
|
|
|
java? [
|
|
|
|
[
|
|
|
|
"lists/java"
|
|
|
|
"namespaces/java"
|
|
|
|
"jvm-compiler/auxiliary"
|
|
|
|
"jvm-compiler/compiler"
|
|
|
|
"jvm-compiler/compiler-types"
|
|
|
|
"jvm-compiler/inference"
|
|
|
|
"jvm-compiler/primitives"
|
|
|
|
"jvm-compiler/tail"
|
|
|
|
"jvm-compiler/types"
|
|
|
|
"jvm-compiler/miscellaneous"
|
|
|
|
] [
|
|
|
|
test
|
|
|
|
] each
|
|
|
|
] when ;
|