Commit 8940b764 authored by pfdietz's avatar pfdietz
Browse files

More slot-exists-p tests, particularly on structure and condition classes.

parent cd1bf879
......@@ -53,3 +53,82 @@
when (slot-exists-p x slot-name)
collect x))
nil)
;;; With various types
(defclass slot-exists-p-class-02 ()
((a :type t) (b :type nil) (c :type symbol) (d :type cons)
(e :type float) (f :type single-float) (g :type short-float)
(h :type double-float) (i :type long-float) (j :type char)
(k :type base-char) (l :type rational) (m :type ratio) (n :type integer)
(o :type fixnum) (p :type complex) (q :type condition)))
(deftest slot-exists-p.9
(let ((obj (allocate-instance (find-class 'slot-exists-p-class-02))))
(map-slot-exists-p* obj '(a b c d e f g h i j k l m n o p q)))
(t t t t t t t t t t t t t t t t t))
;;; Inheritance
(defclass slot-exists-p-class-03a ()
(a b))
(defclass slot-exists-p-class-03b ()
(a c))
(defclass slot-exists-p-class-03c (slot-exists-p-class-03a slot-exists-p-class-03b)
(d e))
(deftest slot-exists-p.10
(let ((obj (allocate-instance (find-class 'slot-exists-p-class-03c))))
(map-slot-exists-p* obj '(a b c d e f g)))
(t t t t t nil nil))
;;; SLOT-EXISTS-P is supposed to work on structure objects and condition objects
(defstruct slot-exists-p-struct-01
a b c)
(deftest slot-exists-p.11
(let ((obj (make-slot-exists-p-struct-01)))
(map-slot-exists-p* obj '(a b c z nil)))
(t t t nil nil))
(deftest slot-exists-p.12
(let ((obj (make-slot-exists-p-struct-01 :a 1 :b 2 :c 3)))
(map-slot-exists-p* obj '(a b c z nil)))
(t t t nil nil))
(defstruct (slot-exists-p-struct-02 (:include slot-exists-p-struct-01))
d e)
(deftest slot-exists-p.13
(let ((obj (make-slot-exists-p-struct-02)))
(map-slot-exists-p* obj '(a b c d e f z nil)))
(t t t t t nil nil nil))
(deftest slot-exists-p.14
(let ((obj (make-slot-exists-p-struct-02 :a 1 :b 3 :e 5)))
(map-slot-exists-p* obj '(a b c d e f z nil)))
(t t t t t nil nil nil))
;;; SLOT-EXISTS-P is supposed to work on condition objects, too
;;; (after all, they are objects, and they have slots)
(define-condition slot-exists-p-condition-01 ()
(a b c))
(deftest slot-exists-p.15
(let ((obj (make-condition 'slot-exists-p-condition-01)))
(map-slot-exists-p* obj (list 'a 'b 'c (gensym))))
(t t t nil))
(define-condition slot-exists-p-condition-02 (slot-exists-p-condition-01)
(a d e))
(deftest slot-exists-p.16
(let ((obj (make-condition 'slot-exists-p-condition-01)))
(map-slot-exists-p* obj (list 'a 'b 'c 'd 'e (gensym))))
(t t t t t nil))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment