Remove private keywords from sb-thread:make-mutex.
[sbcl.git] / tests / compiler-2.pure.lisp
blob61a1fefabcb5eb1171380e12481df9992369e265
1 ;;;; various compiler tests without side effects
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 ;;;; This file of tests was added because the tests in 'compiler.pure.lisp'
15 ;;;; are a total hodgepodge- there is often no hugely compelling reason for
16 ;;;; their being tests of the compiler per se, such as whether
17 ;;;; INPUT-ERROR-IN-COMPILED-FILE is a subclass of SERIOUS-CONDITION;
18 ;;;; in addition to which it is near impossible to wade through the
19 ;;;; ton of nameless, slow, and noisy tests.
21 ;;;; This file strives to do better on all fronts:
22 ;;;; the tests should be fast, named, and not noisy.
24 (cl:in-package :cl-user)
26 (load "compiler-test-util.lisp")
28 (with-test (:name :ldb-recognize-local-macros)
29 ;; Should not call %LDB
30 (assert (not (ctu:find-named-callees
31 (compile nil
32 '(lambda (x)
33 (declare (optimize speed))
34 (macrolet ((b () '(byte 2 2)))
35 (ldb (b) (the fixnum x)))))))))
37 ;; lp#1458190
38 (with-test (:name :dbp-eval-order)
39 (sb-int:collect ((calls))
40 (flet ((f (new old)
41 (dpb (progn (calls 'eval-new) new)
42 (progn (calls 'eval-byte) (byte 10 10))
43 (progn (calls 'eval-old) old))))
44 (f 20 0)
45 (assert (equal (calls)
46 '(eval-new eval-byte eval-old))))))
48 ;; Best practice treats TRULY-THE as a special operator, not a macro,
49 ;; in a context such as (DPB X (TRULY-THE SB-KERNEL:BYTE-SPECIFIER ...) Y).
50 ;; DPB used to expand its second argument using MACROEXPAND and lose
51 ;; the nuance of TRULY-THE. Strictly speaking, byte-specifier is not a
52 ;; type specifier that users are supposed to know about, so portable code
53 ;; should not care, but this might affect internal code.
54 (with-test (:name :dpb-inner-macro)
55 (flet ((source-xform (sexpr)
56 (funcall (sb-int:info :function :source-transform (car sexpr))
57 sexpr (sb-kernel:make-null-lexenv))))
58 (assert (equal-mod-gensyms
59 (source-xform
60 '(dpb (new) (truly-the sb-kernel:byte-specifier bspec) (old)))
61 '(let ((new (new))
62 (byte (truly-the sb-kernel:byte-specifier bspec)))
63 (sb-kernel:%dpb new (byte-size byte) (byte-position byte)
64 (old)))))))