cl-quickcheck

API Reference

cl-quickcheck

Common Lisp port of the QuickCheck unit test framework

CL-QUICKCHECK

  • Macro QUICKCHECK (&body body)
    Run BODY and report the results of any tests.
  • Macro TEST (flag)
    Test that FLAG is true.
  • Macro IS (fn &rest operands)
    Test that FN applied to OPERANDS is true, with the failure message detailing the failing arguments.
  • Macro ISNT (fn &rest operands)
    Test that FN applied to OPERANDS is false.
  • Macro IS= (x y)
    Test that X is EQUAL to Y.
  • Macro ISNT= (x y)
    Test that X is not EQUAL to Y.
  • Macro SHOULD-SIGNAL (condition &body body)
    Test that evaluating BODY signals (a subtype of) CONDITION.
  • Macro NAMED (name &body tests)
    Perform the given TESTS with all the test names set to NAME.
  • Macro WRAP-EACH (wrapper &body wrappees)
    Perform each of the WRAPPEES as if surrounded by WRAPPER (with the literal symbol WRAPPEE inside WRAPPER being the hole where the wrappee appears). This is useful for factoring out common setup/teardown code for a sequence of tests without compromising their isolation.
  • Macro ONLY-IF (flag test)
    Perform the TEST only if FLAG is true, otherwise return a SKIPPED test result whose name is TEST quoted.
  • Macro FOR-ALL (bindings &body body)
    Perform the test in BODY for random values of BINDINGS.
  • Struct TEST
    NAME
    FLOPPED
    DETAIL
    BINDINGS
  • Function TEST-NAME (instance)
  • Function (setf TEST-NAME) (value instance)
  • Function TEST-FLOPPED (instance)
  • Function (setf TEST-FLOPPED) (value instance)
  • Function TEST-DETAIL (instance)
  • Function (setf TEST-DETAIL) (value instance)
  • Function TEST-BINDINGS (instance)
  • Function (setf TEST-BINDINGS) (value instance)
  • Variable *BREAK-ON-FAILURE*
    nil
    When true, test failures jump us immediately into the debugger.
  • Variable *TESTING*
    nil
    When true, we're in the dynamic extent of a quickcheck form.
  • Function COLLECT-TEST-RESULTS (fn)
    Call FN with *TESTING* true, and return a list of the test results.
  • Variable *NUM-TRIALS*
    100
    Number of random trials we want to see pass in FOR-ALL tests.
  • Function GENERATE (generator)
    Ask GENERATOR to produce a value.
  • Variable *SIZE*
    20
    Bounds the size of random test cases in a generator-dependent way.
  • Macro DEFINE (binding &body body)
    Like Scheme's top-level DEFINE, more or less.
  • Variable A-BOOLEAN
    (lambda () (= 0 (random 2)))
  • Variable AN-INDEX
    (lambda () (random cl-quickcheck:*size*))
  • Variable AN-INTEGER
    (lambda ()
      (- (random (+ cl-quickcheck:*size* cl-quickcheck:*size* 1))
         cl-quickcheck:*size*))
  • Variable A-REAL
    (lambda () (- (random (float (* 2 cl-quickcheck:*size*))) cl-quickcheck:*size*))
  • Function A-LIST (generator)
  • Function A-TUPLE (&rest generators)
  • Function A-MEMBER (&rest generators)
  • Function A-CHAR
  • Function A-STRING
  • Function A-SYMBOL
  • Variable K-GENERATOR
    cl-quickcheck:an-index
  • Variable M-GENERATOR
    cl-quickcheck:an-integer
  • Variable N-GENERATOR
    cl-quickcheck:an-integer
  • Macro PICK-WEIGHTED (&body choices)
    Given CHOICES with constant weights, pick a random one at runtime.
  • Variable *LOUD*
    t
    When true, we show progress as tests are run with dots to stdout.
  • Function REPORT (test-cases)
    Print out the interesting test results in longer form.