source: trunk/source/tests/ansi-tests/when.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 11 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 1.4 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Fri Oct 18 19:36:57 2002
4;;;; Contains: Tests of WHEN
5
6(in-package :cl-test)
7
8(deftest when.1
9  (when t)
10  nil)
11
12(deftest when.2
13  (when nil 'a)
14  nil)
15
16(deftest when.3 (when t (values)))
17
18(deftest when.4
19  (when t (values 'a 'b 'c 'd))
20  a b c d)
21
22(deftest when.5
23 (when nil (values))
24 nil)
25
26(deftest when.6
27  (when nil (values 'a 'b 'c 'd))
28  nil)
29
30(deftest when.7
31  (let ((x 0))
32    (values
33     (when t (incf x) 'a)
34     x))
35  a 1)
36
37;;; No implicit tagbody
38(deftest when.8
39  (block done
40    (tagbody
41     (when t
42       (go 10)
43       10
44       (return-from done 'bad))
45     10
46     (return-from done 'good)))
47  good)
48
49;;; Test that explicit calls to macroexpand in subforms
50;;; are done in the correct environment
51
52(deftest when.9
53  (macrolet
54   ((%m (z) z))
55   (when (expand-in-current-env (%m t)) :good))
56  :good)
57
58(deftest when.10
59  (macrolet
60   ((%m (z) z))
61   (when (expand-in-current-env (%m nil)) :bad))
62  nil)
63
64(deftest when.11
65  (macrolet
66   ((%m (z) z))
67   (let ((x t))
68     (values (when x (expand-in-current-env (%m (setf x 'foo)))) x)))
69  foo foo)
70
71;;; Error tests
72
73(deftest when.error.1
74  (signals-error (funcall (macro-function 'when)) program-error)
75  t)
76
77(deftest when.error.2
78  (signals-error (funcall (macro-function 'when)
79                           '(when t))
80                 program-error)
81  t)
82
83(deftest when.error.3
84  (signals-error (funcall (macro-function 'when)
85                           '(when t) nil nil)
86                 program-error)
87  t)
Note: See TracBrowser for help on using the repository browser.