X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fcompiler.impure.lisp;h=84dd8488f9904b9e55656b19d83f8e6926c2cef1;hb=f2f24807c969eeab86a4daa7f1fc611e7bd27594;hp=2502ae2d49e1c0a8abb19bb5038f4beede76010b;hpb=b025fdbef7236941a6389fe6fa9d9903d2a5cab7;p=sbcl.git diff --git a/tests/compiler.impure.lisp b/tests/compiler.impure.lisp index 2502ae2..84dd848 100644 --- a/tests/compiler.impure.lisp +++ b/tests/compiler.impure.lisp @@ -1628,8 +1628,8 @@ (defvar *sneaky-nested-thing* (list (make-instance 'some-constant-thing))) (defconstant +sneaky-nested-thing+ *sneaky-nested-thing*) (multiple-value-bind (file-fun core-fun) (compile2 '(lambda () +sneaky-nested-thing+)) - (assert (eq *sneaky-nested-thing* (funcall file-fun))) - (assert (eq *sneaky-nested-thing* (funcall core-fun)))) + (assert (equal *sneaky-nested-thing* (funcall file-fun))) + (assert (equal *sneaky-nested-thing* (funcall core-fun)))) ;;; catch constant modifications thru undefined variables (defun sneak-set-dont-set-me (x) @@ -1643,4 +1643,39 @@ (assert (not (sneak-set-dont-set-me2 13))) (assert (typep dont-set-me2 'some-constant-thing)) +;;; check that non-trivial constants are EQ across different files: this is +;;; not something ANSI either guarantees or requires, but we want to do it +;;; anyways. +(defconstant +share-me-1+ 123.456d0) +(defconstant +share-me-2+ "a string to share") +(defconstant +share-me-3+ (vector 1 2 3)) +(defconstant +share-me-4+ (* 2 most-positive-fixnum)) +(multiple-value-bind (f1 c1) (compile2 '(lambda () (values +share-me-1+ + +share-me-2+ + +share-me-3+ + +share-me-4+ + pi))) + (multiple-value-bind (f2 c2) (compile2 '(lambda () (values +share-me-1+ + +share-me-2+ + +share-me-3+ + +share-me-4+ + pi))) + (flet ((test (fa fb) + (mapc (lambda (a b) + (assert (eq a b))) + (multiple-value-list (funcall fa)) + (multiple-value-list (funcall fb))))) + (test f1 c1) + (test f1 f2) + (test f1 c2)))) + +;;; user-defined satisfies-types cannot be folded +(deftype mystery () '(satisfies mysteryp)) +(defvar *mystery* nil) +(defun mysteryp (x) (eq x *mystery*)) +(defstruct thing (slot (error "missing") :type mystery)) +(defun test-mystery (m) (when (eq :mystery (thing-slot m)) :ok)) +(setf *mystery* :mystery) +(assert (eq :ok (test-mystery (make-thing :slot :mystery)))) + ;;; success