Better handling of children deletion in delete-lambda.
[sbcl.git] / tests / vector.pure.lisp
blob8e63d6aaaa3ae1381208327e41f4558ef4037bf5
1 ;;;; This software is part of the SBCL system. See the README file for
2 ;;;; more information.
3 ;;;;
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
6 ;;;; from CMU CL.
7 ;;;;
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)
15 (funcall (lambda ()
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
22 :adjustable t
23 :element-type '(unsigned-byte 32)))
24 (complex-character (make-array 14
25 :element-type 'character
26 :fill-pointer t)))
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)
43 (fill-pointer a)
44 (<= (array-total-size a) 5)))
45 (assert (= fp1 5))
46 (assert (= index 5))
47 (assert (= fp2 6))
48 (assert (not bool))))
50 (with-test (:name :svref-unknown-type)
51 (compile nil `(lambda (a)
52 (declare ((vector undefined-type) a))
53 (svref a 0)))
54 (compile nil `(lambda (a)
55 (declare ((vector undefined-type) a))
56 (setf (svref a 0) 10))))
58 (with-test (:name :svref-negative-index)
59 (let ((vector #(1)))
60 (flet ((test (index)
61 (funcall (compile nil `(lambda (vector index)
62 (svref vector index)))
63 vector index)))
64 (assert-error (test -1))
65 (assert (= (test 0) 1))
66 (assert-error (test 1)))))
68 (with-test (:name :fill-pointer-transform)
69 (assert-error
70 (funcall (checked-compile `(lambda (x)
71 (setf (fill-pointer x) 0)))
72 (make-array 2 :adjustable t))
73 type-error))