diff --git a/collects/schemeunit/planet-docs/schemeunit/Acknowlegements.html b/collects/schemeunit/planet-docs/schemeunit/Acknowlegements.html deleted file mode 100644 index 8e1edaa565..0000000000 --- a/collects/schemeunit/planet-docs/schemeunit/Acknowlegements.html +++ /dev/null @@ -1,11 +0,0 @@ - -5 Acknowlegements
Version: 4.1.5.3

5 Acknowlegements

The following people have contributed to SchemeUnit:

\ No newline at end of file diff --git a/collects/schemeunit/planet-docs/schemeunit/Release_Notes.html b/collects/schemeunit/planet-docs/schemeunit/Release_Notes.html deleted file mode 100644 index 87762f1ddf..0000000000 --- a/collects/schemeunit/planet-docs/schemeunit/Release_Notes.html +++ /dev/null @@ -1,19 +0,0 @@ - -4 Release Notes
On this page:
4.1 Version 3.4
4.2 Version 3
Version: 4.1.5.3

4 Release Notes

4.1 Version 3.4

This version allows arbitrary expressions within test -suites, fixing the semantics issue below.

There are also miscellaneous Scribble fixes.

4.2 Version 3

This version of SchemeUnit is largely backwards compatible -with version 2 but there are significant changes to the -underlying model, justifying incrementing the major version -number. These changes are best explained in -The Philosophy of SchemeUnit.

There are a few omissions in this release, that will -hopefully be corrected in later minor version releases:

\ No newline at end of file diff --git a/collects/schemeunit/planet-docs/schemeunit/api.html b/collects/schemeunit/planet-docs/schemeunit/api.html deleted file mode 100644 index 6b011f5fd1..0000000000 --- a/collects/schemeunit/planet-docs/schemeunit/api.html +++ /dev/null @@ -1,226 +0,0 @@ - -3 SchemeUnit API
On this page:
3.1 Overview of Scheme Unit
3.2 Checks
check
check-eq?
check-not-eq?
check-eqv?
check-equal?
check-not-equal?
check-pred
check-=
check-true
check-false
check-not-false
check-exn
check-not-exn
fail
check-regexp-match
3.2.1 Augmenting Information on Check Failure
check-info
make-check-name
make-check-params
make-check-location
make-check-expression
make-check-message
make-check-actual
make-check-expected
with-check-info*
with-check-info
3.2.2 Custom Checks
define-simple-check
define-binary-check
define-check
fail-check
3.2.3 The Check Evaluation Context
current-check-handler
current-check-around
3.3 Compound Testing Forms
3.3.1 Test Cases
test-begin
test-case
test-case?
3.3.2 Test Suites
test-suite
test-suite?
3.3.2.1 Utilities for Defining Test Suites
define-test-suite
define/ provide-test-suite
test-suite*
3.3.3 Compound Testing Evaluation Context
current-test-name
current-test-case-around
test-suite-test-case-around
test-suite-check-around
3.4 Test Control Flow
before
after
around
delay-test
3.5 Miscellaneous Utilities
require/ expose
3.6 User Interfaces
3.6.1 Textual User Interface
run-tests
3.6.2 Graphical User Interface
3.7 Programmatically Running Tests and Inspecting Results
3.7.1 Result Types
exn: test
exn: test: check
test-result
test-failure
test-error
test-success
3.7.2 Functions to Run Tests
run-test-case
run-test
fold-test-results
foldts
Version: 4.1.5.3

3 SchemeUnit API

 (require schemeunit)

3.1 Overview of SchemeUnit

There are three basic data types in SchemeUnit:

3.2 Checks

Checks are the basic building block of SchemeUnit. A check -checks some condition. If the condition holds the check -evaluates to #t. If the condition doesn’t hold the -check raises an instance of exn:test:check with -information detailing the failure.

Although checks are implemented as macros, which is -necessary to grab source location, they are conceptually -functions. This means, for instance, checks always evaluate -their arguments. You can use check as first class -functions, though you will lose precision in the reported -source locations if you do so.

The following are the basic checks SchemeUnit provides. You -can create your own checks using define-check.

