Commit c3342f17 authored by pfdietz's avatar pfdietz

Added tests for IF, UNLESS, WHEN, and CASE.

parent d2bd9e5a
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Fri Oct 18 19:56:44 2002
;;;; Contains: Tests of CASE
(in-package :cl-test)
(deftest case.1
(case 'a)
nil)
(deftest case.2
(case 10 (10 'a))
a)
(deftest case.3
(case (copy-seq "abc") ("abc" 'a))
nil)
(deftest case.4
(case 'z ((a b c) 1)
((d e) 2)
((f z g) 3)
(t 4))
3)
(deftest case.5
(case (1+ most-positive-fixnum)
(#.(1+ most-positive-fixnum) 'a))
a)
(deftest case.6
(case nil (nil 'a) (t 'b))
b)
(deftest case.7
(case nil ((nil) 'a) (t 'b))
a)
(deftest case.8
(case 'a (b 0) (a (values 1 2 3)) (t nil))
1 2 3)
(deftest case.9
(case 'c (b 0) (a (values 1 2 3)) (t (values 'x 'y 'z)))
x y z)
(deftest case.10
(case 'z (b 1) (a 2) (z (values)) (t nil)))
(deftest case.11
(case 'z (b 1) (a 2) (t (values))))
(deftest case.12
(case t (a 10))
nil)
(deftest case.13
(case t ((t) 10) (t 20))
10)
(deftest case.14
(let ((x (list 'a 'b)))
(eval `(case (quote ,x) ((,x) 1) (t 2))))
1)
(deftest case.15
(case 'otherwise ((t) 10))
nil)
(deftest case.16
(case t ((otherwise) 10))
nil)
(deftest case.17
(case 'a (b 0) (c 1) (otherwise 2))
2)
(deftest case.18
(case 'a (b 0) (c 1) ((otherwise) 2))
nil)
(deftest case.19
(case 'a (b 0) (c 1) ((t) 2))
nil)
(deftest case.20
(case #\a
((#\b #\c) 10)
((#\d #\e #\A) 20)
(() 30)
((#\z #\a #\y) 40))
40)
......@@ -14,6 +14,7 @@
(load "and.lsp")
(load "block.lsp")
(load "call-arguments-limit.lsp")
(load "case.lsp")
(load "catch.lsp")
(load "constantly.lsp")
(load "complement.lsp")
......@@ -33,6 +34,7 @@
(load "function.lsp")
(load "functionp.lsp")
(load "identity.lsp")
(load "if.lsp")
(load "labels.lsp")
(load "lambda-list-keywords.lsp")
(load "lambda-parameters-limit.lsp")
......@@ -47,7 +49,10 @@
(load "some.lsp")
(load "t.lsp")
(load "tagbody.lsp")
(load "unless.lsp")
(load "unwind-protect.lsp")
(load "when.lsp")
;;; Tests of conses
......
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Fri Oct 18 08:21:29 2002
;;;; Contains: Tests for IF
(in-package :cl-test)
(deftest if.1
(if t 1 2)
1)
(deftest if.2
(if nil 1 2)
2)
(deftest if.3 (if t (values) 'a))
(deftest if.4
(if nil 'a)
nil)
(deftest if.5
(if t (values 'a 'b 'c) 'd)
a b c)
(deftest if.6
(if nil 'a (values 'b 'c 'd))
b c d)
(deftest if.7 (if nil 'a (values)))
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Fri Oct 18 19:39:34 2002
;;;; Contains: Tests of UNLESS
(in-package :cl-test)
(deftest unless.1
(unless t)
nil)
(deftest unless.2
(unless nil)
nil)
(deftest unless.3
(unless 'b 'a)
nil)
(deftest unless.4
(unless nil 'a)
a)
(deftest unless.5 (unless nil (values)))
(deftest unless.6
(unless nil (values 1 2 3 4))
1 2 3 4)
(deftest unless.7
(unless 1 (values))
nil)
(deftest unless.8
(unless #() (values 1 2 3 4))
nil)
(deftest unless.9
(let ((x 0))
(values
(unless nil
(incf x)
'a)
x))
a 1)
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Fri Oct 18 19:36:57 2002
;;;; Contains: Tests of WHEN
(in-package :cl-test)
(deftest when.1
(when t)
nil)
(deftest when.2
(when nil 'a)
nil)
(deftest when.3 (when t (values)))
(deftest when.4
(when t (values 'a 'b 'c 'd))
a b c d)
(deftest when.5
(when nil (values))
nil)
(deftest when.6
(when nil (values 'a 'b 'c 'd))
nil)
(deftest when.7
(let ((x 0))
(values
(when t (incf x) 'a)
x))
a 1)
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