fill-pointer.lsp 1.46 KB
Newer Older
pfdietz's avatar
pfdietz committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Tue Jan 21 22:14:23 2003
;;;; Contains: Tests of FILL-POINTER

(in-package :cl-test)

;;; More tests are in make-array.lsp

(deftest fill-pointer.1
  (fill-pointer (make-array '(10) :fill-pointer 5))
  5)

(deftest fill-pointer.2
  (fill-pointer (make-array '(10) :fill-pointer t))
  10)

(deftest fill-pointer.3
  (let ((a (make-array '(10) :fill-pointer 5
		       :initial-contents '(1 2 3 4 5 6 7 8 9 10))))
    (values
     (fill-pointer a)
     (setf (fill-pointer a) 6)
     a))
  5 6 #(1 2 3 4 5 6))

pfdietz's avatar
pfdietz committed
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
;;; Error tests

(deftest fill-pointer.error.1
  (classify-error (fill-pointer))
  program-error)

(deftest fill-pointer.error.2
  (classify-error (fill-pointer (make-array '(10) :fill-pointer 4)
				nil))
  program-error)

(deftest fill-pointer.error.3
  (classify-error (fill-pointer (make-array '(10) :fill-pointer nil)))
  type-error)

(deftest fill-pointer.error.4
  (classify-error (fill-pointer #0aNIL))
  type-error)

(deftest fill-pointer.error.5
  (classify-error (fill-pointer #2a((a b c)(d e f))))
  type-error)

(deftest fill-pointer.error.6
  (let (why)
    (loop for e in *mini-universe*
	  when (and (or (not (typep e 'vector))
			(not (array-has-fill-pointer-p e)))
		    (not (eql (setq why (classify-error** `(fill-pointer ',e)))
			      'type-error)))
	  collect (list e why)))
  nil)
59
60
61
62

(deftest fill-pointer.error.7
  (classify-error (locally (fill-pointer #2a((a b c)(d e f))) t))
  type-error)