makunbound.lsp 1.15 KB
Newer Older
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
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Tue Jul 13 07:55:05 2004
;;;; Contains: Add tests for MAKUNBOUND

(in-package :cl-test)

(deftest makunbound.1
  (let ((sym (gensym)))
    (values
     (boundp sym)
     (equalt (multiple-value-list (makunbound sym)) (list sym))
     (boundp sym)
     (setf (symbol-value sym) nil)
     (notnot (boundp sym))
     (equalt (multiple-value-list (makunbound sym)) (list sym))
     (boundp sym)))
  nil t nil nil t t nil)

(deftest makunbound.2
  (let ((sym (gensym)))
    (values
     (boundp sym)
     (setf (symbol-value sym) :foo)
     (equalt (multiple-value-list (makunbound sym)) (list sym))
     (boundp sym)
     (handler-case (symbol-value sym)
sds's avatar
sds committed
28 29 30
                   (unbound-variable (c)
                     (if (eq (cell-error-name c) sym) :good
                       (list :bad sym (cell-error-name c)))))))
31 32 33 34 35 36 37 38 39 40 41 42 43
  nil :foo t nil :good)

;;; Error cases

(deftest makunbound.error.1
  (signals-error (makunbound) program-error)
  t)

(deftest makunbound.error.2
  (signals-error (makunbound (gensym) nil) program-error)
  t)

(deftest makunbound.error.3
pfdietz's avatar
pfdietz committed
44
  (check-type-error #'makunbound #'symbolp)
45
  nil)