1 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; While most of SBCL is derived from the CMU CL system, the test
5 ;;;; files (like this one) were written from scratch after the fork
8 ;;;; This software is in the public domain and is provided with
9 ;;;; absolutely no warranty. See the COPYING and CREDITS files for
10 ;;;; more information.
12 (cl:in-package
:cl-user
)
14 (with-test (:name
:length
)
16 (let ((simple-t (make-array 35))
17 (simple-u32 (make-array 50
18 :element-type
'(unsigned-byte 32)))
19 (simple-character (make-string 44))
20 (complex-t (make-array 4 :fill-pointer
3))
21 (complex-u32 (make-array 88
23 :element-type
'(unsigned-byte 32)))
24 (complex-character (make-array 14
25 :element-type
'character
27 (assert (= (length simple-t
) 35))
28 (assert (= (length simple-u32
) 50))
29 (assert (= (length simple-character
) 44))
30 (assert (= (length complex-t
) 3))
31 (assert (= (length complex-u32
) 88))
32 (assert (= (length complex-character
) 14))
33 (vector-push-extend #\a complex-t
)
34 (assert (= (length complex-t
) 4))
35 (assert-error (vector-push-extend #\b simple-t
))))))
37 (with-test (:name
:fill-pointer
)
38 (multiple-value-bind (fp1 index fp2 bool
)
39 (let ((a (make-array '(5) :fill-pointer
5 :adjustable
5
40 :initial-contents
'(a b c d e
))))
41 (values (fill-pointer a
)
42 (vector-push-extend 'x a
)
44 (<= (array-total-size a
) 5)))
50 (with-test (:name
:svref-unknown-type
)
51 (compile nil
`(lambda (a)
52 (declare ((vector undefined-type
) a
))
54 (compile nil
`(lambda (a)
55 (declare ((vector undefined-type
) a
))
56 (setf (svref a
0) 10))))
58 (with-test (:name
:svref-negative-index
)
61 (funcall (compile nil
`(lambda (vector index
)
62 (svref vector index
)))
64 (assert-error (test -
1))
65 (assert (= (test 0) 1))
66 (assert-error (test 1)))))
68 (with-test (:name
:fill-pointer-transform
)
70 (funcall (checked-compile `(lambda (x)
71 (setf (fill-pointer x
) 0)))
72 (make-array 2 :adjustable t
))