a627d0626cc3bea8e68cb27b7414422a25ff54dc
[sbcl.git] / tests / smoke.impure.lisp
1 ;;;; rudimentary tests ("smoke tests") for miscellaneous stuff which
2 ;;;; doesn't seem to deserve specialized files at the moment
3
4 ;;;; This software is part of the SBCL system. See the README file for
5 ;;;; more information.
6 ;;;;
7 ;;;; While most of SBCL is derived from the CMU CL system, the test
8 ;;;; files (like this one) were written from scratch after the fork
9 ;;;; from CMU CL.
10 ;;;; 
11 ;;;; This software is in the public domain and is provided with
12 ;;;; absolutely no warranty. See the COPYING and CREDITS files for
13 ;;;; more information.
14
15 (cl:in-package :cl-user)
16
17 ;;; ROOM should run without signalling an error. (bug 247)
18 (room)
19 (room t)
20 (room nil)
21
22 ;;; COPY-SYMBOL should work without signalling an error, even if the
23 ;;; symbol is unbound.
24 (copy-symbol 'foo)
25 (copy-symbol 'bar t)
26 (defvar *baz* nil)
27 (copy-symbol '*baz* t)
28
29 ;;; SETQ should return its value.
30 (assert (typep (setq *baz* 1) 'integer))
31 (assert (typep (in-package :cl-user) 'package))
32
33 ;;; PROFILE should run without obvious breakage
34 #-darwin
35 (progn
36   (defun profiled-fun ()
37     (random 1d0))
38   (profile profiled-fun)
39   (loop repeat 100000 do (profiled-fun))
40   (report))
41
42 ;;; Defconstant should behave as the documentation specifies,
43 ;;; including documented condition type.
44 (defun oidentity (x) x)
45 (defconstant +const+ 1)
46 (assert (= (oidentity +const+) 1))
47 (let ((error (nth-value 1 (ignore-errors (defconstant +const+ 2)))))
48   (assert (typep error 'sb-ext:defconstant-uneql))
49   (assert (= (sb-ext:defconstant-uneql-old-value error) 1))
50   (assert (= (sb-ext:defconstant-uneql-new-value error) 2))
51   (assert (eql (sb-ext:defconstant-uneql-name error) '+const+)))
52 (assert (= (oidentity +const+) 1))
53 (handler-bind
54     ((sb-ext:defconstant-uneql
55          (lambda (c) (abort c))))
56   (defconstant +const+ 3))
57 (assert (= (oidentity +const+) 1))
58 (handler-bind
59     ((sb-ext:defconstant-uneql
60          (lambda (c) (continue c))))
61   (defconstant +const+ 3))
62 (assert (= (oidentity +const+) 3))
63
64 ;;; MULTIPLE-VALUE-BIND and lambda list keywords
65 (multiple-value-bind (&rest &optional &key &allow-other-keys)
66     (values 1 2 3)
67   (assert (= &rest 1))
68   (assert (= &optional 2))
69   (assert (= &key 3))
70   (assert (null &allow-other-keys)))
71
72 (let ((fn (lambda (&foo &rest &bar) (cons &foo &bar))))
73   (assert (equal (funcall fn 1) '(1)))
74   (assert (equal (funcall fn 1 2 3) '(1 2 3))))
75
76 ;;; success
77 (quit :unix-status 104)