source: trunk/source/tests/ansi-tests/define-modify-macro.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: 2.6 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sat Oct 19 11:42:14 2002
4;;;; Contains: Tests of DEFINE-MODIFY-MACRO
5
6(in-package :cl-test)
7
8(deftest define-modify-macro.1
9  (values
10   (eval '(define-modify-macro dmm1-appendf (&rest args)
11            append "Append lists onto a list"))
12   (eval
13    '(let ((u '(p q r)) v)
14       (list
15        (setq v u)
16        (dmm1-appendf u '(a b c d))
17        (dmm1-appendf u ())
18        (dmm1-appendf u '(e f g))
19        u
20        v))))
21  dmm1-appendf
22  ((p q r)
23   (p q r a b c d)
24   (p q r a b c d)
25   (p q r a b c d e f g)
26   (p q r a b c d e f g)
27   (p q r)))
28
29(deftest define-modify-macro.2
30  (values
31   (eval '(define-modify-macro new-incf (&optional (delta 1)) +))
32   (eval
33    '(let ((i 10))
34       (list
35        (new-incf i)
36        (new-incf i 100)
37        i))))
38  new-incf
39  (11 111 111))
40
41(deftest define-modify-macro.3
42  (values
43   (eval '(define-modify-macro new-incf1 (&optional (delta 1)) +))
44   (eval
45    '(let ((a (vector 0 0 0 0 0))
46           (i 1))
47       (list
48        (new-incf1 (aref a (incf i)))
49        a
50        i))))
51  new-incf1
52  (1 #(0 0 1 0 0) 2))
53
54(deftest define-modify-macro.4
55  (values
56   (eval '(define-modify-macro new-incf2 (&optional (delta 1)) +))
57   (eval
58    '(let ((a (vector 0 0 0 0 0))
59           (i 1))
60       (list
61        (new-incf2 (aref a (incf i)) (incf i))
62        a
63        i))))
64  new-incf2
65  (3 #(0 0 3 0 0) 3))
66
67;;; (deftest define-modify-macro.error.1
68;;;   (signals-error (define-modify-macro)  program-error)
69;;;   t)
70;;;
71;;; (deftest define-modify-macro.error.2
72;;;   (signals-error (define-modify-macro dfm-error-1) program-error)
73;;;   t)
74;;;
75;;; (deftest define-modify-macro.error.3
76;;;   (signals-error (define-modify-macro dfm-error-2 ()) program-error)
77;;;   t)
78;;;
79;;; (deftest define-modify-macro.error.4
80;;;   (signals-error (define-modify-macro dfm-error-2 () nil "Documentation"
81;;;                 "extra illegal argument")
82;;;                   program-error)
83;;;   t)
84
85(def-macro-test define-modify-macro.error.1
86  (define-modify-macro nonexistent-modify-macro () foo))
87
88;;; Documentation tests
89
90(deftest define-modify-macro.documentation.1
91  (let ((sym (gensym)))
92    (eval `(define-modify-macro ,sym (&optional (delta 1)) +))
93    (values
94     (documentation sym 'function)
95     (documentation (macro-function sym) 'function)
96     (documentation (macro-function sym) t)))
97  nil nil nil)
98
99(deftest define-modify-macro.documentation.2
100  (let ((sym (gensym))
101        (doc "DMM-DOC"))
102    (eval `(define-modify-macro ,sym (&optional (delta 1)) + ,doc))
103    (values
104     (equalt doc (or (documentation sym 'function) doc))
105     (equalt doc (or (documentation (macro-function sym) 'function) doc))
106     (equalt doc (or (documentation (macro-function sym) t) doc))))
107  t t t)
Note: See TracBrowser for help on using the repository browser.