aboutsummaryrefslogtreecommitdiff
path: root/testiere.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'testiere.lisp')
-rw-r--r--testiere.lisp32
1 files changed, 11 insertions, 21 deletions
diff --git a/testiere.lisp b/testiere.lisp
index 949e492..1750a2d 100644
--- a/testiere.lisp
+++ b/testiere.lisp
@@ -7,6 +7,17 @@
(defun build-test (name spec)
(match spec
+ ((list :fails inputs)
+ `(assert
+ (handler-case (progn (,name ,@inputs) nil)
+ (error (e) (declare (ignore e)) t))))
+
+ ((list :signals inputs condition)
+ `(assert
+ (handler-case (progn (,name ,@inputs) nil)
+ (,condition (c) (declare (ignore c)) t)
+ (condition (c) (declare (ignore c)) nil))))
+
((list* :with-stubs redefs more-specs)
(let* ((assoc-vars
(loop for (stub-name . more) in redefs
@@ -60,27 +71,6 @@
(error (e)
(format t "~a~%Not defining ~a" e ',name))))))
-;; (defun+ plus-at-least-two (a b &rest more)
-;; "Adds at least two numbers together"
-;; :tests
-;; (= (1 2 3 4) 10)
-;; (= (0 0) 0)
-;; (:stubs ((some-function (x y z) (print "stubbed") (list x y z)))
-;; :before 'do-some-stuff-before-hand
-;; :test (= (1 1) 2)
-;; :after-with-outptu 'check-output-all-good-p)
-;; (:fails (1))
-;; (:throws ("foo" "bar") 'type-error)
-;; (:after (1 1) 'all-good-after-p)
-;; (:after-with-output (1 1) 'output-all-good-after-p)
-;; (:setup 'do-some-stuff-before-hand
-;; :then :test (= (1 1) 2)
-;; :after 'all-good-after-p)
-;; :end
-;; (reduce '+ more :initial-value (+ a b)))
-
-
-
(defmacro defmethod+ (name (&optional combination) lambda-list &body body)
"Like regular DEFMETHOD, but with embedded unit tests. If those
test would fail, the method fails to be defined. ")