Move COMPILE-FILE-POSITION tests to their own file.
[sbcl.git] / tests / compiler-2.impure-cload.lisp
blob441852228765994ed8809672099d214548ecd4f8
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 ;;; This is a fopcompilable form that caused FOP stack underflow
20 ;;; because the PROGN and SETQ each failed to push a NIL onto the stack.
21 ;;; >>> DO NOT ADD A (WITH-TEST) TO THIS. <<< It must stay fopcompilable.
22 (let ((a (progn)) ; lp# 1427050
23 (b (setq))
24 (b (+ 1 2)))
25 (defvar *aaa* a)
26 (defvar *bbb* b))
29 ;;;; These three forms should be equivalent.
31 ;;; This used to be a bug in the handling of null-lexenv vs toplevel
32 ;;; policy: LOCALLY and MACROLET hid the toplevel policy from view.
34 (locally
35 (defun foo (n)
36 (frob 'foo)
37 (if (<= n 0)
39 (foo (1- n)))))
41 (progn
42 (defun bar (n)
43 (frob 'bar)
44 (if (<= n 0)
46 (bar (1- n)))))
48 (macrolet ()
49 (defun quux (n)
50 (frob 'quux)
51 (if (<= n 0)
53 (quux (1- n)))))
55 (defun frob (x)
56 (setf (fdefinition x) (constantly 13)))
58 (defun test ()
59 (list (foo 1) (bar 1) (quux 1)))
61 (assert (equal (test) '(0 0 0)))
62 (assert (equal (test) '(13 13 13))) ; sanity check
64 ;;; Bug in 1.0.2 and 1.0.3, where the XEP was compiled with the wrong
65 ;;; policy. (Test-case derived from code posted by alexander.ekart in
66 ;;; comp.lang.lisp).
68 (locally
69 (declare (optimize (safety 0)))
70 (defun bubblesort (x y)
71 (declare (type (simple-array fixnum (*)) x)
72 (type fixnum y)
73 (optimize (speed 3) (safety 3) (space 0) (debug 0)))
74 (aref x y)))
76 (assert-error (bubblesort (make-array 10) 9))
78 (define-symbol-macro %trash% what)
79 (locally
80 ;; just in case we get so smart that INFO becomes foldable
81 (declare (notinline sb-int:info))
82 (assert (eq (sb-int:info :variable :kind '%trash%) :macro))
83 (assert (eq (sb-int:info :variable :macro-expansion '%trash%) 'what))
84 (assert (sb-int:info :source-location :symbol-macro '%trash%)))
85 (let ()
86 (declare (notinline sb-int:info))
87 (defconstant %trash% 9) ; this is non-toplevel
88 (multiple-value-bind (val foundp)
89 (sb-int:info :variable :macro-expansion '%trash%)
90 (assert (and (not val) (not foundp)))))