or.lsp 1.25 KB
Newer Older
pfdietz's avatar
pfdietz committed
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
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Fri Oct 18 07:29:27 2002
;;;; Contains: Tests of OR

(in-package :cl-test)

(deftest or.1
  (or)
  nil)

(deftest or.2
  (or nil)
  nil)

(deftest or.3
  (or 'a)
  a)

(deftest or.4
  (or (values 'a 'b 'c))
  a b c)

(deftest or.5 (or (values)))

(deftest or.6
  (or (values t nil) 'a)
  t)

(deftest or.7
  (or nil (values 'a 'b 'c))
  a b c)

(deftest or.8
  (let ((x 0))
    (values (or t (incf x))
sds's avatar
sds committed
37
            x))
pfdietz's avatar
pfdietz committed
38 39 40 41 42 43
  t 0)

(deftest or.9
  (or (values nil 1 2) (values 1 nil 2))
  1 nil 2)

44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
;;; Test that explicit calls to macroexpand in subforms
;;; are done in the correct environment

(deftest or.10
  (macrolet
   ((%m (z) z))
   (or (expand-in-current-env (%m 'x))
       (expand-in-current-env (%m nil))
       (expand-in-current-env (%m 'y))
       t))
  x)

(deftest or.11
  (macrolet
   ((%m (z) z))
   (or (expand-in-current-env (%m nil))
       (expand-in-current-env (%m 'a))
       nil))
sds's avatar
sds committed
62
  a)
63 64 65

;;; Error tests

66
(deftest or.error.1
67 68
  (signals-error (funcall (macro-function 'or)) program-error)
  t)
69 70

(deftest or.error.2
71 72
  (signals-error (funcall (macro-function 'or) '(or)) program-error)
  t)
73 74

(deftest or.error.3
75 76
  (signals-error (funcall (macro-function 'or) '(or) nil nil) program-error)
  t)