Signal floating-point-overflow from bignum-to-float.
[sbcl.git] / tests / backq.impure-cload.lisp
blob2400a0acb54db8d2d747a02b17286ca1809d0d5f
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-package "CL-USER")
16 (eval-when (:compile-toplevel)
17 (load "compiler-test-util.lisp"))
19 ;; In the expression `(,@l1 a b ,@l2) is it preferable that we expand this
20 ;; as (APPEND L1 (LIST* 'A 'B L2)) or as (APPEND L1 '(A) '(B) L2)?
21 ;; The IR1 transform is designed to catch the latter case, but the expander
22 ;; returns the former, which probably favors speed over code size.
23 ;; This is perhaps an interesting reason to make expansion policy-sensitive.
24 ;; I'll test a case that definitely triggers the IR1 transform.
26 (defun list-backq-expr (l1) `(,@l1 ,most-positive-fixnum a))
27 (defun obviously-constant-list () '(#.most-positive-fixnum a))
29 (defun vector-backq-expr () `#(foo ,char-code-limit)) ; no xform, but folded
30 (defun obviously-constant-vector () #(foo #.char-code-limit))
32 (test-util:with-test (:name :backquote-ir1-simplifier)
33 ;; The pre-tests show that the backquoted expression did not compress
34 ;; (,char-code-limit x) into a constant, nor for the vector.
35 ;; Thus the IR1 optimization must do it in order for this test to pass.
36 (assert (equal (macroexpand '`(,@l1 ,char-code-limit x))
37 '(APPEND l1 (LIST* char-code-limit '(X)))))
38 (assert (equal (macroexpand '`#(,char-code-limit foo))
39 '(VECTOR char-code-limit 'foo)))
41 (assert (eq (obviously-constant-list) (list-backq-expr nil)))
43 ;; FIXME: do we not coalesce vector constants? I thought this should pass.
44 #+nil
45 (assert (eq (obviously-constant-vector) (vector-backq-expr)))
47 ;; Compiled code should reference a constant vector.
48 (assert (member (vector 'foo char-code-limit)
49 (ctu:find-code-constants #'vector-backq-expr)
50 :test #'equalp)))