A test no longer fails.
[sbcl.git] / tests / vector.pure.lisp
blob2770eadcde393d378547066605629c5e7858f713
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 (with-test (:name :length)
13 (funcall (lambda ()
14 (let ((simple-t (make-array 35))
15 (simple-u32 (make-array 50
16 :element-type '(unsigned-byte 32)))
17 (simple-character (make-string 44))
18 (complex-t (make-array 4 :fill-pointer 3))
19 (complex-u32 (make-array 88
20 :adjustable t
21 :element-type '(unsigned-byte 32)))
22 (complex-character (make-array 14
23 :element-type 'character
24 :fill-pointer t)))
25 (assert (= (length simple-t) 35))
26 (assert (= (length simple-u32) 50))
27 (assert (= (length simple-character) 44))
28 (assert (= (length complex-t) 3))
29 (assert (= (length complex-u32) 88))
30 (assert (= (length complex-character) 14))
31 (vector-push-extend #\a complex-t)
32 (assert (= (length complex-t) 4))
33 (assert-error (vector-push-extend #\b simple-t))))))
35 (with-test (:name :fill-pointer)
36 (multiple-value-bind (fp1 index fp2 bool)
37 (let ((a (make-array '(5) :fill-pointer 5 :adjustable 5
38 :initial-contents '(a b c d e))))
39 (values (fill-pointer a)
40 (vector-push-extend 'x a)
41 (fill-pointer a)
42 (<= (array-total-size a) 5)))
43 (assert (= fp1 5))
44 (assert (= index 5))
45 (assert (= fp2 6))
46 (assert (not bool))))
48 (with-test (:name :svref-unknown-type)
49 (compile nil `(lambda (a)
50 (declare ((vector undefined-type) a))
51 (svref a 0)))
52 (compile nil `(lambda (a)
53 (declare ((vector undefined-type) a))
54 (setf (svref a 0) 10))))
56 (with-test (:name :svref-negative-index)
57 (let ((vector #(1)))
58 (flet ((test (index)
59 (funcall (compile nil `(lambda (vector index)
60 (svref vector index)))
61 vector index)))
62 (assert-error (test -1))
63 (assert (= (test 0) 1))
64 (assert-error (test 1)))))
66 (with-test (:name :fill-pointer-transform)
67 (assert-error
68 (funcall (checked-compile `(lambda (x)
69 (setf (fill-pointer x) 0)))
70 (make-array 2 :adjustable t))
71 type-error))
73 (with-test (:name :concatenate-to-vector)
74 (assert (sb-kernel:%concatenate-to-vector sb-vm:simple-bit-vector-widetag
75 '(1 1) '(1 0))))