source: trunk/source/tests/ansi-tests/loop7.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: 6.2 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Mon Nov 11 21:40:05 2002
4;;;; Contains: Tests for FOR-AS-PACKAGE clause for LOOP
5
6(in-package :cl-test)
7
8(defpackage "LOOP.CL-TEST.1"
9  (:use)
10  (:intern "FOO" "BAR" "BAZ")
11  (:export "A" "B" "C"))
12
13(defpackage "LOOP.CL-TEST.2"
14  (:use "LOOP.CL-TEST.1")
15  (:intern "X" "Y" "Z"))
16
17(deftest loop.7.1
18  (sort (mapcar #'symbol-name
19                (loop for x being the symbols of "LOOP.CL-TEST.1" collect x))
20        #'string<)
21  ("A" "B" "BAR" "BAZ" "C" "FOO"))
22
23(deftest loop.7.2
24  (sort (mapcar #'symbol-name
25                (loop for x being each symbol of "LOOP.CL-TEST.1" collect x))
26        #'string<)
27  ("A" "B" "BAR" "BAZ" "C" "FOO"))
28
29(deftest loop.7.3
30  (sort (mapcar #'symbol-name
31                (loop for x being the symbol of "LOOP.CL-TEST.1" collect x))
32        #'string<)
33  ("A" "B" "BAR" "BAZ" "C" "FOO"))
34
35(deftest loop.7.4
36  (sort (mapcar #'symbol-name
37                (loop for x being each symbols of "LOOP.CL-TEST.1" collect x))
38        #'string<)
39  ("A" "B" "BAR" "BAZ" "C" "FOO"))
40
41(deftest loop.7.5
42  (sort (mapcar #'symbol-name
43                (loop for x being the symbols in "LOOP.CL-TEST.1" collect x))
44        #'string<)
45  ("A" "B" "BAR" "BAZ" "C" "FOO"))
46
47(deftest loop.7.6
48  (sort (mapcar #'symbol-name
49                (loop for x being each symbol in "LOOP.CL-TEST.1" collect x))
50        #'string<)
51  ("A" "B" "BAR" "BAZ" "C" "FOO"))
52
53(deftest loop.7.7
54  (sort (mapcar #'symbol-name
55                (loop for x being the symbol in "LOOP.CL-TEST.1" collect x))
56        #'string<)
57  ("A" "B" "BAR" "BAZ" "C" "FOO"))
58
59(deftest loop.7.8
60  (sort (mapcar #'symbol-name
61                (loop for x being each symbols in "LOOP.CL-TEST.1" collect x))
62        #'string<)
63  ("A" "B" "BAR" "BAZ" "C" "FOO"))
64
65(deftest loop.7.9
66  (sort (mapcar #'symbol-name
67                (loop for x being the external-symbols of "LOOP.CL-TEST.1" collect x))
68        #'string<)
69  ("A" "B" "C"))
70
71(deftest loop.7.10
72  (sort (mapcar #'symbol-name
73                (loop for x being each external-symbol in "LOOP.CL-TEST.1" collect x))
74        #'string<)
75  ("A" "B" "C"))
76
77(deftest loop.7.11
78  (sort (mapcar #'symbol-name
79                (loop for x being each external-symbol in (find-package "LOOP.CL-TEST.1") collect x))
80        #'string<)
81  ("A" "B" "C"))
82
83(deftest loop.7.12
84  (sort (mapcar #'symbol-name
85                (loop for x being each external-symbol in :LOOP.CL-TEST.1 collect x))
86        #'string<)
87  ("A" "B" "C"))
88
89(deftest loop.7.13
90  (sort (mapcar #'symbol-name
91                (loop for x being the symbols of "LOOP.CL-TEST.2" collect x))
92        #'string<)
93  ("A" "B" "C" "X" "Y" "Z"))
94
95(deftest loop.7.14
96  (sort (mapcar #'symbol-name
97                (loop for x being the present-symbols of "LOOP.CL-TEST.2" collect x))
98        #'string<)
99  ("X" "Y" "Z"))
100
101;;; According to the ANSI CL spec, "If the package for the iteration is not supplied,
102;;; the current package is used."  Thse next tests are of the cases that the package
103;;; is not supplied in the loop form.
104
105(deftest loop.7.15
106  (let ((*package* (find-package "LOOP.CL-TEST.1")))
107    (sort (mapcar #'symbol-name (loop for x being each symbol collect x))
108          #'string<))
109  ("A" "B" "BAR" "BAZ" "C" "FOO"))
110
111(deftest loop.7.16
112  (let ((*package* (find-package "LOOP.CL-TEST.1")))
113    (sort (mapcar #'symbol-name (loop for x being each external-symbol collect x))
114          #'string<))
115  ("A" "B" "C"))
116
117(deftest loop.7.17
118  (let ((*package* (find-package "LOOP.CL-TEST.2")))
119    (sort (mapcar #'symbol-name (loop for x being each present-symbol collect x))
120          #'string<))
121  ("X" "Y" "Z"))
122
123;;; Cases where the package doesn't exist.  According to the standard,
124;;; (section 6.1.2.1.7), this should cause a pacakge-error.
125
126(deftest loop.7.18
127  (let ()
128    (ignore-errors (delete-package "LOOP.MISSING.PACKAGE"))
129    (signals-error
130     (loop for x being each symbol of "LOOP.MISSING.PACKAGE" collect x)
131     package-error))
132  t)
133
134(deftest loop.7.19
135  (let ()
136    (ignore-errors (delete-package "LOOP.MISSING.PACKAGE"))
137    (signals-error
138     (loop for x being each present-symbol of "LOOP.MISSING.PACKAGE"
139           collect x)
140     package-error))
141  t)
142
143(deftest loop.7.20
144  (let ()
145    (ignore-errors (delete-package "LOOP.MISSING.PACKAGE"))
146    (signals-error
147     (loop for x being each external-symbol of "LOOP.MISSING.PACKAGE"
148           collect x)
149     package-error))
150  t)
151
152;;; NIL d-var-specs
153
154(deftest loop.7.21
155  (loop for nil being the symbols of "LOOP.CL-TEST.1" count t)
156  6)
157   
158(deftest loop.7.22
159  (loop for nil being the external-symbols of "LOOP.CL-TEST.1" count t)
160  3)
161   
162(deftest loop.7.23
163  (loop for nil being the present-symbols of "LOOP.CL-TEST.2" count t)
164  3)
165
166;;; Type specs
167
168(deftest loop.7.24
169  (loop for x t being the symbols of "LOOP.CL-TEST.1" count x)
170  6)
171   
172(deftest loop.7.25
173  (loop for x t being the external-symbols of "LOOP.CL-TEST.1" count x)
174  3)
175   
176(deftest loop.7.26
177  (loop for x t being the present-symbols of "LOOP.CL-TEST.2" count x)
178  3)
179
180(deftest loop.7.27
181  (loop for x of-type symbol being the symbols of "LOOP.CL-TEST.1" count x)
182  6)
183   
184(deftest loop.7.28
185  (loop for x of-type symbol being the external-symbols of "LOOP.CL-TEST.1" count x)
186  3)
187   
188(deftest loop.7.29
189  (loop for x of-type symbol being the present-symbols of "LOOP.CL-TEST.2" count x)
190  3)
191
192;;; Tests of the 'as' form
193
194(deftest loop.7.30
195  (sort (mapcar #'symbol-name
196                (loop as x being the symbols of "LOOP.CL-TEST.1" collect x))
197        #'string<)
198  ("A" "B" "BAR" "BAZ" "C" "FOO"))
199
200(deftest loop.7.31
201  (sort (mapcar #'symbol-name
202                (loop as x being each symbol of "LOOP.CL-TEST.1" collect x))
203        #'string<)
204  ("A" "B" "BAR" "BAZ" "C" "FOO"))
205
206(deftest loop.7.32
207  (sort (mapcar #'symbol-name
208                (loop as x being the symbol of "LOOP.CL-TEST.1" collect x))
209        #'string<)
210  ("A" "B" "BAR" "BAZ" "C" "FOO"))
211
212;;; Test that explicit calls to macroexpand in subforms
213;;; are done in the correct environment
214
215(deftest loop.7.33
216  (macrolet
217   ((%m (z) z))
218   (sort (mapcar #'symbol-name
219                 (loop for x being the symbols of
220                       (expand-in-current-env (%m "LOOP.CL-TEST.1"))
221                       collect x))
222         #'string<))
223  ("A" "B" "BAR" "BAZ" "C" "FOO"))
224
225(deftest loop.7.34
226  (macrolet
227   ((%m (z) z))
228   (sort (mapcar #'symbol-name
229                 (loop for x being the external-symbols of
230                       (expand-in-current-env (%m "LOOP.CL-TEST.1"))
231                       collect x))
232         #'string<))
233  ("A" "B" "C"))
234
235(deftest loop.7.35
236  (macrolet
237   ((%m (z) z))
238   (sort (mapcar #'symbol-name
239                 (loop for x being the present-symbols of
240                       (expand-in-current-env (%m "LOOP.CL-TEST.2"))
241                       collect x))
242         #'string<))
243  ("X" "Y" "Z"))
Note: See TracBrowser for help on using the repository browser.