slot-unbound.lsp 1.39 KB
Newer Older
pfdietz's avatar
pfdietz committed
1 2 3 4 5
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sun Jun 15 06:57:23 2003
;;;; Contains: Tests for SLOT-UNBOUND

6

pfdietz's avatar
pfdietz committed
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

(defclass slot-unbound-class-01 ()
  ((a :reader sunb-a)
   (b :accessor sunb-b)
   (c :writer sunb-c)
   (e :reader sunb-e)
   (f :reader sunb-f)))

(defmethod slot-unbound ((class t) (obj slot-unbound-class-01) (slot-name t))
  (list (class-name class) slot-name))

(deftest slot-unbound.1
  (let ((obj (make-instance 'slot-unbound-class-01)))
    (values
     (slot-value obj 'a)
     (slot-value obj 'b)
     (slot-value obj 'c)))
  (slot-unbound-class-01 a)
  (slot-unbound-class-01 b)
  (slot-unbound-class-01 c))

(deftest slot-unbound.2
  (let ((obj (make-instance 'slot-unbound-class-01)))
    (values
     (sunb-a obj)
     (sunb-b obj)))
  (slot-unbound-class-01 a)
  (slot-unbound-class-01 b))

(defmethod slot-unbound ((class t) (obj slot-unbound-class-01)
sds's avatar
sds committed
37
                         (slot-name (eql 'e)))
pfdietz's avatar
pfdietz committed
38 39 40
  (values))

(defmethod slot-unbound ((class t) (obj slot-unbound-class-01)
sds's avatar
sds committed
41
                         (slot-name (eql 'f)))
pfdietz's avatar
pfdietz committed
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
  (values 1 2 3))

(deftest slot-unbound.3
  (slot-value (make-instance 'slot-unbound-class-01) 'e)
  nil)

(deftest slot-unbound.4
  (slot-value (make-instance 'slot-unbound-class-01) 'f)
  1)

(deftest slot-unbound.5
  (sunb-e (make-instance 'slot-unbound-class-01))
  nil)

(deftest slot-unbound.6
  (sunb-f (make-instance 'slot-unbound-class-01))
  1)