X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fdefstruct.impure.lisp;h=b80e723d663bcab5f87445ec274ad8eb14fc5684;hb=c2ac5ba3964165ee2d21ccd4c6bf8bdc48e1a165;hp=83475d091a81eaa971e540212134f11121dd84d8;hpb=970dd272dc84f7420252eadb4829cc193f795716;p=sbcl.git diff --git a/tests/defstruct.impure.lisp b/tests/defstruct.impure.lisp index 83475d0..b80e723 100644 --- a/tests/defstruct.impure.lisp +++ b/tests/defstruct.impure.lisp @@ -671,5 +671,47 @@ (aref (vector x) (incf i))) (bug-348-x x)))) -;;; success -(format t "~&/returning success~%") +;;; obsolete instance trapping +;;; +;;; FIXME: Both error conditions below should possibly be instances +;;; of the same class. (Putting this FIXME here, since this is the only +;;; place where they appear together.) + +(with-test (:name obsolete-defstruct/print-object) + (eval '(defstruct born-to-change)) + (let ((x (make-born-to-change))) + (handler-bind ((error 'continue)) + (eval '(defstruct born-to-change slot))) + (assert (eq :error + (handler-case + (princ-to-string x) + (sb-pcl::obsolete-structure () + :error)))))) + +(with-test (:name obsolete-defstruct/typep) + (eval '(defstruct born-to-change-2)) + (let ((x (make-born-to-change-2))) + (handler-bind ((error 'continue)) + (eval '(defstruct born-to-change-2 slot))) + (assert (eq :error2 + (handler-case + (typep x (find-class 'standard-class)) + (sb-kernel:layout-invalid () + :error2)))))) + +;; EQUALP didn't work for structures with float slots (reported by +;; Vjacheslav Fyodorov). +(defstruct raw-slot-equalp-bug + (b 0s0 :type single-float) + c + (a 0d0 :type double-float)) + +(with-test (:name raw-slot-equalp) + (assert (equalp (make-raw-slot-equalp-bug :a 1d0 :b 2s0) + (make-raw-slot-equalp-bug :a 1d0 :b 2s0))) + (assert (equalp (make-raw-slot-equalp-bug :a 1d0 :b 0s0) + (make-raw-slot-equalp-bug :a 1d0 :b -0s0))) + (assert (not (equalp (make-raw-slot-equalp-bug :a 1d0 :b 2s0) + (make-raw-slot-equalp-bug :a 1d0 :b 3s0)))) + (assert (not (equalp (make-raw-slot-equalp-bug :a 1d0 :b 2s0) + (make-raw-slot-equalp-bug :a 2d0 :b 2s0)))))