-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchecks.lisp
32 lines (25 loc) · 926 Bytes
/
checks.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
;;; NUTS special checks
;;; (c) Vsevolod Dyomkin, see LICENSE file for permissions
(in-package :nuts)
(defmacro check-t (form)
"Checks, if <_:arg form />'s return value is non-NIL
and in this case returns T instead of a it"
`(check 'true ,form))
(defmacro check-errs (form &rest error-types)
"Check, that errors of <_:arg error-types /> (or any errors,
if this list is empty) are signaled. Errors are not re-signalled"
`(handler-case
(progn ,form
nil)
,@(mapcar (lambda (error-type)
`(,error-type (c)
(declare (ignore c))
(check eql ',error-type ',error-type)))
(or error-types '(error)))))
(defmacro check-funcall (form fun-form)
"Check, that <_:arg fun-form /> was called inside <_:arg form />"
`(check 'inside/equalp
(with-inter ((car ,fun-form))
,form)
,fun-form))
;;; end