X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fdefstruct.impure.lisp;h=be0c7e8d8fbb708715558d2a1bb79e4f917924ca;hb=5d5894082c39ca44da75d38859d669c7b2108f6a;hp=7e5fad911510fedbba1f5103e68f6a1b0e0925a7;hpb=f73aadf04d841e0f1bfede4c11a13c4ba5c4e264;p=sbcl.git diff --git a/tests/defstruct.impure.lisp b/tests/defstruct.impure.lisp index 7e5fad9..be0c7e8 100644 --- a/tests/defstruct.impure.lisp +++ b/tests/defstruct.impure.lisp @@ -699,5 +699,46 @@ (sb-kernel:layout-invalid () :error2)))))) -;;; success -(format t "~&/returning success~%") +;; 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))))) + +;;; Check that all slot types (non-raw and raw) can be initialized with +;;; constant arguments. +(defstruct constant-arg-inits + (a 42 :type t) + (b 1 :type fixnum) + (c 2 :type sb-vm:word) + (d 3.0 :type single-float) + (e 4.0d0 :type double-float) + (f #c(5.0 5.0) :type (complex single-float)) + (g #c(6.0d0 6.0d0) :type (complex double-float))) +(defun test-constant-arg-inits () + (let ((foo (make-constant-arg-inits))) + (declare (dynamic-extent foo)) + (assert (eql 42 (constant-arg-inits-a foo))) + (assert (eql 1 (constant-arg-inits-b foo))) + (assert (eql 2 (constant-arg-inits-c foo))) + (assert (eql 3.0 (constant-arg-inits-d foo))) + (assert (eql 4.0d0 (constant-arg-inits-e foo))) + (assert (eql #c(5.0 5.0) (constant-arg-inits-f foo))) + (assert (eql #c(6.0d0 6.0d0) (constant-arg-inits-g foo))))) +(make-constant-arg-inits) + +;;; bug reported by John Morrison, 2008-07-22 on sbcl-devel +(defstruct (raw-slot-struct-with-unknown-init (:constructor make-raw-slot-struct-with-unknown-init ())) + (x (#:unknown-function) :type double-float)) +