class-name.lsp 1.13 KB
Newer Older
1 2 3 4 5
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sun Jun 15 12:05:47 2003
;;;; Contains: Tests of CLASS-NAME

6

7 8 9 10 11 12 13 14 15

;;; This is mostly tested elsewhere.

(deftest class-name.1
  (class-name (find-class 'symbol))
  symbol)

(defclass class-name-class-01 () (a b c))

16 17
(report-and-ignore-errors
 (eval '(defmethod class-name ((x class-name-class-01)) 'silly)))
18 19 20 21 22 23 24 25 26 27 28

(deftest class-name.2
  (class-name (make-instance 'class-name-class-01))
  silly)

;; Tests of (setf class-name)

(deftest setf-class-name.1
  (typep* #'(setf class-name) 'standard-generic-function)
  t)

29 30
(deftest setf-class-name.2
  (let ((sym (gensym))
sds's avatar
sds committed
31
        (newsym (gensym)))
32 33 34 35 36
    (eval `(defclass ,sym () (a b c)))
    (let ((class (find-class sym)))
      (values
       (eqlt (class-name class) sym)
       (equalt
sds's avatar
sds committed
37 38
        (multiple-value-list (setf (class-name (find-class sym)) newsym))
        (list newsym))
39 40
       (eqlt newsym (class-name class)))))
  t t t)
sds's avatar
sds committed
41

42 43 44

;;; Error tests

45
(deftest class-name.error.1
46 47
  (signals-error (class-name) program-error)
  t)
48 49

(deftest class-name.error.2
50
  (signals-error (class-name (find-class 'symbol) nil)
sds's avatar
sds committed
51
                 program-error)
52
  t)