0.7.8.34:
[sbcl.git] / tests / dump.impure-cload.lisp
1 ;;;; tests related to the way objects are dumped into fasl files
2
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
6 ;;;; While most of SBCL is derived from the CMU CL system, the test
7 ;;;; files (like this one) were written from scratch after the fork
8 ;;;; from CMU CL.
9 ;;;; 
10 ;;;; This software is in the public domain and is provided with
11 ;;;; absolutely no warranty. See the COPYING and CREDITS files for
12 ;;;; more information.
13
14 (cl:in-package :cl-user)
15
16 (declaim (optimize (debug 3) (speed 2) (space 1)))
17
18 ;;; Don Geddis reported this test case 25 December 1999 on a CMU CL
19 ;;; mailing list: dumping circular lists caused the compiler to enter
20 ;;; an infinite loop. Douglas Crosher reported a patch 27 Dec 1999.
21 ;;; The patch was tested on SBCL by Martin Atzmueller 2 Nov 2000, and
22 ;;; merged in sbcl-0.6.8.11.
23 (defun q-dg1999-1 () (dolist (x '#1=("A" "B" . #1#)) x))
24 (defun q-dg1999-2 () (dolist (x '#1=("C" "D" . #1#)) x))
25 (defun q-dg1999-3 () (dolist (x '#1=("E" "F" . #1#)) x))
26 (defun q-dg1999-4 () (dolist (x '#1=("C" "D" . #1#)) x))
27 (defun useful-dg1999 (keys)
28   (declare (type list keys))
29   (loop
30       for c in '#1=("Red" "Blue" . #1#)
31       for key in keys))
32
33 ;;; sbcl-0.6.11.25 or so had DEF!STRUCT/MAKE-LOAD-FORM/HOST screwed up
34 ;;; so that the compiler couldn't dump pathnames.
35 (format t "Now the compiler can dump pathnames again: ~S ~S~%" #p"" #p"/x/y/z")
36
37 (eval-when (:compile-toplevel :load-toplevel :execute)
38   (defstruct foo x y)
39   (defmethod make-load-form ((foo foo) &optional env)
40     (declare (ignore env))
41     ;; an extremely meaningless MAKE-LOAD-FORM method whose only point
42     ;; is to exercise the mechanism a little bit
43     (values `(make-foo :x (list ',(foo-x foo)))
44             `(setf (foo-y ,foo) ',foo))))
45
46 (defparameter *foo*
47   #.(make-foo :x "X" :y "Y"))
48
49 (assert (equalp (foo-x *foo*) '("X")))
50 (assert (eql (foo-y *foo*) *foo*))
51
52 ;;; Logical pathnames should be dumpable, too, but what does it mean?
53 ;;; As of sbcl-0.7.7.16, we've taken dumping the host part to mean
54 ;;; dumping a reference to the name of the host (much as dumping a
55 ;;; symbol involves dumping a reference to the name of its package).
56 (eval-when (:compile-toplevel :load-toplevel :execute)
57   (setf (logical-pathname-translations "MY-LOGICAL-HOST")
58         (list '("**;*.*.*" "/tmp/*.*"))))
59
60 (defparameter *path* #p"MY-LOGICAL-HOST:FOO;BAR.LISP")
61
62 ;;; Non-SIMPLE-ARRAY VECTORs should be dumpable, though they can lose
63 ;;; their complex attributes.
64
65 (defparameter *string* #.(make-array 3 :initial-element #\a
66                                        :fill-pointer 2
67                                        :element-type 'character))
68
69 ;;; SBCL 0.7.8 incorrectly read high bits of (COMPLEX DOUBLE-FLOAT)
70 ;;; components as unsigned bytes.
71 (defparameter *numbers*
72   '(-1s0 -1f0 -1d0 -1l0
73     #c(-1s0 -1s0) #c(-1f0 -1f0) #c(-1d0 -1d0) #c(-1l0 -1l0)))
74
75 (sb-ext:quit :unix-status 104) ; success