anchor.diff: -;;; Copyright (c) 2011-2012, James M. Lawrence. All rights reserved.
  +;;; Copyright (c) 2014, James M. Lawrence. All rights reserved.
   ;;;
   ;;; Redistribution and use in source and binary forms, with or without
   ;;; modification, are permitted provided that the following conditions
  
positive.code:      (passed)))
  
  (defun check-signals (expected fn)
    (flet ((handler (condition)
             (cond ((typep condition expected)
                    (passed)
                    (return-from check-signals))
                   (t
                    (error "Expected to signal ~s, but got ~a."
                           expected (if condition
                                        (type-of condition)
                                        "nothing"))))))
      (handler-bind ((condition #'handler))
        (funcall fn))
      (handler nil)))
  
  (defmacro signals (condition &body body)
    `(check-signals ',condition (lambda () ,@body)))
  
  (defun report ()
    (format t "~& Did ~d check~:p.~%    ~
                     Pass: ~d (100%)~%    ~
                     Skip: 0 ( 0%)~%    ~
                     Fail: 0 ( 0%)~%"
            *pass-count* *pass-count*))
  
  (defmacro test (name &body body)
    `(progn
       (defun ,name ()
         (unless *running* (setf *pass-count* 0))
         (multiple-value-prog1 (progn ,@body)
           (unless *running* (report))))
       (pushnew ',name *tests*)
       ',name))
  
  (defun shuffle (vector)
    (let ((*random-state* (make-random-state t)))
      (loop
         :for i :downfrom (- (length vector) 1) :to 1
         :do (rotatef (aref vector i) (aref vector (random (1+ i))))))
    vector)
  
  (defun make-test-seq (test-spec)
    (etypecase test-spec
      (atom (vector test-spec))
      (sequence (shuffle (map-into (make-array (length test-spec))
                                   #'identity test-spec)))))
  
  (defun run! (&optional (test-spec *tests*))
    (setf *pass-count* 0)
    (let ((*running* t))
      (map nil #'funcall (make-test-seq test-spec))
      (report)))
  
  (defun debug! (&rest args)
    (apply #'run! args))
  
  (defun in-suite* (&rest args)
    (declare (ignore args)))
  
negative.code: ;;;
  ;;; * Type inferencing works inside the `is' macro.
  ;;;
  ;;; * Tests are runnable as ordinary functions of the same name.
  
  (defpackage #:lparallel-test.1am
    (:use #:cl)
    (:export #:is #:signals #:test #:run))
  
  (in-package #:lparallel-test.1am)
  
  