source: trunk/source/tests/ansi-tests/make-list.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: 2.3 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sat Apr 19 22:04:27 2003
4;;;; Contains: Tests of MAKE-LIST
5
6(in-package :cl-test)
7
8(compile-and-load "cons-aux.lsp")
9
10(deftest make-list-empty.1
11  (make-list 0)
12  nil)
13
14(deftest make-list-empty.2
15  (make-list 0 :initial-element 'a)
16  nil)
17
18(deftest make-list-no-initial-element
19  (make-list 6)
20  (nil nil nil nil nil nil))
21
22(deftest make-list-with-initial-element
23  (make-list 6 :initial-element 'a)
24  (a a a a a a))
25
26(deftest make-list.allow-other-keys.1
27  (make-list 5 :allow-other-keys t :foo 'a)
28  (nil nil nil nil nil))
29
30(deftest make-list.allow-other-keys.2
31  (make-list 5 :bar nil :allow-other-keys t)
32  (nil nil nil nil nil))
33
34(deftest make-list.allow-other-keys.3
35  (make-list 5 :allow-other-keys nil)
36  (nil nil nil nil nil))
37
38(deftest make-list.allow-other-keys.4
39  (make-list 5 :allow-other-keys t :allow-other-keys nil 'bad t)
40  (nil nil nil nil nil))
41
42(deftest make-list.allow-other-keys.5
43  (make-list 5 :allow-other-keys t)
44  (nil nil nil nil nil))
45
46(deftest make-list-repeated-keyword
47  (make-list 5 :initial-element 'a :initial-element 'b)
48  (a a a a a))
49
50(deftest make-list.order.1
51  (let ((i 0) x y)
52    (values
53     (make-list (progn (setf x (incf i)) 5)
54                :initial-element
55                (progn (setf y (incf i)) 'a))
56     i x y))
57  (a a a a a)
58  2 1 2)
59
60(deftest make-list.order.2
61  (let ((i 0) x y z)
62    (values
63     (make-list (progn (setf x (incf i)) 5)
64                :initial-element
65                (progn (setf y (incf i)) 'a)
66                :initial-element
67                (progn (setf z (incf i)) 'b))
68     i x y z))
69  (a a a a a)
70  3 1 2 3)
71
72(def-fold-test make-list.fold.1 (make-list 1))
73(def-fold-test make-list.fold.2 (make-list 10 :initial-element 'x))
74
75;;; Error tests
76
77(deftest make-list.error.1
78  (check-type-error #'make-list (typef 'unsigned-byte))
79  nil)
80
81(deftest make-list.error.3
82  (signals-error (make-list) program-error)
83  t)
84
85(deftest make-list.error.4
86  (signals-error (make-list 5 :bad t) program-error)
87  t)
88
89(deftest make-list.error.5
90  (signals-error (make-list 5 :initial-element) program-error)
91  t)
92
93(deftest make-list.error.6
94  (signals-error (make-list 5 1 2) program-error)
95  t)
96
97(deftest make-list.error.7
98  (signals-error (make-list 5 :bad t :allow-other-keys nil)
99                 program-error)
100  t)
101
102(deftest make-list.error.8
103  (signals-error (locally (make-list 'a) t) type-error)
104  t)
Note: See TracBrowser for help on using the repository browser.