File: loop4.lsp

package info (click to toggle)
cl-ansi-tests 20071218-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 7,000 kB
  • ctags: 22,025
  • sloc: lisp: 134,798; makefile: 144
file content (108 lines) | stat: -rw-r--r-- 1,990 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sun Oct 27 22:46:39 2002
;;;; Contains: Tests for LOOP FOR-AS-EQUAL-THEN

(in-package :cl-test)

(deftest loop.4.1
  (loop
   for x = 1 then (1+ x)
   until (> x 5)
   collect x)
  (1 2 3 4 5))

(deftest loop.4.2
  (loop
   for i from 1 to 10
   for j = (1+ i) collect j)
  (2 3 4 5 6 7 8 9 10 11))

(deftest loop.4.3
  (loop
   for i from 1 to 10
   for j of-type integer = (1+ i) collect j)
  (2 3 4 5 6 7 8 9 10 11))

(deftest loop.4.4
  (loop for e on '(a b c d e)
	for (x . y) = e
	collect x)
  (a b c d e))

(deftest loop.4.5
  (loop for (x . y) = '(a b c d e) then y
	while x
	collect x)
  (a b c d e))

;;; Error cases

(deftest loop.4.6
  (signals-error
   (loop for (x . x) = '(nil nil nil)
	 until x count t)
   program-error)
  t)

(deftest loop.4.7
  (signals-error
   (macroexpand '(loop for (x . x) = '(nil nil nil)
		       until x count t))
   program-error)
  t)

(deftest loop.4.8
  (signals-error
   (macroexpand '(loop for x = '(nil nil nil)
		       for x = 1 count x until t))
   program-error)
  t)

;;; Test that explicit calls to macroexpand in subforms
;;; are done in the correct environment

(deftest loop.4.9
  (macrolet
   ((%m (z) z))
   (loop
    for x = (expand-in-current-env (%m 1)) then (1+ x)
    until (> x 5)
    collect x))
  (1 2 3 4 5))

(deftest loop.4.10
  (macrolet
   ((%m (z) z))
   (loop
    for x = 1 then (expand-in-current-env (%m (1+ x)))
    until (> x 5)
    collect x))
  (1 2 3 4 5))

(deftest loop.4.11
  (macrolet
   ((%m (z) z))
   (loop
    for x = 1 then (1+ x)
    until (expand-in-current-env (%m (> x 5)))
    collect x))
  (1 2 3 4 5))

(deftest loop.4.12
  (macrolet
   ((%m (z) z))
   (loop
    for x = 1 then (1+ x)
    while (expand-in-current-env (%m (<= x 5)))
    collect x))
  (1 2 3 4 5))

(deftest loop.4.13
  (macrolet
   ((%m (z) z))
   (loop
    for x = 1 then (1+ x)
    until (> x 5)
    collect (expand-in-current-env (%m x))))
  (1 2 3 4 5))