source: trunk/source/tests/ansi-tests/macroexpand-1.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.6 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sat May 28 13:47:32 2005
4;;;; Contains: Tests of MACROEXPAND-1
5
6(in-package :cl-test)
7
8(deftest macroexpand-1.error.1
9  (signals-error (macroexpand-1) program-error)
10  t)
11
12(deftest macroexpand-1.error.2
13  (signals-error (macroexpand-1 'x nil nil) program-error)
14  t)
15
16;;; Non-error tests
17
18(deftest macroexpand-1.1
19  (check-predicate
20   #'(lambda (x)
21       (or (symbolp x) (consp x)
22           (let ((vals (multiple-value-list (macroexpand-1 x))))
23             (and (= (length vals) 2)
24                  (eql (car vals) x)
25                  (null (cadr vals)))))))
26  nil)
27
28(deftest macroexpand-1.2
29  (check-predicate
30   #'(lambda (x)
31       (or (symbolp x) (consp x)
32           (let ((vals (multiple-value-list (macroexpand-1 x nil))))
33             (and (= (length vals) 2)
34                  (eql (car vals) x)
35                  (null (cadr vals)))))))
36  nil)
37
38(deftest macroexpand-1.3
39  (macrolet
40      ((%m (&environment env)
41           `(quote
42             ,(check-predicate
43               #'(lambda (x)
44                   (or (symbolp x) (consp x)
45                       (let ((vals (multiple-value-list (macroexpand-1 x env))))
46                         (and (= (length vals) 2)
47                              (eql (car vals) x)
48                              (null (cadr vals))))))))))
49    (%m))
50  nil)
51
52(deftest macroexpand-1.4
53  (macrolet ((%m () ''foo))
54    (macrolet ((%m2 (&environment env)
55                    (macroexpand-1 '(%m) env)))
56      (%m2)))
57  foo)
58
59(deftest macroexpand-1.5
60  (let ((form (list (gensym)))
61        (i 0))
62    (values
63     (equalt (macroexpand-1 (progn (incf i) form)) form)
64     i))
65  t 1)
66
67(deftest macroexpand-1.6
68  (let ((form (list (gensym)))
69        (i 0) a b)
70    (values
71     (equalt (macroexpand-1 (progn (setf a (incf i)) form)
72                            (progn (setf b (incf i)) nil))
73             form)
74     i a b))
75  t 2 1 2)
Note: See TracBrowser for help on using the repository browser.