source: trunk/source/tests/ansi-tests/loop4.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.9 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sun Oct 27 22:46:39 2002
4;;;; Contains: Tests for LOOP FOR-AS-EQUAL-THEN
5
6(in-package :cl-test)
7
8(deftest loop.4.1
9  (loop
10   for x = 1 then (1+ x)
11   until (> x 5)
12   collect x)
13  (1 2 3 4 5))
14
15(deftest loop.4.2
16  (loop
17   for i from 1 to 10
18   for j = (1+ i) collect j)
19  (2 3 4 5 6 7 8 9 10 11))
20
21(deftest loop.4.3
22  (loop
23   for i from 1 to 10
24   for j of-type integer = (1+ i) collect j)
25  (2 3 4 5 6 7 8 9 10 11))
26
27(deftest loop.4.4
28  (loop for e on '(a b c d e)
29        for (x . y) = e
30        collect x)
31  (a b c d e))
32
33(deftest loop.4.5
34  (loop for (x . y) = '(a b c d e) then y
35        while x
36        collect x)
37  (a b c d e))
38
39;;; Error cases
40
41(deftest loop.4.6
42  (signals-error
43   (loop for (x . x) = '(nil nil nil)
44         until x count t)
45   program-error)
46  t)
47
48(deftest loop.4.7
49  (signals-error
50   (macroexpand '(loop for (x . x) = '(nil nil nil)
51                       until x count t))
52   program-error)
53  t)
54
55(deftest loop.4.8
56  (signals-error
57   (macroexpand '(loop for x = '(nil nil nil)
58                       for x = 1 count x until t))
59   program-error)
60  t)
61
62;;; Test that explicit calls to macroexpand in subforms
63;;; are done in the correct environment
64
65(deftest loop.4.9
66  (macrolet
67   ((%m (z) z))
68   (loop
69    for x = (expand-in-current-env (%m 1)) then (1+ x)
70    until (> x 5)
71    collect x))
72  (1 2 3 4 5))
73
74(deftest loop.4.10
75  (macrolet
76   ((%m (z) z))
77   (loop
78    for x = 1 then (expand-in-current-env (%m (1+ x)))
79    until (> x 5)
80    collect x))
81  (1 2 3 4 5))
82
83(deftest loop.4.11
84  (macrolet
85   ((%m (z) z))
86   (loop
87    for x = 1 then (1+ x)
88    until (expand-in-current-env (%m (> x 5)))
89    collect x))
90  (1 2 3 4 5))
91
92(deftest loop.4.12
93  (macrolet
94   ((%m (z) z))
95   (loop
96    for x = 1 then (1+ x)
97    while (expand-in-current-env (%m (<= x 5)))
98    collect x))
99  (1 2 3 4 5))
100
101(deftest loop.4.13
102  (macrolet
103   ((%m (z) z))
104   (loop
105    for x = 1 then (1+ x)
106    until (> x 5)
107    collect (expand-in-current-env (%m x))))
108  (1 2 3 4 5))
Note: See TracBrowser for help on using the repository browser.