symbol-function.lsp 1.04 KB
Newer Older
1 2 3 4 5 6 7 8 9
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Tue Jul 13 07:38:43 2004
;;;; Contains: Tests of SYMBOL-FUNCTION

(in-package :cl-test)

(deftest symbol-function.1
  (let ((sym (gensym))
sds's avatar
sds committed
10
        (f #'(lambda () (values 1 2 3))))
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
    (values
     (eqt (setf (symbol-function sym) f) f)
     (multiple-value-list (eval (list sym)))))
  t (1 2 3))

;;; Error cases

(deftest symbol-function.error.1
  (signals-error (symbol-function) program-error)
  t)

(deftest symbol-function.error.2
  (signals-error (symbol-function 'cons nil) program-error)
  t)

(deftest symbol-function.error.3
27
  (check-type-error #'symbol-function #'symbolp)
28 29 30
  nil)

(deftest symbol-function.error.4
31
  (check-type-error #'(lambda (x) (setf (symbol-function x) #'identity))
sds's avatar
sds committed
32
                    #'symbolp)
33 34 35 36
  nil)

(deftest symbol-function.error.5
  (let ((sym (gensym)))
pfdietz's avatar
pfdietz committed
37
    (handler-case (progn (symbol-function sym) nil)
sds's avatar
sds committed
38 39 40 41
                  (undefined-function
                   (c)
                   (assert (eq (cell-error-name c) sym))
                   :good)))
pfdietz's avatar
pfdietz committed
42 43 44
  :good)


45