aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2021-06-29 10:56:27 -0500
committerColin Okay <okay@toyful.space>2021-06-29 10:56:27 -0500
commitf910263958844bbd09bf949f627854ce44959181 (patch)
tree40d1e8758ae6a72240acd48a9b8d01a1df6a34c2
parent902093ad89a154b267772acc197f7f47f2eeefd4 (diff)
signals and fails test types
-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. ")