Transpose lines.
[sbcl.git] / tests / backq.pure-cload.lisp
blobc12ee95421e83b643dcc8715c7145f755be4fb72
1 ;;;; tests of backquote readmacro within the compiler
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 ;; In the expression `(,@l1 a b ,@l2) is it preferable that we expand this
15 ;; as (APPEND L1 (LIST* 'A 'B L2)) or as (APPEND L1 '(A) '(B) L2)?
16 ;; The IR1 transform is designed to catch the latter case, but the expander
17 ;; returns the former, which probably favors speed over code size.
18 ;; This is perhaps an interesting reason to make expansion policy-sensitive.
19 ;; I'll test a case that definitely triggers the IR1 transform.
21 (defun list-backq-expr (l1) `(,@l1 ,most-positive-fixnum a))
22 (defun obviously-constant-list () '(#.most-positive-fixnum a))
24 (defun vector-backq-expr () `#(foo ,char-code-limit)) ; no xform, but folded
25 (defun obviously-constant-vector () #(foo #.char-code-limit))
27 (with-test (:name :backquote-ir1-simplifier)
28 ;; The pre-tests show that the backquoted expression did not compress
29 ;; (,char-code-limit x) into a constant, nor for the vector.
30 ;; Thus the IR1 optimization must do it in order for this test to pass.
31 (assert (equal (macroexpand '`(,@l1 ,char-code-limit x))
32 '(APPEND l1 (LIST* char-code-limit '(X)))))
33 (assert (equal (macroexpand '`#(,char-code-limit foo))
34 '(VECTOR char-code-limit 'foo)))
36 (assert (eq (obviously-constant-list) (list-backq-expr nil)))
38 ;; FIXME: do we not coalesce vector constants? I thought this should pass.
39 #+nil
40 (assert (eq (obviously-constant-vector) (vector-backq-expr)))
42 ;; Compiled code should reference a constant vector.
43 (assert (member (vector 'foo char-code-limit)
44 (ctu:find-code-constants #'vector-backq-expr)
45 :test #'equalp)))