/[gcl]/gcl/ansi-tests/loop9.lsp
ViewVC logotype

Diff of /gcl/ansi-tests/loop9.lsp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by pfdietz, Fri Nov 15 12:34:41 2002 UTC revision 1.2 by pfdietz, Sun Nov 17 03:33:17 2002 UTC
# Line 1  Line 1 
1  ;-*- Mode:     Lisp -*-  ;-*- Mode:     Lisp -*-
2  ;;;; Author:   Paul Dietz  ;;;; Author:   Paul Dietz
3  ;;;; Created:  Thu Nov 14 06:25:21 2002  ;;;; Created:  Thu Nov 14 06:25:21 2002
4  ;;;; Contains: Tests for loop value accumulation clauses  ;;;; Contains: Tests for loop list accumulation clauses
5    
6  (in-package :cl-test)  (in-package :cl-test)
7    
# Line 73  Line 73 
73           finally (return foo)))           finally (return foo)))
74    program-error)    program-error)
75    
76    (deftest loop.9.12
77      (let ((foo '(a b)))
78        (values
79         (loop for x in '(c d e) collect x into foo finally (return foo))
80         foo))
81      (c d e)
82      (a b))
83    
84  ;;; Tests of APPEND, APPENDING  ;;; Tests of APPEND, APPENDING
85    
# Line 92  Line 99 
99    (loop for x in '((a) (b) (c . whatever)) appending x)    (loop for x in '((a) (b) (c . whatever)) appending x)
100    (a b c . whatever))    (a b c . whatever))
101    
102  ;;; More to go here  (deftest loop.9.24
103      (loop for x in '(a b c d)
104            append (list x)
105            when (eq x 'b) append '(1 2 3)
106            when (eq x 'd) appending '(4 5 6))
107      (a b 1 2 3 c d 4 5 6))
108    
109    (deftest loop.9.25
110      (let (z)
111        (values
112         (loop for x in '((a) (b) (c) (d))
113               append x into foo
114               finally (setq z foo))
115         z))
116      nil
117      (a b c d))
118    
119    (deftest loop.9.26
120      (loop for x in '((a) (b) (c) (d))
121            for i from 1
122            append x into foo
123            append x into foo
124            appending (list i) into foo
125            finally (return foo))
126      (a a 1 b b 2 c c 3 d d 4))
127    
128    (deftest loop.9.27
129      (classify-error
130       (loop with foo = '(a b)
131             for x in '(c d) append (list x) into foo
132             finally (return foo)))
133      program-error)
134    
135    (deftest loop.9.28
136      (classify-error
137       (loop with foo = '(a b)
138             for x in '(c d) appending (list x) into foo
139             finally (return foo)))
140      program-error)
141    
142    
143    ;;; NCONC, NCONCING
144    
145    (deftest loop.9.30
146      (loop for x in '((a b) (c d) (e f g) () (i)) nconc (copy-seq x))
147      (a b c d e f g i))
148    
149    (deftest loop.9.31
150      (loop for x in '((a b) (c d) (e f g) () (i)) nconcing (copy-seq x))
151      (a b c d e f g i))
152    
153    (deftest loop.9.32
154      (loop for x in '((a) (b) (c . whatever)) nconc (copy-seq x))
155      (a b c . whatever))
156    
157    (deftest loop.9.33
158      (loop for x in '((a) (b) (c . whatever)) nconcing (copy-seq x))
159      (a b c . whatever))
160    
161    (deftest loop.9.34
162      (loop for x in '(a b c d)
163            nconc (list x)
164            when (eq x 'b) nconc (copy-seq '(1 2 3))
165            when (eq x 'd) nconcing (copy-seq '(4 5 6)))
166      (a b 1 2 3 c d 4 5 6))
167    
168    (deftest loop.9.35
169      (let (z)
170        (values
171         (loop for x in '((a) (b) (c) (d))
172               nconc (copy-seq x) into foo
173               finally (setq z foo))
174         z))
175      nil
176      (a b c d))
177    
178    (deftest loop.9.36
179      (loop for x in '((a) (b) (c) (d))
180            for i from 1
181            nconc (copy-seq x) into foo
182            nconc (copy-seq x) into foo
183            nconcing (list i) into foo
184            finally (return foo))
185      (a a 1 b b 2 c c 3 d d 4))
186    
187    (deftest loop.9.37
188      (classify-error
189       (loop with foo = '(a b)
190             for x in '(c d) nconc (list x) into foo
191             finally (return foo)))
192      program-error)
193    
194    (deftest loop.9.38
195      (classify-error
196       (loop with foo = '(a b)
197             for x in '(c d) nconcing (list x) into foo
198             finally (return foo)))
199      program-error)
200    
201    ;;; Combinations
202    
203    (deftest loop.9.40
204      (loop for x in '(1 2 3 4 5 6 7)
205            if (< x 2) append (list x)
206            else if (< x 5) nconc (list (1+ x))
207            else collect (+ x 2))
208      (1 3 4 5 7 8 9))
209    
210    (deftest loop.9.41
211      (loop for x in '(1 2 3 4 5 6 7)
212            if (< x 2) append (list x) into foo
213            else if (< x 5) nconc (list (1+ x)) into foo
214            else collect (+ x 2) into foo
215            finally (return foo))
216      (1 3 4 5 7 8 9))

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26