-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.lisp
More file actions
29 lines (24 loc) · 719 Bytes
/
test.lisp
File metadata and controls
29 lines (24 loc) · 719 Bytes
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
(in-package :dbc)
(defmacro return-exception (expr)
"Returns the type of exception
associated with the evaluation
of expression expr; Returns
result of evaluation of expr
in no exceptions occur."
`(handler-case (eval ,expr)
(error (c)
(type-of c))))
(defun create-test-env ()
(progn
(defun double (xs)
(mapcar #'(lambda (x) (* x 2)) xs))
(defcnt doublee (xs)
(:pre (listp xs)
:post t)
(double xs))))
(create-test-env)
(lisp-unit:define-test pre-conditions
(let ((observed-exception (return-exception '(doublee 'invalid)))
(expected-exception 'simple-error))
(assert-equal observed-exception expected-exception)))
(lisp-unit:run-tests)