(check op v1 v2 [message])  #t
  op : (-> any any (or/c #t #f))
  v1 : any
  v2 : any
  message : string? = ""

The simplest check. Succeeds if op applied to -v1 and v2 is not #f, otherwise -raises an exception of type exn:test:check. The -optional message is included in the output if the -check fails.

For example, the following check succeeds:

  (check < 2 3)

(check-eq? v1 v2 [message])  #t
  v1 : any
  v2 : any
  message : string? = ""
(check-not-eq? v1 v2 [message])  #t
  v1 : any
  v2 : any
  message : string? = ""
(check-eqv? v1 v2 [message])  #t
  v1 : any
  v2 : any
  message : string? = ""
(check-equal? v1 v2 [message])  #t
  v1 : any
  v2 : any
  message : string? = ""
(check-not-equal? v1 v2 [message])  #t
  v1 : any
  v2 : any
  message : string? = ""

Checks that v1 is (not) eq?, -eqv?, or equal? to v2. The -optional message is included in the output if the -check fails.

For example, the following checks all fail:

  (check-eq? (list 1) (list 1) "allocated data not eq?")
  (check-not-eq? 1 1 "integers are eq?")
  (check-eqv? 1 1.0 "not eqv?")
  (check-equal? 1 1.0 "not equal?")
  (check-not-equal? (list 1) (list 1) "equal?")

(check-pred pred v [message])  #t
  pred : (-> any (or/c #t #f))
  v : any
  message : string? = ""

Checks that pred returns #t when applied to v. The optional message is included in the output if the check fails.

Here’s an example that passes and an example that fails:

  (check-pred string? "I work")
  (check-pred number? "I fail")

(check-= v1 v2 epsilon [message])  #t
  v1 : any
  v2 : any
  epsilon : number?
  message : string? = ""

Checks that v1 and v2 are within -epsilon of one another. The optional -message is included in the output if the check -fails.

Here’s an example that passes and an example that fails:

  (check-= 1.0 1.01 0.01 "I work")
  (check-= 1.0 1.01 0.005 "I fail")

(check-true v [message])  #t
  v : any
  message : string? = ""
(check-false v [message])  #t
  v : any
  message : string? = ""
(check-not-false v [message])  #t
  v : any
  message : string? = ""

Checks that v is #t, #f, or not -#f as appropriate. The optional message -is included in the output if the check fails.

For example, the following checks all fail:

  (check-true 1)
  (check-false 1)
  (check-not-false #f)

(check-exn exn-predicate thunk [message])  #t
  exn-predicate : (-> any (or/c #t #f))
  thunk : (-> any)
  message : string? = ""

Checks that thunk raises an exception for which -exn-predicate returns #t. The optional -message is included in the output if the check -fails. A common error is to use an expression instead of a -function of no arguments for thunk. Remember that -checks are conceptually functions.

Here are two example, one showing a test that succeeds, and one showing a common error:

  (check-exn exn?
             (lambda ()
               (raise (make-exn "Hi there"
                                (current-continuation-marks)))))
  ; Forgot to wrap the expression in a thunk. Don't do this!
  (check-exn exn?
             (raise (make-exn "Hi there"
                              (current-continuation-marks))))

(check-not-exn thunk [message])  #t
  thunk : (-> any)
  message : string? = ""

Checks that thunk does not raise any exceptions. -The optional message is included in the output if -the check fails.

(fail [message])  #t
  message : string? = ""

This checks fails unconditionally. Good for creating test stubs that youintend to fill out later. The optional message is included in the output if the check fails.

(check-regexp-match regexp string)  #t
  regexp : regexp?
  string : string?

Checks that regexp matches the string.

The following check will succeed:

  (check-regexp-match "a+bba" "aaaaaabba")

This check will fail:

  (check-regexp-match "a+bba" "aaaabbba")

3.2.1 Augmenting Information on Check Failure

When an check fails it stores information including the name -of the check, the location and message (if available), the -expression the check is called with, and the parameters to -the check. Additional information can be stored by using -the with-check-info* function, and the -with-check-info macro.

(struct check-info (name value))
  name : symbol?
  value : any

A check-info structure stores information associated -with the context of execution of an check.

The are several predefined functions that create check -information structures with predefined names. This avoids -misspelling errors:

(make-check-name name)  check-info?
  name : string?
(make-check-params params)  check-info?
  params : (listof any)
(make-check-location loc)  check-info?
  loc : (list any (or/c number? #f) (or/c number? #f) (or/c number? #f) (or/c number? #f))
(make-check-expression msg)  check-info?
  msg : any
(make-check-message msg)  check-info?
  msg : string?
(make-check-actual param)  check-info?
  param : any
(make-check-expected param)  check-info?
  param : any

(with-check-info* info thunk)  any
  info : (listof check-info?)
  thunk : (-> any)

Stores the given info on the check-info stack for -the duration (the dynamic extent) of the execution of -thunk

Example:

  (with-check-info*
   (list (make-check-info 'time (current-seconds)))
   (lambda () (check = 1 2)))

When this check fails the message

time: <current-seconds-at-time-of-running-check>

will be printed along with the usual information on an -check failure.

(with-check-info ((name val) ...) body ...)

The with-check-info macro stores the given -information in the check information stack for the duration -of the execution of the body expressions. Name is -a quoted symbol and val is any value.

Example:

  (for-each
   (lambda (elt)
     (with-check-info
      (('current-element elt))
      (check-pred odd? elt)))
   (list 1 3 5 7 8))

When this test fails the message

current-element: 8

will be displayed along with the usual information on an -check failure.

3.2.2 Custom Checks

Custom checks can be defined using define-check and -its variants. To effectively use these macros it is useful -to understand a few details about a check’s evaluation -model.

Firstly, a check should be considered a function, even -though most uses are actually macros. In particular, checks -always evaluate their arguments exactly once before -executing any expressions in the body of the checks. Hence -if you wish to write checks that evalute user defined code -that code must be wrapped in a thunk (a function of no -arguments) by the user. The predefined check-exn -is an example of this type of check.

It is also useful to understand how the check information -stack operates. The stack is stored in a parameter and the -with-check-info forms evaluate to calls to -parameterize. Hence check information has lexical -scope. For this reason simple checks (see below) cannot -usefully contain calls to with-check-info to report -additional information. All checks created using -define-simple-check or define-check grab -some information by default: the name of the checks and the -values of the parameters. Additionally the macro forms of -checks grab location information and the expressions passed -as parameters.

(define-simple-check (name param ...) expr ...)

The define-simple-check macro constructs a check -called name that takes the params and an optional -message as arguments and evaluates the exprs. The -check fails if the result of the exprs is -#f. Otherwise the check succeeds. Note that -simple checks cannot report extra information using -with-check-info.

Example:

To define a check check-odd?

  (define-simple-check (check-odd? number)
    (odd? number))

We can use these checks in the usual way:

  (check-odd? 3)  ; Success
  (check-odd? 2)  ; Failure

(define-binary-check (name pred actual expected))
(define-binary-check (name actual expected) expr ...)

The define-binary-check macro constructs a check -that tests a binary predicate. It’s benefit over -define-simple-check is in better reporting on check -failure. The first form of the macro accepts a binary -predicate and tests if the predicate holds for the given -values. The second form tests if expr non-false.

Examples:

Here’s the first form, where we use a predefined predicate -to construct a binary check:

  (define-binary-check (check-char=? char=? actual expected))

In use:

  (check-char=? (read-char a-port) #\a)

If the expression is more complicated the second form should -be used. For example, below we define a binary check that -tests a number if within 0.01 of the expected value:

  (define-binary-check (check-in-tolerance actual expected)
    (< (abs (- actual expected)) 0.01))

(define-check (name param ...) expr ...)

The define-check macro acts in exactly the same way -as define-simple-check, except the check only fails -if the macro fail-check is called in the body of -the check. This allows more flexible checks, and in -particular more flexible reporting options.

(fail-check)

The fail-check macro raises an exn:test:check with -the contents of the check information stack.

3.2.3 The Check Evaluation Context

The semantics of checks are determined by the parameters -current-check-around and -current-check-handler. Other testing form such as -test-begin and test-suite change the value -of these parameters.

(current-check-handler)  (-> any/c any/c)
(current-check-handler handler)  void?
  handler : (-> any/c any/c)

Parameter containing the function that handles exceptions -raised by check failures. The default behaviour is to print -an error message including the exception message and stack -trace.

(current-check-around)  (-> thunk any/c)
(current-check-around check)  void?
  check : (-> thunk any/c)

Parameter containing the function that handles the execution -of checks. The default value wraps the evaluation of -thunk in a with-handlers call that calls -current-check-handler if an exception is raised.

3.3 Compound Testing Forms

3.3.1 Test Cases

As programs increase in complexity the unit of testing -grows beyond a single check. For example, it may be the case -that if one check fails it doesn’t make sense to run -another. To solve this problem compound testing forms can -be used to group expressions. If any expression in a group -fails (by raising an exception) the remaining expressions -will not be evaluated.

(test-begin expr ...)

A test-begin form groups the exprs into a -single unit. If any expr fails the following ones -are not evaluated.

For example, in the following code the world is not -destroyed as the preceding check fails:

  (test-begin
    (check-eq? 'a 'b)
    ; This line won't be run
    (destroy-the-world))

(test-case name expr ...)

Like a test-begin except a name is associated with -the group of exprs. The name will be reported if -the test fails.

Here’s the above example rewritten to use test-case -so the test can be named.

  (test-case
    "Example test"
    (check-eq? 'a 'b)
    ; This line won't be run
    (destroy-the-world))

(test-case? obj)  boolean?
  obj : any

True if obj is a test case, and false otherwise

3.3.2 Test Suites

Test cases can themselves be grouped into test suites. A -test suite can contain both test cases and test suites. -Unlike a check or test case, a test suite is not immediately -run. Instead use one of the functions described in -User Interfaces or Programmatically Running Tests and Inspecting Results.

(test-suite name [#:before before-thunk] [#:after after-thunk] test ...)

Constructs a test suite with the given name and tests. The -tests may be test cases, constructed using -test-begin or test-case, or other test -suites.

The before-thunk and after-thunk are -optional thunks (functions are 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 -run. Instead use one of the functions described in -User Interfaces or Programmatically Running Tests and Inspecting Results.

For example, here is a test suite that displays Before -before any tests are run, and After when the tests have -finished.

  (test-suite
    "An example suite"
    #:before (lambda () (display "Before"))
    #:after  (lambda () (display "After"))
    (test-case
      "An example test"
      (check-eq? 1 1)))

(test-suite? obj)  boolean?
  obj : any

True if -obj is a test suite, and false otherwise

3.3.2.1 Utilities for Defining Test Suites

There are some macros that simplify the common cases of -defining test suites:

(define-test-suite name test ...)

The -define-test-suite form creates a test suite with -the given name (converted to a string) and tests, and binds -it to the same name.

For example, this code creates a binding for the name -example-suite as well as creating a test suite with -the name "example-suite":

  (define-test-suite example-suite
    (check = 1 1))

(define/provide-test-suite name test ...)

This -for is just like define-test-suite, and in addition -it provides the test suite.

Finally, there is the test-suite* macro, which -defines a test suite and test cases using a shorthand -syntax:

(test-suite* name (test-case-name test-case-body
...) ...)

Defines a test suite with the given name, and -creates test cases within the suite, with the given names and -body expressions.

As far I know no-one uses this macro, so it might disappear -in future versions of SchemeUnit.

3.3.3 Compound Testing Evaluation Context

Just like with checks, there are several parameters that -control the semantics of compound testing forms.

(current-test-name)  (or/c string? false/c)
(current-test-name name)  void?
  name : (or/c string? false/c)

This parameter stores the name of the current test case. A -value of #f indicates a test case with no name, -such as one constructed by test-begin.

(current-test-case-around)  (-> (-> any/c) any/c)
(current-test-case-around handler)  void?
  handler : (-> (-> any/c) any/c)

This parameter handles evaluation of test cases. The value -of the parameter is a function that is passed a thunk (a -function of no arguments). The function, when applied, -evaluates the expressions within a test case. The default -value of the current-test-case-around parameters -evaluates the thunk in a context that catches exceptions and -prints an appropriate message indicating test case failure.

(test-suite-test-case-around thunk)  any/c
  thunk : (-> any/c)

The current-test-case-around parameter is -parameterized to this value within the scope of a -test-suite. This function creates a test case -structure instead of immediately evaluating the thunk.

(test-suite-check-around thunk)  any/c
  thunk : (-> any/c)

The current-check-around parameter is parameterized -to this value within the scope of a test-suite. -This function creates a test case structure instead of -immediately evaluating a check.

3.4 Test Control Flow

The before, after, and around -macros allow you to specify code that is always run before, -after, or around expressions in a test case.

(before before-expr expr1 expr2 ...)

Whenever control enters the scope execute the before-expr -before executing expr-1, and expr-2 ...

(after expr-1 expr-2 ... after-expr)

Whenever control exits the scope execute the after-expr -after executing expr-1, and expr-2 ... The after-expr is -executed even if control exits via an exception or other means.

(around before-expr expr-1 expr-2 ... after-expr)

Whenever control enters the scope execute the -before-expr before executing expr-1 expr-2 ..., and execute after-expr whenever control -leaves the scope.

Example:

The test below checks that the file test.dat contains -the string "foo". The before action writes to this -file. The after action deletes it.

  (around
    (with-output-to-file "test.dat"
       (lambda ()
         (write "foo")))
    (with-input-from-file "test.dat"
      (lambda ()
        (check-equal? "foo" (read))))
    (delete-file "test.dat"))

(delay-test test1 test2 ...)

This somewhat curious macro evaluates the given tests in a -context where current-test-case-around is -parameterized to test-suite-test-case-around. This -has been useful in testing SchemeUnit. It might be useful -for you if you create test cases that create test cases.

3.5 Miscellaneous Utilities

The require/expose macro allows you to access -bindings that a module does not provide. It is useful for -testing the private functions of modules.

(require/expose module (id ...))

Requires id from module into the current module. It doesn’t matter if the source module provides the bindings or not; require/expose can still get at them.

Note that require/expose can be a bit fragile, -especially when mixed with compiled code. Use at your own risk!

This example gets make-failure-test, which is defined in a SchemeUnit test:

  (require/expose schemeunit/check-test (make-failure-test))

3.6 User Interfaces

SchemeUnit provides a textual and a graphical user interface

3.6.1 Textual User Interface

 (require schemeunit/text-ui)

The textual UI is in the text-ui module. It is run -via the run-tests function

(run-tests test [verbosity])  natural-number/c
  test : (or/c test-case? test-suite?)
  verbosity : (symbols 'quite 'normal 'verbose) = 'normal

The given test is run and the result of running it -output to the current-output-port. The output is -compatable with the (X)Emacs next-error command (as used, -for example, by (X)Emac’s compile function)

The optional verbosity is one of 'quiet, -'normal, or 'verbose. Quiet output -displays only the number of successes, failures, and errors. -Normal reporting suppresses some extraneous check -information (such as the expression). Verbose reports all -information.

run-tests returns the number of unsuccessful tests.

3.6.2 Graphical User Interface

The GUI has not yet been updated to this version of SchemeUnit.

3.7 Programmatically Running Tests and Inspecting Results

SchemeUnit provides an API for running tests, from which -custom UIs can be created.

3.7.1 Result Types

(struct (exn:test exn) ())

The base structure for SchemeUnit exceptions. You should -never catch instances of this type, only the subtypes -documented below.

(struct (exn:test:check exn:test) (stack))
  stack : (listof check-info)

A exn:test:check is raised when an check fails, and -contains the contents of the check-info stack at the -time of failure.

(struct test-result (test-case-name))
  test-case-name : (or/c string #f)

A test-result is the result of running the test with -the given name (with #f indicating no name is available).

(struct (test-failure test-result) (result))
  result : any

Subtype of test-result representing a test failure.

(struct (test-error test-result) (result))
  result : exn

Subtype of test-result representing a test error.

(struct (test-success test-result) (result))
  result : any

Subtype of test-result representing a test success.

3.7.2 Functions to Run Tests

(run-test-case name action)  test-result
  name : (or/c string #f)
  action : (-> any)

Runs the given test case, returning a result representing success, failure, or error.

(run-test test)  (R = (listof (or/c test-result R)))
  test : (or/c test-case? test-suite?)

Runs the given test (test case or test suite) returning a -tree (list of lists) of results

Example:

  (run-test
     (test-suite
      "Dummy"
      (test-case "Dummy" (check-equal? 1 2))))

(fold-test-results result-fn    
  seed    
  test    
  #:run run    
  #:fdown fdown    
  #:fup fup)  'a
  result-fn : ('b 'c ... 'a . -> . 'a)
  seed : 'a
  test : (or/c test-case? test-suite?)
  run : (string (() -> any) . -> . 'b 'c ...)
  fdown : (string 'a . -> . 'a)
  fup : (string 'a . -> . 'a)

Fold result-fn pre-order left-to-right depth-first -over the results of run. By default run -is run-test-case and fdown and -fup just return the seed, so result-fn is -folded over the test results.

This function is useful for writing custom folds (and hence -UIs) over test results without you having to take care of -all the expected setup and teardown. For example, -fold-test-results will run test suite before and -after actions for you. However it is still flexible enough, -via its keyword arguments, to do almost anything that foldts -can. Hence it should be used in preference to foldts.

result-fn is a function from the results of -run (defaults to a test-result) and the -seed to a new seed

Seed is any value

Test is a test-case or test-suite

Run is a function from a test case name (string) and action -(thunk) to any values.

FDown is a function from a test suite name (string) and the -seed, to a new seed

FUp is a function from a test suite name (string) and the -seed, to a new seed.

Examples:

The following code counts the number of successes

  (define (count-successes test)
    (fold-test-results
     (lambda (result seed)
       (if (test-success? result)
           (add1 seed)
           seed))
     0
     test))

The following code returns the symbol 'burp instead -of running test cases. Note how the result-fn receives the -value of run.

  (define (burp test)
    (fold-test-results
     (lambda (result seed) (cons result seed))
     null
     test
     #:run (lambda (name action) 'burp)))

(foldts fdown fup fhere seed test)  'a
  fdown : (test-suite string thunk thunk 'a -> 'a)
  fup : (test-suite string thunk thunk 'a 'a -> 'a)
  fhere : (test-case string thunk 'a -> 'a)
  seed : 'a
  test : (or/c test-case? test-suite?)

Foldts is a nifty tree fold (created by Oleg Kiselyov) that -folds over a test in a useful way (fold-test-results isn’t -that useful as you can’t specify actions around test cases).

Fdown is a function of test suite, test suite name, before -action, after action, and the seed. It is run when a test -suite is encountered on the way down the tree (pre-order).

Fup is a function of test suite, test suite name, before -action, after action, the seed at the current level, and the -seed returned by the children. It is run on the way up the -tree (post-order).

Fhere is a function of the test case, test case name, the -test case action, and the seed. (Note that this might change -in the near future to just the test case. This change would -be to allow fhere to discriminate subtypes of test-case, -which in turn would allow test cases that are, for example, -ignored).

Example:

Here’s the implementation of fold-test-results in terms of -foldts:

  (define (fold-test-results suite-fn case-fn seed test)
    (foldts
     (lambda (suite name before after seed)
       (before)
       (suite-fn name seed))
     (lambda (suite name before after seed kid-seed)
       (after)
       kid-seed)
     (lambda (case name action seed)
       (case-fn
        (run-test-case name action)
        seed))
     seed
     test))

If you’re used to folds you’ll probably be a bit surprised -that the functions you pass to foldts receive both the -structure they operate on, and the contents of that -structure. This is indeed unusual. It is done to allow -subtypes of test-case and test-suite to be run in customised -ways. For example, you might define subtypes of test case -that are ignored (not run), or have their execution time -recorded, and so on. To do so the functions that run the -test cases need to know what type the test case has, and -hence is is necessary to provide this information.

If you’ve made it this far you truly are a master SchemeUnit -hacker. As a bonus prize we’ll just mention that the code -in hash-monad.ss and monad.ss might be of interest for -constructing user interfaces. The API is still in flux, so -isn’t documented here. However, do look at the -implementation of run-tests for examples of use.

\ No newline at end of file diff --git a/collects/schemeunit/planet-docs/schemeunit/doc-index.html b/collects/schemeunit/planet-docs/schemeunit/doc-index.html deleted file mode 100644 index 4101fe9def..0000000000 --- a/collects/schemeunit/planet-docs/schemeunit/doc-index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Index
Version: 4.1.5.3

Index

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

 

Acknowlegements
after
around
Augmenting Information on Check Failure
before
check
check-=
check-eq?
check-equal?
check-eqv?
check-exn
check-false
check-info
check-info-name
check-info-value
check-info?
check-not-eq?
check-not-equal?
check-not-exn
check-not-false
check-pred
check-regexp-match
check-true
Checks
Compound Testing Evaluation Context
Compound Testing Forms
current-check-around
current-check-handler
current-test-case-around
current-test-name
Custom Checks
define-binary-check
define-check
define-simple-check
define-test-suite
define/provide-test-suite
delay-test
exn:test
exn:test:check
exn:test:check-stack
exn:test:check?
exn:test?
fail
fail-check
fold-test-results
foldts
Functions to Run Tests
Graphical User Interface
Historical Context
make-check-actual
make-check-expected
make-check-expression
make-check-info
make-check-location
make-check-message
make-check-name
make-check-params
make-exn:test
make-exn:test:check
make-test-error
make-test-failure
make-test-result
make-test-success
Miscellaneous Utilities
Overview of SchemeUnit
Programmatically Running Tests and Inspecting Results
Quick Start Guide for SchemeUnit
Release Notes
require/expose
Result Types
run-test
run-test-case
run-tests
schemeunit
SchemeUnit API
schemeunit/text-ui
SchemeUnit: Unit Testing for Scheme
struct:check-info
struct:exn:test
struct:exn:test:check
struct:test-error
struct:test-failure
struct:test-result
struct:test-success
Test Cases
Test Control Flow
Test Suites
test-begin
test-case
test-case?
test-error
test-error-result
test-error?
test-failure
test-failure-result
test-failure?
test-result
test-result-test-case-name
test-result?
test-success
test-success-result
test-success?
test-suite
test-suite*
test-suite-check-around
test-suite-test-case-around
test-suite?
Textual User Interface
The Check Evaluation Context
The Philosophy of SchemeUnit
User Interfaces
Utilities for Defining Test Suites
Version 3
Version 3.4
with-check-info
with-check-info*

\ No newline at end of file diff --git a/collects/schemeunit/planet-docs/schemeunit/index.html b/collects/schemeunit/planet-docs/schemeunit/index.html deleted file mode 100644 index 14af253707..0000000000 --- a/collects/schemeunit/planet-docs/schemeunit/index.html +++ /dev/null @@ -1,5 +0,0 @@ - -SchemeUnit: Unit Testing for Scheme
Version: 4.1.5.3

SchemeUnit: Unit Testing for Scheme

by Noel Welsh (noelwelsh at GMail) -and Ryan Culpepper (ryan_sml at yahoo dot com)

SchemeUnit is a unit-testing framework for PLT Scheme. It -is designed to handle the needs of all Scheme programmers, -from novices to experts.

    1 Quick Start Guide for SchemeUnit

    2 The Philosophy of SchemeUnit

      2.1 Historical Context

    3 SchemeUnit API

      3.1 Overview of SchemeUnit

      3.2 Checks

        3.2.1 Augmenting Information on Check Failure

        3.2.2 Custom Checks

        3.2.3 The Check Evaluation Context

      3.3 Compound Testing Forms

        3.3.1 Test Cases

        3.3.2 Test Suites

          3.3.2.1 Utilities for Defining Test Suites

        3.3.3 Compound Testing Evaluation Context

      3.4 Test Control Flow

      3.5 Miscellaneous Utilities

      3.6 User Interfaces

        3.6.1 Textual User Interface

        3.6.2 Graphical User Interface

      3.7 Programmatically Running Tests and Inspecting Results

        3.7.1 Result Types

        3.7.2 Functions to Run Tests

    4 Release Notes

      4.1 Version 3.4

      4.2 Version 3

    5 Acknowlegements

    Index

\ No newline at end of file diff --git a/collects/schemeunit/planet-docs/schemeunit/philosophy.html b/collects/schemeunit/planet-docs/schemeunit/philosophy.html deleted file mode 100644 index 4f35783792..0000000000 --- a/collects/schemeunit/planet-docs/schemeunit/philosophy.html +++ /dev/null @@ -1,58 +0,0 @@ - -2 The Philosophy of SchemeUnit
On this page:
2.1 Historical Context
Version: 4.1.5.3

2 The Philosophy of SchemeUnit

SchemeUnit is designed to allow tests to evolve in step with -the evolution of the program under testing. SchemeUnit -scales from the unstructed checks suitable for simple -programs to the complex structure necessary for large -projects.

Simple programs, such as those in How to Design Programs, -are generally purely functional with no setup required to -obtain a context in which the function may operate. -Therefore the tests for these programs are extremely simple: -the test expressions are single checks, usually for -equality, and there are no dependencies between expressions. -For example, a HtDP student may be writing simple list -functions such as length, and the properties they are -checking are of the form:

  (equal? (length null) 0)
  (equal? (length '(a)) 1)
  (equal? (length '(a b)) 2)

SchemeUnit directly supports this style of testing. A check -on its own is a valid test. So the above examples may be -written in SchemeUnit as:

  (check-equal? (length null) 0)
  (check-equal? (length '(a)) 1)
  (check-equal? (length '(a b)) 2)

Simple programs now get all the benefits of SchemeUnit with -very little overhead.

There are limitations to this style of testing that more -complex programs will expose. For example, there might be -dependencies between expressions, caused by state, so that -it does not make sense to evaluate some expressions if -earlier ones have failed. This type of program needs a way -to group expressions so that a failure in one group causes -evaluation of that group to stop and immediately proceed to -the next group. In SchemeUnit all that is required is to -wrap a test-begin expression around a group of -expressions:

  (test-begin
    (setup-some-state!)
    (check-equal? (foo! 1) 'expected-value-1)
    (check-equal? (foo! 2) 'expected-value-2))

Now if any expression within the test-begin -expression fails no further expressions in that group will -be evaluated.

Notice that all the previous tests written in the simple -style are still valid. Introducing grouping is a local -change only. This is a key feature of SchemeUnit’s support -for the evolution of the program.

The programmer may wish to name a group of tests. This is -done using the test-case expression, a simple -variant on test-begin:

  (test-case
    "The name"
    ... test expressions ...)

Most programs will stick with this style. However, -programmers writing very complex programs may wish to -maintain separate groups of tests for different parts of the -program, or run their tests in different ways to the normal -SchemeUnit manner (for example, test results may be logged -for the purpose of improving software quality, or they may -be displayed on a website to indicate service quality). For -these programmers it is necessary to delay the execution of -tests so they can processed in the programmer’s chosen -manner. To do this, the programmer simply wraps a test-suite -around their tests:

  (test-suite
    "Suite name"
    (check ...)
    (test-begin ...)
    (test-case ...))

The tests now change from expressions that are immediately -evaluated to objects that may be programmatically -manipulated. Note again this is a local change. Tests -outside the suite continue to evaluate as before.

2.1 Historical Context

Most testing frameworks, including earlier versions of -SchemeUnit, support only the final form of testing. This is -likely due to the influence of the SUnit testing framework, -which is the ancestor of SchemeUnit and the most widely used -frameworks in Java, .Net, Python, and Ruby, and many other -languages. That this is insufficient for all users is -apparent if one considers the proliferation of "simpler" -testing frameworks in Scheme such as SRFI-78, or the the -practice of beginner programmers. Unfortunately these -simpler methods are inadequate for testing larger -systems. To the best of my knowledge SchemeUnit is the only -testing framework that makes a conscious effort to support -the testing style of all levels of programmer.

\ No newline at end of file diff --git a/collects/schemeunit/planet-docs/schemeunit/quick-start.html b/collects/schemeunit/planet-docs/schemeunit/quick-start.html deleted file mode 100644 index ae0991677b..0000000000 --- a/collects/schemeunit/planet-docs/schemeunit/quick-start.html +++ /dev/null @@ -1,34 +0,0 @@ - -1 Quick Start Guide for SchemeUnit
Version: 4.1.5.3

1 Quick Start Guide for SchemeUnit

Suppose we have code contained in file.scm, which -implements buggy versions of + and - -called my-+ and my--:

  #lang scheme/base
  
  (define (my-+ a b)
    (if (zero? a)
        b
        (my-+ (sub1 a) (add1 b))))
  
  (define (my-* a b)
    (if (zero? a)
        b
        (my-* (sub1 a) (my-+ b b))))
  
  (provide my-+
           my-*)

We want to test this code with SchemeUnit. We start by -creating a file called file-test.scm to contain our -tests. At the top of file-test.scm we import -SchemeUnit and file.scm:

  #lang scheme/base
  
  (require schemeunit
           "file.scm")

Now we add some tests to check our library:

  (check-equal? (my-+ 1 1) 2 "Simple addition")
  (check-equal? (my-* 1 2) 2 "Simple multiplication")

This is all it takes to define tests in SchemeUnit. Now -evaluate this file and see if the library is correct. -Here’s the result I get:

#t
--------------------
FAILURE
name:       check-equal?
location:   (file-test.scm 7 0 117 27)
expression: (check-equal? (my-* 1 2) 2)
params:     (4 2)
actual:     4
expected:   2
--------------------

The first #t indicates the first test passed. The -second test failed, as shown by the message.

Requiring SchemeUnit and writing checks is all you need to -get started testing, but let’s take a little bit more time -to look at some features beyond the essentials.

Let’s say we want to check that a number of properties hold. -How do we do this? So far we’ve only seen checks of a -single expression. In SchemeUnit a check is always a single -expression, but we can group checks into units called test -cases. Here’s a simple test case written using the -test-begin form:

  (test-begin
   (let ((lst (list 2 4 6 9)))
     (check = (length lst) 4)
     (for-each
      (lambda (elt)
        (check-pred even? elt))
      lst)))

Evalute this and you should see an error message like:

--------------------
A test
... has a FAILURE
name:       check-pred
location:   (#<path:/Users/noel/programming/schematics/schemeunit/branches/v3/doc/file-test.scm> 14 6 252 22)
expression: (check-pred even? elt)
params:     (#<procedure:even?> 9)
--------------------

This tells us that the expression (check-pred even? elt) failed. The arguments of this check were -even? and 9, and as 9 is not even the -check failed. A test case fails as soon as any check within -it fails, and no further checks are evaluated once this -takes place.

Naming our test cases if useful as it helps remind us what -we’re testing. We can give a test case a name with the -test-case form:

  (test-case
   "List has length 4 and all elements even"
   (let ((lst (list 2 4 6 9)))
     (check = (length lst) 4)
     (for-each
      (lambda (elt)
        (check-pred even? elt))
      lst)))

Now if we want to structure our tests are bit more we can -group them into a test suite:

  (define file-tests
    (test-suite
     "Tests for file.scm"
  
     (check-equal? (my-+ 1 1) 2 "Simple addition")
  
     (check-equal? (my-* 1 2) 2 "Simple multiplication")
  
     (test-case
      "List has length 4 and all elements even"
      (let ((lst (list 2 4 6 9)))
        (check = (length lst) 4)
        (for-each
          (lambda (elt)
            (check-pred even? elt))
        lst)))))

Evaluate the module now and you’ll see the tests no longer -run. This is because test suites delay execution of their -tests, allowing you to choose how you run your tests. You -might, for example, print the results to the screen or log -them to a file.

Let’s run our tests, using SchemeUnit’s simple textual user -interface (there are fancier interfaces available but this -will do for our example). In file-test.scm add the -following lines:

  (require schemeunit/text-ui)
  
  (run-tests file-tests)

Now evaluate the file and you should see similar output -again.

These are the basics of SchemeUnit. Refer to the -documentation below for more advanced topics, such as -defining your own checks. Have fun!

\ No newline at end of file diff --git a/collects/schemeunit/planet-docs/schemeunit/scribble-common.js b/collects/schemeunit/planet-docs/schemeunit/scribble-common.js deleted file mode 100644 index bfd8711f0a..0000000000 --- a/collects/schemeunit/planet-docs/schemeunit/scribble-common.js +++ /dev/null @@ -1,67 +0,0 @@ -// Common functionality for PLT documentation pages - -function GetCookie(key, def) { - if (document.cookie.length <= 0) return def; - var i, cookiestrs = document.cookie.split(/; */); - for (i = 0; i < cookiestrs.length; i++) { - var cur = cookiestrs[i]; - var eql = cur.indexOf('='); - if (eql >= 0 && cur.substring(0,eql) == key) - return unescape(cur.substring(eql+1)); - } - return def; -} - -function SetCookie(key, val) { - var d = new Date(); - d.setTime(d.getTime()+(365*24*60*60*1000)); - document.cookie = - key + "=" + escape(val) + "; expires="+ d.toGMTString() + "; path=/"; -} - -// note that this always stores a directory name, ending with a "/" -function SetPLTRoot(ver, relative) { - var root = location.protocol + "//" + location.host - + NormalizePath(location.pathname.replace(/[^\/]*$/, relative)); - SetCookie("PLT_Root."+ver, root); -} - -// adding index.html works because of the above -function GotoPLTRoot(ver, relative) { - var u = GetCookie("PLT_Root."+ver, null); - if (u == null) return true; // no cookie: use plain up link - // the relative path is optional, default goes to the toplevel start page - if (!relative) relative = "index.html"; - location = u + relative; - return false; -} - -normalize_rxs = [/\/\/+/g, /\/\.(\/|$)/, /\/[^\/]*\/\.\.(\/|$)/]; -function NormalizePath(path) { - var tmp, i; - for (i = 0; i < normalize_rxs.length; i++) - while ((tmp = path.replace(normalize_rxs[i], "/")) != path) path = tmp; - return path; -} - -function DoSearchKey(event, field, ver, top_path) { - var val = field.value; - if (event && event.keyCode == 13) { - var u = GetCookie("PLT_Root."+ver, null); - if (u == null) u = top_path; // default: go to the top path - location = u + "search/index.html" + "?q=" + escape(val); - return false; - } - return true; -} - -function TocviewToggle(glyph,id) { - var s = document.getElementById(id).style; - var expand = s.display == "none"; - s.display = expand ? "block" : "none"; - glyph.innerHTML = expand ? "▼" : "►"; -} - -// `noscript' is problematic in some browsers (always renders as a -// block), use this hack instead (does not always work!) -// document.write(""); diff --git a/collects/schemeunit/planet-docs/schemeunit/scribble.css b/collects/schemeunit/planet-docs/schemeunit/scribble.css deleted file mode 100644 index 832ef53ba5..0000000000 --- a/collects/schemeunit/planet-docs/schemeunit/scribble.css +++ /dev/null @@ -1,549 +0,0 @@ - -/* CSS seems backward: List all the classes for which we want a - particular font, so that the font can be changed in one place. (It - would be nicer to reference a font definition from all the places - that we want it.) - - As you read the rest of the file, remember to double-check here to - see if any font is set. */ - -/* Monospace: */ -.maincolumn, .refpara, .tocset, .stt, .hspace, -.schemeinput, .schemereader, .schemeparen, .schememeta, -.schememod, .schemekeyword, .schemevariable, .schemesymbol, -.schemeresult, .schemestdout, .schemecomment, .schemevalue { - font-family: monospace; -} - -/* Serif: */ -.main, .refcontent, .tocview, .tocsub, .inheritedlbl, i { - font-family: serif; -} - -/* Sans-serif: */ -.version { - font-family: sans-serif; -} - -/* ---------------------------------------- */ - -h2 { /* per-page main title */ - margin-top: 0; -} - -h3, h4, h5, h6, h7, h8 { - margin-top: 1.75em; - margin-bottom: 0.5em; -} - -/* Needed for browsers like Opera, and eventually for HTML 4 conformance. - This means that multiple paragraphs in a table element do not have a space - between them. */ -table p { - margin-top: 0; - margin-bottom: 0; -} - -/* ---------------------------------------- */ -/* Main */ - -body { - color: black; - background-color: #ffffff; -} - -table td { - padding-left: 0; - padding-right: 0; -} - -.maincolumn { - width: 43em; - margin-right: -40em; - margin-left: 15em; -} - -.main { - text-align: left; -} - -/* ---------------------------------------- */ -/* Navigation */ - -.navsettop, .navsetbottom { - background-color: #f0f0e0; - padding: 0.25em 0 0.25em 0; -} - -.navsettop { - margin-bottom: 1.5em; - border-bottom: 2px solid #e0e0c0; -} - -.navsetbottom { - margin-top: 2em; - border-top: 2px solid #e0e0c0; -} - -.navleft { - margin-left: 1ex; - position: relative; - float: left; - white-space: nowrap; -} -.navright { - margin-right: 1ex; - position: relative; - float: right; - white-space: nowrap; -} -.nonavigation { - color: #e0e0e0; -} - -.searchform { - display: inline; - margin: 0; - padding: 0; -} - -.searchbox { - width: 16em; - margin: 0px; - padding: 0px; - background-color: #eee; - border: 1px solid #ddd; - text-align: center; - vertical-align: middle; -} - -/* ---------------------------------------- */ -/* Version */ - -.versionbox { - position: relative; - float: right; - left: 2em; - height: 0em; - width: 13em; - margin: 0em -13em 0em 0em; -} -.version { - font-size: small; -} - -/* ---------------------------------------- */ -/* Margin notes */ - -.refpara { - position: relative; - float: right; - left: 2em; - top: -1em; - height: 0em; - width: 13em; - margin: 0em -13em 0em 0em; -} - -.refcolumn { - background-color: #F5F5DC; - display: block; - position: relative; - width: 13em; - font-size: 85%; - border: 0.5em solid #F5F5DC; -} - -.refcontent { -} - -/* ---------------------------------------- */ -/* Table of contents, inline */ - -.toclink { - text-decoration: none; - color: blue; - font-size: 85%; -} - -.toptoclink { - text-decoration: none; - color: blue; - font-weight: bold; -} - -/* ---------------------------------------- */ -/* Table of contents, left margin */ - -.tocset { - position: relative; - float: left; - width: 12.5em; - margin-right: 2em; -} -.tocset td { - vertical-align: text-top; -} - -.tocview { - text-align: left; - background-color: #f0f0e0; -} - -.tocsub { - text-align: left; - margin-top: 0.5em; - background-color: #f0f0e0; -} - -.tocviewlist, .tocsublist { - margin-left: 0.2em; - margin-right: 0.2em; - padding-top: 0.2em; - padding-bottom: 0.2em; -} -.tocviewlist table { - font-size: 82%; -} - -.tocviewsublist, .tocviewsublistonly, .tocviewsublisttop, .tocviewsublistbottom { - margin-left: 0.4em; - border-left: 1px solid #bbf; - padding-left: 0.8em; -} -.tocviewsublist { - margin-bottom: 1em; -} -.tocviewsublist table, -.tocviewsublistonly table, -.tocviewsublisttop table, -.tocviewsublistbottom table { - font-size: 75%; -} - -.tocviewtitle * { - font-weight: bold; -} - -.tocviewlink { - text-decoration: none; - color: blue; -} - -.tocviewselflink { - text-decoration: underline; - color: blue; -} - -.tocviewtoggle { - text-decoration: none; - color: blue; - font-size: 75%; /* looks better, and avoids bounce when toggling sub-sections due to font alignments */ -} - -.tocsublist td { - padding-left: 1em; - text-indent: -1em; -} - -.tocsublinknumber { - font-size: 82%; -} - -.tocsublink { - font-size: 82%; - text-decoration: none; -} - -.tocsubseclink { - font-size: 82%; - text-decoration: none; -} - -.tocsubnonseclink { - font-size: 82%; - text-decoration: none; - padding-left: 0.5em; -} - -.tocsubtitle { - font-size: 82%; - font-style: italic; - margin: 0.2em; -} - -.sepspace { - font-size: 40%; -} - -.septitle { - font-size: 70%; -} - -/* ---------------------------------------- */ -/* Inherited methods, left margin */ - -.inherited { - width: 100%; - margin-top: 0.5em; - text-align: left; - background-color: #ECF5F5; -} - -.inherited td { - font-size: 82%; - padding-left: 1em; - text-indent: -0.8em; - padding-right: 0.2em; -} - -.inheritedlbl { - font-style: italic; -} - -/* ---------------------------------------- */ -/* Scheme text styles */ - -.schemeinput { - color: #cc6633; - background-color: #eeeeee; -} - -.schemeinputbg { - background-color: #eeeeee; -} - -.schemereader { -} - -.schemeparen { - color: #843c24; -} - -.schememeta { - color: #262680; -} - -.schememod { - color: black; -} - -.schemeopt { - color: black; -} - -.schemekeyword { - color: black; - font-weight: bold; -} - -.schemeerror { - color: red; - font-style: italic; -} - -.schemevariable { - color: #262680; - font-style: italic; -} - -.schemesymbol { - color: #262680; -} - -.schemevaluelink { - text-decoration: none; - color: blue; -} - -.schememodlink { - text-decoration: none; - color: blue; -} - -.schemesyntaxlink { - text-decoration: none; - color: black; - font-weight: bold; -} - -.schemeresult { - color: #0000af; -} - -.schemestdout { - color: #960096; -} - -.schemecomment { - color: #c2741f; -} - -.schemevalue { - color: #228b22; -} - -/* ---------------------------------------- */ -/* Some inline styles */ - -.leftindent { - margin-left: 1em; - margin-right: 0em; -} - -.insetpara { - margin-left: 1em; - margin-right: 1em; -} - -.indexlink { - text-decoration: none; -} - -.nobreak { - white-space: nowrap; -} - -.stt { -} - -.title { - font-size: 200%; - font-weight: normal; - margin-top: 2.8em; - text-align: center; -} - -pre { margin-left: 2em; } -blockquote { margin-left: 2em; } - -ol { list-style-type: decimal; } -ol ol { list-style-type: lower-alpha; } -ol ol ol { list-style-type: lower-roman; } -ol ol ol ol { list-style-type: upper-alpha; } - -i { -} - -.boxed { - width: 100%; - background-color: #E8E8FF; -} - -.inlinetop{ - display: inline; - vertical-align: text-top; -} - -.together { - width: 100%; -} - -.prototype td { - vertical-align: text-top; -} -.longprototype td { - vertical-align: bottom; -} - -.schemeblock td { - vertical-align: baseline; -} - -.argcontract td { - vertical-align: text-top; -} - -.ghost { - color: white; -} - -.highlighted { - background-color: #ddddff; -} - -.defmodule { - width: 100%; - background-color: #F5F5DC; -} - -.specgrammar { - float: right; -} - -.hspace { -} - -.slant { - font-style: oblique; -} - -.inferencetop td { - border-bottom: 1px solid black; - text-align: center; -} -.inferencebottom td { - text-align: center; -} - -.badlink { - text-decoration: underline; - color: red; -} - -.plainlink { - text-decoration: none; - color: blue; -} - -.techoutside { text-decoration: underline; color: #b0b0b0; } -.techoutside:hover { text-decoration: underline; color: blue; } - -/* .techinside:hover doesn't work with FF, .techinside:hover> - .techinside doesn't work with IE, so use both (and IE doesn't - work with inherit in the second one, so use blue directly) */ -.techinside { color: black; } -.techinside:hover { color: blue; } -.techoutside:hover>.techinside { color: inherit; } - -.SBibliography td { - vertical-align: text-top; -} - -.imageleft { - float: left; - margin-right: 0.3em; -} - -.smaller{ - font-size: 82%; -} - -/* A hack, inserted to break some Scheme ids: */ -.mywbr { - width: 0; - font-size: 1px; -} - -.compact li p { - margin: 0em; - padding: 0em; -} - -.noborder img { - border: 0; -} - -.author { - position: relative; - float: right; - left: 2em; - top: -3em; - height: 0em; - width: 23em; /* very wide to keep author names on separate lines */ - margin: 0em -23em 0em 0em; - font-size: 82%; -} -.author:before { - content: "by "; -}