From d4eee108f43e65ad988cb3661245ee13ebf02b1b Mon Sep 17 00:00:00 2001 From: Ryan Culpepper Date: Mon, 22 Feb 2010 20:48:31 +0000 Subject: [PATCH] schemeunit: added ryanc to plt:responsible test-suite list trampoline, make-test-suite svn: r18268 --- collects/schemeunit/private/test-suite.ss | 15 ++++++--- .../scribblings/compound-testing.scrbl | 33 +++++++++++++++---- collects/schemeunit/scribblings/misc.scrbl | 2 +- collects/schemeunit/scribblings/ui.scrbl | 4 +-- 4 files changed, 40 insertions(+), 14 deletions(-) diff --git a/collects/schemeunit/private/test-suite.ss b/collects/schemeunit/private/test-suite.ss index 155049cc2c..aa586d749c 100644 --- a/collects/schemeunit/private/test-suite.ss +++ b/collects/schemeunit/private/test-suite.ss @@ -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)] diff --git a/collects/schemeunit/scribblings/compound-testing.scrbl b/collects/schemeunit/scribblings/compound-testing.scrbl index 870c3fe802..74011e4f68 100644 --- a/collects/schemeunit/scribblings/compound-testing.scrbl +++ b/collects/schemeunit/scribblings/compound-testing.scrbl @@ -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} diff --git a/collects/schemeunit/scribblings/misc.scrbl b/collects/schemeunit/scribblings/misc.scrbl index cf73dd9598..51af0161c8 100644 --- a/collects/schemeunit/scribblings/misc.scrbl +++ b/collects/schemeunit/scribblings/misc.scrbl @@ -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)) ] diff --git a/collects/schemeunit/scribblings/ui.scrbl b/collects/schemeunit/scribblings/ui.scrbl index b4d30e439c..3b80a25e91 100644 --- a/collects/schemeunit/scribblings/ui.scrbl +++ b/collects/schemeunit/scribblings/ui.scrbl @@ -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