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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Tue Jan 28 06:48:19 2003
;;;; Contains: Tests of ASSERT
(in-package :cl-test)
(deftest assert.1
(assert t)
nil)
(deftest assert.2
(assert t ())
nil)
;;; I am assuming that when no places are given to ASSERT,
;;; it doesn't invoke any interactive handler.
(deftest assert.3
(let ((x nil))
(handler-bind
((error #'(lambda (c)
(setq x 17)
(let ((r (find-restart 'continue c)))
(when r (invoke-restart r))))))
(assert x)
x))
17)
(deftest assert.3a
(let ((x nil))
(handler-bind
((error #'(lambda (c)
(setq x 17)
(continue c))))
(assert x)
x))
17)
;;; I don't yet know how to test the interactive version of ASSERT
;;; that is normally invoked when places are given.
;;; Tests of the syntax (at least)
(deftest assert.4
(let (x)
(assert t (x)))
nil)
(deftest assert.5
(let ((x (cons 'a 'b)))
(assert t ((car x) (cdr x))))
nil)
(deftest assert.6
(let ((x (vector 'a 'b 'c)))
(assert t ((aref x 0) (aref x 1) (aref x 2))
"Vector x has value: ~A." x))
nil)
(deftest assert.7
(let ((x nil))
(handler-bind
((simple-error #'(lambda (c)
(setq x 17)
(continue c))))
(assert x () 'simple-error)
x))
17)
(deftest assert.8
(let ((x 0))
(handler-bind
((type-error #'(lambda (c)
(incf x)
(continue c))))
(assert (> x 5) () 'type-error)
x))
6)
(deftest assert.9
(let ((x 0))
(handler-bind
((type-error #'(lambda (c) (declare (ignore c))
(incf x)
(continue))))
(assert (> x 5) () 'type-error)
x))
6)
;;; Test that explicit calls to macroexpand in subforms
;;; are done in the correct environment
(deftest assert.10
(macrolet
((%m (z) z))
(assert (expand-in-current-env (%m t))))
nil)
(deftest assert.11
(macrolet
((%m (z) z))
(assert (expand-in-current-env (%m t)) () "Foo!"))
nil)
|