schemeunit:

added ryanc to plt:responsible
  test-suite list trampoline, make-test-suite

svn: r18268
This commit is contained in:
Ryan Culpepper 2010-02-22 20:48:31 +00:00
parent 8a11336b51
commit d4eee108f4
4 changed files with 40 additions and 14 deletions

View File

@ -83,15 +83,22 @@
(let ([the-name name] (let ([the-name name]
[the-tests [the-tests
(lambda (fdown fup fhere seed) (lambda (fdown fup fhere seed)
(define (run/inner x)
(cond [(schemeunit-test-suite? x)
(current-seed
(apply-test-suite x fdown fup fhere (current-seed)))]
[(list? x)
(for-each run/inner x)]
[else
(void)]))
(parameterize (parameterize
([current-seed seed] ([current-seed seed]
[current-test-case-around (test-suite-test-case-around fhere)] [current-test-case-around (test-suite-test-case-around fhere)]
[current-check-around (test-suite-check-around fhere)]) [current-check-around (test-suite-check-around fhere)])
(let ([t test]) (let ([t test])
(if (schemeunit-test-suite? t) (run/inner t))
(current-seed (apply-test-suite t fdown fup fhere (current-seed))) ...
t)) (current-seed)))])
... (current-seed)))])
(cond (cond
[(not (string? the-name)) [(not (string? the-name))
(raise-type-error 'test-suite "test-suite name as string" the-name)] (raise-type-error 'test-suite "test-suite name as string" the-name)]

View File

@ -61,15 +61,19 @@ Unlike a check or test case, a test suite is not immediately
run. Instead use one of the functions described in run. Instead use one of the functions described in
@secref["ui"] or @secref["running"]. @secref["ui"] or @secref["running"].
@defform[(test-suite name [#:before before-thunk] [#:after after-thunk] test ...)]{ @defform/subs[(test-suite name-expr maybe-before maybe-after test ...)
([maybe-before (code:line)
(code:line #:before before-thunk)]
[maybe-after (code:line)
(code:line #:after after-thunk)])
#:contracts ([name-expr string?])]{
Constructs a test suite with the given name and tests. The Constructs a test suite with the given name and tests. The
tests may be test cases, constructed using tests may be test cases, constructed using @scheme[test-begin] or
@scheme[test-begin] or @scheme[test-case], or other test @scheme[test-case], or other test suites.
suites.
The @scheme[before-thunk] and @scheme[after-thunk] are The @scheme[before-thunk] and @scheme[after-thunk] are
optional thunks (functions are no argument). They are run optional thunks (functions with no argument). They are run
before and after the tests are run, respectively. before and after the tests are run, respectively.
Unlike a check or test case, a test suite is not immediately Unlike a check or test case, a test suite is not immediately
@ -87,9 +91,23 @@ finished.
#:after (lambda () (display "After")) #:after (lambda () (display "After"))
(test-case (test-case
"An example test" "An example test"
(check-eq? 1 1))) (check-eq? 1 1))
(test-suite "A nested test suite"
(test-case "Another test"
(check-< 1 2))))
] ]
@defproc[(make-test-suite [name string?]
[tests (listof (or/c test-case? test-suite?))]
[#:before before-thunk (-> any) void]
[#:after after-thunk (-> any) void])
test-suite?]{
Constructs a test suite with the given @scheme[name] containing the
given @scheme[tests]. Unlike the @scheme[test-suite] form, the tests
are represented as a list of test values.
}
@defproc[(test-suite? (obj any)) boolean?]{ True if @defproc[(test-suite? (obj any)) boolean?]{ True if
@scheme[obj] is a test suite, and false otherwise} @scheme[obj] is a test suite, and false otherwise}
@ -118,6 +136,7 @@ the name @scheme["example-suite"]:
for is just like @scheme[define-test-suite], and in addition for is just like @scheme[define-test-suite], and in addition
it @scheme[provide]s the test suite.} it @scheme[provide]s the test suite.}
@;{
Finally, there is the @scheme[test-suite*] macro, which Finally, there is the @scheme[test-suite*] macro, which
defines a test suite and test cases using a shorthand defines a test suite and test cases using a shorthand
syntax: syntax:
@ -129,7 +148,7 @@ body expressions.
As far I know no-one uses this macro, so it might disappear As far I know no-one uses this macro, so it might disappear
in future versions of SchemeUnit.} in future versions of SchemeUnit.}
}
@section{Compound Testing Evaluation Context} @section{Compound Testing Evaluation Context}

View File

@ -17,5 +17,5 @@ especially when mixed with compiled code. Use at your own risk!
This example gets @scheme[make-failure-test], which is defined in a SchemeUnit test: This example gets @scheme[make-failure-test], which is defined in a SchemeUnit test:
@schemeblock[ @schemeblock[
(require/expose schemeunit/check-test (make-failure-test)) (require/expose schemeunit/private/check-test (make-failure-test))
] ]

View File

@ -13,13 +13,13 @@ The textual UI is in the @schememodname[schemeunit/text-ui] module.
It is run via the @scheme[run-tests] function. It is run via the @scheme[run-tests] function.
@defproc[(run-tests (test (or/c test-case? test-suite?)) @defproc[(run-tests (test (or/c test-case? test-suite?))
(verbosity (symbols 'quite 'normal 'verbose) 'normal)) (verbosity (symbols 'quiet 'normal 'verbose) 'normal))
natural-number/c]{ natural-number/c]{
The given @scheme[test] is run and the result of running it The given @scheme[test] is run and the result of running it
output to the @scheme[current-output-port]. The output is output to the @scheme[current-output-port]. The output is
compatable with the (X)Emacs next-error command (as used, compatable with the (X)Emacs next-error command (as used,
for example, by (X)Emac's compile function) for example, by (X)Emacs's compile function)
The optional @scheme[verbosity] is one of @scheme['quiet], The optional @scheme[verbosity] is one of @scheme['quiet],
@scheme['normal], or @scheme['verbose]. Quiet output @scheme['normal], or @scheme['verbose]. Quiet output