Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Karsten Poeck
ansi-test
Commits
870ca24b
Commit
870ca24b
authored
Nov 17, 2002
by
pfdietz
Browse files
Added more tests for LOOP clauses, mostly REPEAT, WHILE, UNTIL, THEREIS, ALWAYS, and NEVER.
parent
c78b0070
Changes
4
Hide whitespace changes
Inline
Side-by-side
ansi-tests/gclload2.lsp
View file @
870ca24b
...
...
@@ -84,6 +84,8 @@
(load "loop8.lsp")
(load "loop9.lsp")
(load "loop10.lsp")
(load "loop11.lsp")
(load "loop12.lsp")
;;; Tests of conses
...
...
ansi-tests/loop10.lsp
View file @
870ca24b
...
...
@@ -94,6 +94,10 @@
counting x into foo
collect foo)
(1 2 2 3 3 4))
(deftest loop.10.14
(loop for x in '(a b c) count (return 10))
10)
;;; Tests of MAXIMIZE, MAXIMIZING
...
...
@@ -194,6 +198,10 @@
program-error)
(deftest loop.10.39
(loop for x in '(1 2 3) maximize (return 10))
10)
;;; Tests of MINIMIZE, MINIMIZING
(deftest loop.10.40
...
...
@@ -291,6 +299,10 @@
finally (return foo)))
program-error)
(deftest loop.10.58a
(loop for x in '(1 2 3) minimize (return 10))
10)
;;; Tests combining MINIMIZE, MAXIMIZE
(deftest loop.10.59
...
...
@@ -428,3 +440,11 @@
sum (float (1+ i)) into bar float
finally (return (values foo bar)))
10 14.0)
(deftest loop.10.92
(loop for i from 1 to 4 sum (return 100))
100)
(deftest loop.10.93
(loop for i from 1 to 4 summing (return 100))
100)
ansi-tests/loop11.lsp
0 → 100644
View file @
870ca24b
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sat Nov 16 21:39:33 2002
;;;; Contains: Tests for loop termination clauses REPEAT, WHILE and UNTIL
(in-package :cl-test)
;;; Tests of REPEAT
(deftest loop.11.1
(let ((z 0))
(values
(loop repeat 10 do (incf z))
z))
nil
10)
(deftest loop.11.2
(loop repeat 10 collect 'a)
(a a a a a a a a a a))
(deftest loop.11.3
(let ((z 0))
(loop repeat 0 do (incf z))
z)
0)
(deftest loop.11.4
(let ((z 0))
(loop repeat -1 do (incf z))
z)
0)
(deftest loop.11.5
(let ((z 0))
(loop repeat -1.5 do (incf z))
z)
0)
(deftest loop.11.6
(let ((z 0))
(loop repeat -1000000000000 do (incf z))
z)
0)
(deftest loop.11.7
(let ((z 0))
(loop repeat 10 do (incf z) (loop-finish))
z)
1)
(deftest loop.11.8
(loop repeat 3 for i in '(a b c d e) collect i)
(a b c))
(deftest loop.11.9
(loop for i in '(a b c d e) collect i repeat 3)
(a b c))
;;; Tests of WHILE
(deftest loop.11.10
(loop with i = 0 while (< i 10) collect (incf i))
(1 2 3 4 5 6 7 8 9 10))
(deftest loop.11.11
(loop with i = 0 while (if (< i 10) t (return 'good))
collect (incf i))
good)
(deftest loop.11.12
(loop with i = 0
while (< i 10) collect (incf i)
while (< i 10) collect (incf i)
while (< i 10) collect (incf i))
(1 2 3 4 5 6 7 8 9 10))
(deftest loop.11.13
(loop with i = 0 while (< i 10) collect (incf i)
finally (return 'done))
done)
(deftest loop.11.14
(loop for i in '(a b c)
while nil
collect i)
nil)
(deftest loop.11.15
(loop for i in '(a b c)
collect i
while nil)
(a))
(deftest loop.11.16
(loop for i in '(a b c)
while t
collect i)
(a b c))
(deftest loop.11.17
(loop for i in '(a b c)
collect i
while t)
(a b c))
(deftest loop.11.18
(loop for i from 1 to 10
while (< i 6)
finally (return i))
6)
;;; Tests of UNTIL
(deftest loop.11.20
(loop with i = 0 until (>= i 10) collect (incf i))
(1 2 3 4 5 6 7 8 9 10))
(deftest loop.11.21
(loop with i = 0 while (if (< i 10) t (return 'good))
collect (incf i))
good)
(deftest loop.11.22
(loop with i = 0
until (>= i 10) collect (incf i)
until (>= i 10) collect (incf i)
until (>= i 10) collect (incf i))
(1 2 3 4 5 6 7 8 9 10))
(deftest loop.11.23
(loop with i = 0 until (>= i 10) collect (incf i)
finally (return 'done))
done)
(deftest loop.11.24
(loop for i in '(a b c)
until t
collect i)
nil)
(deftest loop.11.25
(loop for i in '(a b c)
collect i
until t)
(a))
(deftest loop.11.26
(loop for i in '(a b c)
until nil
collect i)
(a b c))
(deftest loop.11.27
(loop for i in '(a b c)
collect i
until nil)
(a b c))
(deftest loop.11.28
(loop for i from 1 to 10
until (>= i 6)
finally (return i))
6)
ansi-tests/loop12.lsp
0 → 100644
View file @
870ca24b
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sun Nov 17 08:47:43 2002
;;;; Contains: Tests for ALWAYS, NEVER, THEREIS
(in-package :cl-test)
;;; Tests of ALWAYS clauses
(deftest loop.12.1
(loop for i in '(1 2 3 4) always (< i 10))
t)
(deftest loop.12.2
(loop for i in nil always nil)
t)
(deftest loop.12.3
(loop for i in '(a) always nil)
nil)
(deftest loop.12.4
(loop for i in '(1 2 3 4 5 6 7)
always t
until (> i 5))
t)
(deftest loop.12.5
(loop for i in '(1 2 3 4 5 6 7)
always (< i 6)
until (>= i 5))
t)
(deftest loop.12.6
(loop for x in '(a b c d e) always x)
t)
(deftest loop.12.7
(loop for x in '(1 2 3 4 5 6)
always (< x 20)
never (> x 10))
t)
(deftest loop.12.8
(loop for x in '(1 2 3 4 5 6)
always (< x 20)
never (> x 5))
nil)
(deftest loop.12.9
(loop for x in '(1 2 3 4 5 6)
never (> x 5)
always (< x 20))
nil)
(deftest loop.12.10
(loop for x in '(1 2 3 4 5)
always (< x 10)
finally (return 'good))
good)
(deftest loop.12.11
(loop for x in '(1 2 3 4 5)
always (< x 3)
finally (return 'bad))
nil)
(deftest loop.12.12
(loop for x in '(1 2 3 4 5 6)
always t
when (= x 4) do (loop-finish))
t)
(deftest loop.12.13
(loop for x in '(1 2 3 4 5 6)
do (loop-finish)
always nil)
t)
;;; Tests of NEVER
(deftest loop.12.21
(loop for i in '(1 2 3 4) never (> i 10))
t)
(deftest loop.12.22
(loop for i in nil never t)
t)
(deftest loop.12.23
(loop for i in '(a) never t)
nil)
(deftest loop.12.24
(loop for i in '(1 2 3 4 5 6 7)
never nil
until (> i 5))
t)
(deftest loop.12.25
(loop for i in '(1 2 3 4 5 6 7)
never (>= i 6)
until (>= i 5))
t)
(deftest loop.12.26
(loop for x in '(a b c d e) never (not x))
t)
(deftest loop.12.30
(loop for x in '(1 2 3 4 5)
never (>= x 10)
finally (return 'good))
good)
(deftest loop.12.31
(loop for x in '(1 2 3 4 5)
never (>= x 3)
finally (return 'bad))
nil)
(deftest loop.12.32
(loop for x in '(1 2 3 4 5 6)
never nil
when (= x 4) do (loop-finish))
t)
(deftest loop.12.33
(loop for x in '(1 2 3 4 5 6)
do (loop-finish)
never t)
t)
;;; Tests of THEREIS
(deftest loop.12.41
(loop for x in '(1 2 3 4 5)
thereis (and (eqlt x 3) 'good))
good)
(deftest loop.12.42
(loop for x in '(nil nil a nil nil)
thereis x)
a)
(deftest loop.12.43
(loop for x in '(1 2 3 4 5)
thereis (eql x 4)
when (eql x 2) do (loop-finish))
nil)
;;; Error cases
(deftest loop.12.error.50
(classify-error
(loop for i from 1 to 10
collect i
always (< i 20)))
program-error)
(deftest loop.12.error.51
(classify-error
(loop for i from 1 to 10
collect i
never (> i 20)))
program-error)
(deftest loop.12.error.52
(classify-error
(loop for i from 1 to 10
collect i
thereis (> i 20)))
program-error)
(deftest loop.12.53
(loop for i from 1 to 10
collect i into foo
always (< i 20))
t)
(deftest loop.12.54
(loop for i from 1 to 10
collect i into foo
never (> i 20))
t)
(deftest loop.12.55
(loop for i from 1 to 10
collect i into foo
thereis i)
1)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment