1.0.3.40: :EXECUTABLE T implies --noinform
[sbcl.git] / tests / setf.impure.lisp
blobb15917360f9042f151268735288b06e0d2cae296
1 ;;;; tests related to setf
3 ;;;; This file is impure because we want to be able to use DEFUN.
5 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; more information.
7 ;;;;
8 ;;;; While most of SBCL is derived from the CMU CL system, the test
9 ;;;; files (like this one) were written from scratch after the fork
10 ;;;; from CMU CL.
11 ;;;;
12 ;;;; This software is in the public domain and is provided with
13 ;;;; absolutely no warranty. See the COPYING and CREDITS files for
14 ;;;; more information.
16 (in-package :cl-user)
18 (defvar *foo* nil)
19 (defun (setf foo) (bar)
20 (setf *foo* bar))
22 ;;; Regression test for get-setf-expansion without explicit
23 ;;; environment object.
24 (assert (multiple-value-list (get-setf-expansion '(foo))))
26 ;;; Regression test for SHIFTF of values.
27 (let ((x (list 1))
28 (y (list 2)))
29 (shiftf (values (car x) (car y)) (values (car y) (car x)))
30 (assert (equal (list x y) '((2) (1)))))
32 ;;; SETF of values with multiple-value place forms
33 (let ((a t) (b t) (c t) (d t))
34 (let ((list (multiple-value-list
35 (setf (values (values a b) (values c d)) (values 1 2 3 4)))))
36 (assert (equal list '(1 2)))
37 (assert (eql a 1))
38 (assert (eql c 2))
39 (assert (null b))
40 (assert (null d))))
42 ;;; SETF of THE with VALUES.
43 (let (x y)
44 (setf (the (values fixnum fixnum) (values x y))
45 (values 1 2))
46 (assert (= x 1))
47 (assert (= y 2)))
49 ;;; SETF of MACRO-FUNCTION must accept a NIL environment
50 (let ((fun (constantly 'ok)))
51 (setf (macro-function 'nothing-at-all nil) fun)
52 (assert (eq fun (macro-function 'nothing-at-all nil))))
54 ;;; success