source: trunk/source/tests/ansi-tests/fill-pointer.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 12 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 1.8 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Tue Jan 21 22:14:23 2003
4;;;; Contains: Tests of FILL-POINTER
5
6(in-package :cl-test)
7
8;;; More tests are in make-array.lsp
9
10(deftest fill-pointer.1
11  (fill-pointer (make-array '(10) :fill-pointer 5))
12  5)
13
14(deftest fill-pointer.2
15  (fill-pointer (make-array '(10) :fill-pointer t))
16  10)
17
18(deftest fill-pointer.3
19  (let ((a (make-array '(10) :fill-pointer 5
20                       :initial-contents '(1 2 3 4 5 6 7 8 9 10))))
21    (values
22     (fill-pointer a)
23     (setf (fill-pointer a) 6)
24     a))
25  5 6 #(1 2 3 4 5 6))
26
27(deftest fill-pointer.order.1
28  (let ((i 0)
29        (a (make-array '(10) :fill-pointer 5)))
30    (values
31     (fill-pointer (progn (incf i) a))
32     i))
33  5 1)
34
35(deftest fill-pointer.order.2
36  (let ((i 0) x y
37        (a (make-array '(10) :fill-pointer 5
38                       :initial-contents '(1 2 3 4 5 6 7 8 9 10))))
39    (values
40     i
41     (setf (fill-pointer (progn (setf x (incf i)) a))
42           (progn (setf y (incf i)) 6))
43     a
44     i x y))
45  0 6 #(1 2 3 4 5 6) 2 1 2)
46
47;;; Error tests
48
49(deftest fill-pointer.error.1
50  (signals-error (fill-pointer) program-error)
51  t)
52
53(deftest fill-pointer.error.2
54  (signals-error (fill-pointer (make-array '(10) :fill-pointer 4) nil)
55                 program-error)
56  t)
57
58(deftest fill-pointer.error.3
59  (let ((a (make-array '(10) :fill-pointer nil)))
60    (if (array-has-fill-pointer-p a)
61        t
62      (eval `(signals-error (fill-pointer ',a) type-error))))
63  t)
64
65(deftest fill-pointer.error.4
66  (signals-error (fill-pointer #0aNIL) type-error)
67  t)
68
69(deftest fill-pointer.error.5
70  (signals-error (fill-pointer #2a((a b c)(d e f))) type-error)
71  t)
72
73(deftest fill-pointer.error.6
74  (check-type-error #'fill-pointer #'(lambda (x) (and (vectorp x)
75                                                      (array-has-fill-pointer-p x))))
76  nil)
77
78(deftest fill-pointer.error.7
79  (signals-error (locally (fill-pointer #2a((a b c)(d e f))) t)
80                 type-error)
81  t)
Note: See TracBrowser for help on using the repository browser.