Previous: , Up: How to Test   [Contents][Index]


9.2.2.3 Reference Section

Here is a list of the functions and macros exported by lisp-unit.

  1. Test definition forms
    (define-test name exp1 exp2 ...)
    
    (get-tests [package)
    
    (get-test-code name [package)
    
    (remove-tests names [package])
    
    (remove-all-tests [package])
    
    (run-all-tests package)
    
    (run-tests name1 name2 ...)
    
    (use-debugger [flag])
    
  2. Assertion forms

    All of the assertion forms are macros. They tally a failure if the associated predication returns false. Assertions can be made about return values, printed output, macro expansions, and even expected errors. Assertion form arguments are evaluated in the local lexical environment.

    All assertion forms allow you to include additional expressions at the end of the form. These expressions and their values will be printed only when the test fails.

    Return values are unspecified for all assertion forms.

    (assert-eq value form [form1 form2 ...])
    
    (assert-eql value form [form1 form2 ...])
    
    (assert-equal value form [form1 form2 ...])
    
    (assert-equalp value form [form1 form2 ...])
    
    (assert-equality predicate value form [form1 form2 ...])
    

    These macros tally a failure if value is not equal to the result returned by form, using the specified equality predicate.

    In general, assert-equal is used for most tests. But any binary predicate can be used, with assert-equality, e.g.,

    (assert-equality unordered-equal '(a b c) (unique-atoms '((b c) a ((b a) c))))
    
    (assert-true test [form1 form2 ...])
    (assert-false test [form1 form2 ...])
    

    assert-true tallies a failure if test returns false. assert-false tallies a failure if test returns ‘true’.

    (assert-prints "output" form [form1 form2 ...])
    
    (assert-expands expansion form [form1 form2 ...])
    
    (assert-error condition-type form [form1 form2 ...])
    
    (fail format-string [form1 form2 ...])
    
  3. Utility predicates

    Several predicate functions are exported that are often useful in writing tests with assert-equality.

    (logically-equal value1 value2)
    
    (set-equal list1 list2 [:test])
    
    (unordered-equal list1 list2 [:test])
    

Previous: How to Organize Tests with Packages, Up: How to Test   [Contents][Index]