source: trunk/source/tests/ansi-tests/maplist.lsp @ 8991

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

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

File size: 3.1 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sun Apr 20 07:24:00 2003
4;;;; Contains: Tests of MAPLIST
5
6(in-package :cl-test)
7
8(compile-and-load "cons-aux.lsp")
9
10(deftest maplist.1
11  (maplist #'list nil)
12  nil)
13
14(deftest maplist.2
15  (let* ((x (copy-list '(a b c)))
16         (xcopy (make-scaffold-copy x))
17         (result (maplist #'identity x)))
18    (and (check-scaffold-copy x xcopy)
19         result))
20  ((a b c) (b c) (c)))
21
22(deftest maplist.3
23  (let* ((x (copy-list '(a b c d)))
24         (y (copy-list '(1 2 3 4)))
25         (xcopy (make-scaffold-copy x))
26         (ycopy (make-scaffold-copy y))
27         (result
28          (maplist #'append x y)))
29    (and
30     (check-scaffold-copy x xcopy)
31     (check-scaffold-copy y ycopy)
32     result))
33  ((a b c d 1 2 3 4)
34   (b c d 2 3 4)
35   (c d 3 4)
36   (d 4)))
37
38(deftest maplist.4
39  (let* ((x (copy-list '(a b c d)))
40         (y (copy-list '(1 2 3 4 5)))
41         (xcopy (make-scaffold-copy x))
42         (ycopy (make-scaffold-copy y))
43         (result
44          (maplist #'append x y)))
45    (and
46     (check-scaffold-copy x xcopy)
47     (check-scaffold-copy y ycopy)
48     result))
49  ((a b c d 1 2 3 4 5)
50   (b c d 2 3 4 5)
51   (c d 3 4 5)
52   (d 4 5)))
53
54(deftest maplist.5
55  (let* ((x (copy-list '(a b c d e)))
56         (y (copy-list '(1 2 3 4)))
57         (xcopy (make-scaffold-copy x))
58         (ycopy (make-scaffold-copy y))
59         (result
60          (maplist #'append x y)))
61    (and
62     (check-scaffold-copy x xcopy)
63     (check-scaffold-copy y ycopy)
64     result))
65  ((a b c d e 1 2 3 4)
66   (b c d e 2 3 4)
67   (c d e 3 4)
68   (d e 4)))
69
70(deftest maplist.6
71  (maplist 'append '(a b c) '(1 2 3))
72  ((a b c 1 2 3) (b c 2 3) (c 3)))
73
74(deftest maplist.7
75  (maplist #'(lambda (x y) (nth (car x) y))
76           '(0 1 0 1 0 1 0)
77           '(a b c d e f g)
78           )
79  (a c c e e g g))
80
81(deftest maplist.order.1
82  (let ((i 0) x y z)
83    (values
84     (maplist
85      (progn
86        (setf x (incf i))
87        #'(lambda (x y) (declare (ignore x)) (car y)))
88      (progn
89        (setf y (incf i))
90        '(a b c))
91      (progn
92        (setf z (incf i))
93             '(1 2 3)))
94     i x y z))
95  (1 2 3) 3 1 2 3)
96
97(def-fold-test maplist.fold.1 (maplist 'car '(a b c d e)))
98(def-fold-test maplist.fold.2 (maplist #'cadr '(a b c d e)))
99
100;;; Error tests
101
102(deftest maplist.error.1
103  (check-type-error #'(lambda (x) (maplist #'identity x)) #'listp)
104  nil)
105
106(deftest maplist.error.2
107  (signals-error (maplist #'identity 1) type-error)
108  t)
109
110(deftest maplist.error.3
111  (signals-error (maplist #'identity 1.1323) type-error)
112  t)
113
114(deftest maplist.error.4
115  (signals-error (maplist #'identity "abcde") type-error)
116  t)
117
118(deftest maplist.error.5
119  (signals-error (maplist) program-error)
120  t)
121
122(deftest maplist.error.6
123  (signals-error (maplist #'append) program-error)
124  t)
125
126(deftest maplist.error.7
127  (signals-error (locally (maplist #'identity 'a) t) type-error)
128  t)
129
130(deftest maplist.error.8
131  (signals-error (maplist #'caar '(a b c)) type-error)
132  t)
133
134(deftest maplist.error.9
135  (signals-error (maplist #'cons '(a b c)) program-error)
136  t)
137
138(deftest maplist.error.10
139  (signals-error (maplist #'cons '(a b c) '(1 2 3) '(4 5 6))
140                 program-error)
141  t)
142
143(deftest maplist.error.11
144  (signals-error (maplist #'identity (list* (list 1) (list 2) 3))
145                 type-error)
146  t)
147
148
Note: See TracBrowser for help on using the repository browser.