Commit 97051cf7 authored by pfdietz's avatar pfdietz
Browse files

Added tests for PROG, PROG*, PROG1 and PROG2.

parent 170d55a8
...@@ -54,6 +54,10 @@ ...@@ -54,6 +54,10 @@
(load "notevery.lsp") (load "notevery.lsp")
(load "nth-value.lsp") (load "nth-value.lsp")
(load "or.lsp") (load "or.lsp")
(load "prog.lsp")
(load "prog1.lsp")
(load "prog2.lsp")
(load "progn.lsp")
(load "progv.lsp") (load "progv.lsp")
(load "some.lsp") (load "some.lsp")
(load "t.lsp") (load "t.lsp")
......
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sat Oct 19 09:21:57 2002
;;;; Contains: Tests of PROG
(in-package :cl-test)
(deftest prog.1
(prog ())
nil)
(deftest prog.2
(prog () 'a)
nil)
(deftest prog.3
(prog () (return 'a))
a)
(deftest prog.4
(prog () (return (values 1 2 3 4 5)))
1 2 3 4 5)
(deftest prog.5
(let ((x 'a))
(prog ((x 'b) (y x))
(declare (type symbol x y))
(return (values x y))))
b a)
(deftest prog.6
(let ((x 'a))
(prog (x) (setq x 'b))
x)
a)
(deftest prog.7
(prog ((i 1) (s 0))
(declare (type fixnum i s))
again
(when (> i 10) (return s))
(incf s i)
(incf i)
(go again))
55)
(deftest prog.8
(let ((x 0))
(prog ((y (incf x)) (z (incf x)))
(return (values x y z))))
2 1 2)
(deftest prog.9
(flet ((%f () (locally (declare (special z)) z)))
(prog ((z 10))
(declare (special z))
(return (%f))))
10)
(deftest prog.10
(prog ()
(return
(1+
(prog ()
(go end)
done
(return 1)
end
(go done))))
done
(return 'bad))
2)
;;; Tests of PROG*
(deftest prog*.1
(prog* ())
nil)
(deftest prog*.2
(prog* () 'a)
nil)
(deftest prog*.3
(prog* () (return 'a))
a)
(deftest prog*.4
(prog* () (return (values 1 2 3 4 5)))
1 2 3 4 5)
(deftest prog*.5
(let ((x 'a))
(prog* ((z x) (x 'b) (y x))
(declare (type symbol x y))
(return (values x y z))))
b b a)
(deftest prog*.6
(let ((x 'a))
(prog* (x) (setq x 'b))
x)
a)
(deftest prog*.7
(prog* ((i 1) (s 0))
(declare (type fixnum i s))
again
(when (> i 10) (return s))
(incf s i)
(incf i)
(go again))
55)
(deftest prog*.8
(let ((x 0))
(prog* ((y (incf x)) (z (incf x)))
(return (values x y z))))
2 1 2)
(deftest prog*.9
(flet ((%f () (locally (declare (special z)) z)))
(prog* ((z 10))
(declare (special z))
(return (%f))))
10)
(deftest prog*.10
(prog* ()
(return
(1+
(prog* ()
(go end)
done
(return 1)
end
(go done))))
done
(return 'bad))
2)
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sat Oct 19 09:37:14 2002
;;;; Contains: Tests for PROG1
(in-package :cl-test)
(deftest prog1.1
(prog1 'a)
a)
(deftest prog1.2
(prog1 'a 'b)
a)
(deftest prog1.3
(prog1 (values 'a 'b) 'c)
a)
(deftest prog1.4
(prog1 (values) 'c)
nil)
(deftest prog1.5
(let ((x 0))
(values (prog1 x (incf x)) x))
0 1)
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sat Oct 19 09:40:51 2002
;;;; Contains: Tests for PROG2
(in-package :cl-test)
(deftest prog2.1
(prog2 'a 'b)
b)
(deftest prog2.2
(prog2 'a 'b 'c)
b)
(deftest prog2.3
(prog2 'a (values) 'c)
nil)
(deftest prog2.4
(prog2 'a (values 'b 'd) 'c)
b)
(deftest prog2.5
(let ((x 0))
(values
(prog2 (incf x) (incf x) (incf x))
x))
2 3)
(deftest prog2.6
(let ((x 1))
(values
(prog2 (incf x (1+ x)) (incf x (+ 2 x)) (incf x 100))
x))
8 108)
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Sat Oct 19 09:33:51 2002
;;;; Contains: Tests of PROGN
(in-package :cl-test)
(deftest progn.1
(progn)
nil)
(deftest progn.2
(progn 'a)
a)
(deftest progn.3
(progn 'b 'a)
a)
(deftest progn.4
(let ((x 0))
(values (progn (incf x) x) x))
1 1)
(deftest progn.5 (progn (values)))
(deftest progn.6
(progn (values 1 2) (values 'a 'b 'c 'd 'e))
a b c d e)
(deftest progn.7
(let ((x 0))
(prog ()
(progn (go x) x 'a)
(return 'bad)
x
(return 'good)))
good)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment