-
Notifications
You must be signed in to change notification settings - Fork 4
/
and.lsp
84 lines (66 loc) · 1.43 KB
/
and.lsp
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
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Fri Oct 18 07:23:48 2002
;;;; Contains: Tests for AND
(in-package :cl-test)
(deftest and.1
(and)
t)
(deftest and.2
(and nil)
nil)
(deftest and.3
(and 'a)
a)
(deftest and.4
(and (values 'a 'b 'c))
a b c)
(deftest and.5 (and (values)))
(deftest and.6
(and (values t nil) 'a)
a)
(deftest and.7
(and nil (values 'a 'b 'c))
nil)
(deftest and.8
(and (values 1 nil) (values nil 2))
nil 2)
(deftest and.9
(and (values nil t) t)
nil)
;;; Test that explicit calls to macroexpand in subforms
;;; are done in the correct environment
(deftest and.10
(macrolet
((%m (z) z))
(and (expand-in-current-env (%m :a))
(expand-in-current-env (%m :b))
(expand-in-current-env (%m :c))))
:c)
;;; Error tests
(deftest and.order.1
(let ((x 0))
(values (and nil (incf x))
x))
nil 0)
(deftest and.order.2
(let ((i 0) a b c d)
(values
(and (setf a (incf i))
(setf b (incf i))
(setf c (incf i))
(setf d (incf i)))
i a b c d))
4 4 1 2 3 4)
(deftest and.error.1
(signals-error (funcall (macro-function 'and))
program-error)
t)
(deftest and.error.2
(signals-error (funcall (macro-function 'and) '(and))
program-error)
t)
(deftest and.error.3
(signals-error (funcall (macro-function 'and) '(and) nil nil)
program-error)
t)