source: trunk/source/tests/ansi-tests/symbol-macrolet.lsp @ 8991

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

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

File size: 1.8 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sat Jan  8 05:58:53 2005
4;;;; Contains: Tests of SYMBOL-MACROLET
5
6(in-package :cl-test)
7
8(deftest symbol-macrolet.1
9  (loop for s in *cl-non-variable-constant-symbols*
10        for form = `(ignore-errors (symbol-macrolet ((,s 17)) ,s))
11        unless (eql (eval form) 17)
12        collect s)
13  nil)
14
15(deftest symbol-macrolet.2
16  (symbol-macrolet ())
17  nil)
18
19(deftest symbol-macrolet.3
20  (symbol-macrolet () (declare (optimize)))
21  nil)
22
23(deftest symbol-macrolet.4
24  (symbol-macrolet ((x 1))
25    (symbol-macrolet ((x 2))
26      x))
27  2)
28
29(deftest symbol-macrolet.5
30  (let ((x 10))
31     (symbol-macrolet ((y x))
32       (list x
33             y
34             (let ((x 20)) x)
35             (let ((y 30)) x)
36             (let ((y 50)) y)
37             x
38             y)))
39  (10 10 20 10 50 10 10))
40
41(deftest symbol-macrolet.6
42  (symbol-macrolet () (values)))
43                       
44(deftest symbol-macrolet.7
45  (symbol-macrolet () (values 'a 'b 'c 'd 'e))
46  a b c d e)
47
48(deftest symbol-macrolet.8
49  (let ((x :good))
50    (declare (special x))
51    (let ((x :bad))
52      (symbol-macrolet () (declare (special x)) x)))
53  :good)
54
55;;; Error tests               
56
57(deftest symbol-macrolet.error.1
58  (signals-error
59   (symbol-macrolet ((x 10))
60     (declare (special x))
61     20)
62   program-error)
63  t)
64
65(defconstant constant-for-symbol-macrolet.error.2 nil)
66
67(deftest symbol-macrolet.error.2
68  (signals-error (symbol-macrolet ((constant-for-symbol-macrolet.error.2 'a))
69                   constant-for-symbol-macrolet.error.2)
70                 program-error)
71  t)
72
73(deftest symbol-macrolet.error.3
74  (signals-error (symbol-macrolet ((*pathnames* 19)) *pathnames*)
75                 program-error)
76  t)
77
78;;; Test that explicit calls to macroexpand in subforms
79;;; are done in the correct environment
80
81(deftest symbol-macrolet.9
82  (macrolet
83   ((%m (z) z))
84   (symbol-macrolet () (expand-in-current-env (%m :good))))
85  :good)
Note: See TracBrowser for help on using the repository browser.