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]
[the-tests
(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
([current-seed seed]
[current-test-case-around (test-suite-test-case-around fhere)]
[current-check-around (test-suite-check-around fhere)])
(let ([t test])
(if (schemeunit-test-suite? t)
(current-seed (apply-test-suite t fdown fup fhere (current-seed)))
t))
... (current-seed)))])
(run/inner t))
...
(current-seed)))])
(cond
[(not (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
@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
tests may be test cases, constructed using
@scheme[test-begin] or @scheme[test-case], or other test
suites.
tests may be test cases, constructed using @scheme[test-begin] or
@scheme[test-case], or other test suites.
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.
Unlike a check or test case, a test suite is not immediately
@ -87,9 +91,23 @@ finished.
#:after (lambda () (display "After"))
(test-case
"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
@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
it @scheme[provide]s the test suite.}
@;{
Finally, there is the @scheme[test-suite*] macro, which
defines a test suite and test cases using a shorthand
syntax:
@ -129,7 +148,7 @@ body expressions.
As far I know no-one uses this macro, so it might disappear
in future versions of SchemeUnit.}
}
@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:
@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.
@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]{
The given @scheme[test] is run and the result of running it
output to the @scheme[current-output-port]. The output is
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],
@scheme['normal], or @scheme['verbose]. Quiet output