Parse raw slot data when printing structures in LDB
[sbcl.git] / tests / compiler-2.impure-cload.lisp
blob3d9d2ab71bdb0cb06c7f648d6f463b778f23d2f8
1 ;;;; -*- lisp -*-
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.
14 (cl:in-package :cl-user)
16 ;;;; recognize self-calls
17 (declaim (optimize speed))
19 ;;;; These three forms should be equivalent.
21 ;;; This used to be a bug in the handling of null-lexenv vs toplevel
22 ;;; policy: LOCALLY and MACROLET hid the toplevel policy from view.
24 (locally
25 (defun foo (n)
26 (frob 'foo)
27 (if (<= n 0)
29 (foo (1- n)))))
31 (progn
32 (defun bar (n)
33 (frob 'bar)
34 (if (<= n 0)
36 (bar (1- n)))))
38 (macrolet ()
39 (defun quux (n)
40 (frob 'quux)
41 (if (<= n 0)
43 (quux (1- n)))))
45 (defun frob (x)
46 (setf (fdefinition x) (constantly 13)))
48 (defun test ()
49 (list (foo 1) (bar 1) (quux 1)))
51 (assert (equal (test) '(0 0 0)))
52 (assert (equal (test) '(13 13 13))) ; sanity check
54 ;;; Bug in 1.0.2 and 1.0.3, where the XEP was compiled with the wrong
55 ;;; policy. (Test-case derived from code posted by alexander.ekart in
56 ;;; comp.lang.lisp).
58 (locally
59 (declare (optimize (safety 0)))
60 (defun bubblesort (x y)
61 (declare (type (simple-array fixnum (*)) x)
62 (type fixnum y)
63 (optimize (speed 3) (safety 3) (space 0) (debug 0)))
64 (aref x y)))
66 (assert-error (bubblesort (make-array 10) 9))
68 (define-symbol-macro %trash% what)
69 (locally
70 ;; just in case we get so smart that INFO becomes foldable
71 (declare (notinline sb-int:info))
72 (assert (eq (sb-int:info :variable :kind '%trash%) :macro))
73 (assert (eq (sb-int:info :variable :macro-expansion '%trash%) 'what))
74 (assert (sb-int:info :source-location :symbol-macro '%trash%)))
75 (let ()
76 (declare (notinline sb-int:info))
77 (defconstant %trash% 9) ; this is non-toplevel
78 (multiple-value-bind (val foundp)
79 (sb-int:info :variable :macro-expansion '%trash%)
80 (assert (and (not val) (not foundp)))))