-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathclass-name.lsp
52 lines (39 loc) · 1.16 KB
/
class-name.lsp
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
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sun Jun 15 12:05:47 2003
;;;; Contains: Tests of CLASS-NAME
(in-package :cl-test)
;;; This is mostly tested elsewhere.
(deftest class-name.1
(class-name (find-class 'symbol))
symbol)
(defclass class-name-class-01 () (a b c))
(report-and-ignore-errors
(eval '(defmethod class-name ((x class-name-class-01)) 'silly)))
(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)
(deftest setf-class-name.2
(let ((sym (gensym))
(newsym (gensym)))
(eval `(defclass ,sym () (a b c)))
(let ((class (find-class sym)))
(values
(eqlt (class-name class) sym)
(equalt
(multiple-value-list (setf (class-name (find-class sym)) newsym))
(list newsym))
(eqlt newsym (class-name class)))))
t t t)
;;; Error tests
(deftest class-name.error.1
(signals-error (class-name) program-error)
t)
(deftest class-name.error.2
(signals-error (class-name (find-class 'symbol) nil)
program-error)
t)