1.0.31.14: removing :DEFAULT-INITARGS via DEFCLASS
[sbcl/pkhuong.git] / tests / interface.pure.lisp
blob81a987b8bbab1170bea11764caacf452686913d0
1 ;;;; tests for problems in the interface presented to the user/programmer
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 ;;;; properties of symbols, e.g. presence of doc strings for public symbols
18 ;;; FIXME: It would probably be good to require here that every
19 ;;; external symbol either has a doc string or has some good excuse
20 ;;; (like being an accessor for a structure which has a doc string).
22 ;;;; tests of interface machinery
24 ;;; APROPOS should accept a package designator, not just a package, and
25 ;;; furthermore do the right thing when it gets a package designator.
26 ;;; (bug reported and fixed by Alexey Dejneka sbcl-devel 2001-10-17)
27 (assert (< 0
28 (length (apropos-list "PRINT" :cl))
29 (length (apropos-list "PRINT"))))
30 ;;; Further, it should correctly deal with the external-only flag (bug
31 ;;; reported by cliini on #lisp IRC 2003-05-30, fixed in sbcl-0.8.0.1x
32 ;;; by CSR)
33 (assert (= (length (apropos-list "" "CL"))
34 (length (apropos-list "" "CL" t))))
35 (assert (< 0
36 (length (apropos-list "" "SB-VM" t))
37 (length (apropos-list "" "SB-VM"))))
39 ;;; DESCRIBE shouldn't fail on rank-0 arrays (bug reported and fixed
40 ;;; by Lutz Euler sbcl-devel 2002-12-03)
41 (describe #0a0)
42 (describe #(1 2 3))
43 (describe #2a((1 2) (3 4)))
45 ;;; TYPEP, SUBTYPEP, UPGRADED-ARRAY-ELEMENT-TYPE and
46 ;;; UPGRADED-COMPLEX-PART-TYPE should be able to deal with NIL as an
47 ;;; environment argument
48 (typep 1 'fixnum nil)
49 (subtypep 'fixnum 'integer nil)
50 (upgraded-array-element-type '(mod 5) nil)
51 (upgraded-complex-part-type '(single-float 0.0 1.0) nil)
53 ;;; We should have documentation for our extension package:
54 (assert (documentation (find-package "SB-EXT") t))
56 ;;; DECLARE should not be a special operator
57 (assert (not (special-operator-p 'declare)))
59 ;;; WITH-TIMEOUT should accept more than one form in its body.
60 (with-test (:name :with-timeout-forms)
61 (handler-bind ((sb-ext:timeout #'continue))
62 (sb-ext:with-timeout 3
63 (sleep 2)
64 (sleep 2))))
66 ;;; SLEEP should work with large integers as well -- no timers
67 ;;; on win32, so don't test there.
68 #-win32
69 (with-test (:name (sleep pretty-much-forever))
70 (assert (eq :timeout
71 (handler-case
72 (sb-ext:with-timeout 1
73 (sleep (ash 1 (* 2 sb-vm:n-word-bits))))
74 (sb-ext:timeout ()
75 :timeout)))))
77 ;;; DOCUMENTATION should return nil, not signal slot-unbound
78 (documentation 'fixnum 'type)
79 (documentation 'class 'type)
80 (documentation (find-class 'class) 'type)
81 (documentation 'foo 'structure)
83 ;;; DECODE-UNIVERSAL-TIME should accept second-resolution time-zones.
84 (macrolet ((test (ut time-zone list)
85 (destructuring-bind (sec min hr date mon yr day tz)
86 list
87 `(multiple-value-bind (sec min hr date mon yr day dst tz)
88 (decode-universal-time ,ut ,time-zone)
89 (declare (ignore dst))
90 (assert (= sec ,sec))
91 (assert (= min ,min))
92 (assert (= hr ,hr))
93 (assert (= date ,date))
94 (assert (= mon ,mon))
95 (assert (= yr ,yr))
96 (assert (= day ,day))
97 (assert (= tz ,tz))))))
98 (test (* 86400 365) -1/3600 (1 0 0 1 1 1901 1 -1/3600))
99 (test (* 86400 365) 0 (0 0 0 1 1 1901 1 0))
100 (test (* 86400 365) 1/3600 (59 59 23 31 12 1900 0 1/3600)))
102 ;;; DECODE-UNIVERSAL-TIME shouldn't fail when the time is outside UNIX
103 ;;; 32-bit time_t and a timezone wasn't passed
104 (decode-universal-time 0 nil)
106 ;;; ENCODE-UNIVERSAL-TIME should be able to encode the universal time
107 ;;; 0 when passed a representation in a timezone where the
108 ;;; representation of 0 as a decoded time is in 1899.
109 (encode-universal-time 0 0 23 31 12 1899 1)
111 ;;; DISASSEMBLE shouldn't fail on purified functions
112 (disassemble 'cl:+)
113 (disassemble 'sb-ext:run-program)
115 ;;; minimal test of GC: see stress-gc.{sh,lisp} for a more
116 ;;; comprehensive test.
117 (loop repeat 2
118 do (compile nil '(lambda (x) x))
119 do (sb-ext:gc :full t))