Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
ansi-test
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michał Herda
ansi-test
Commits
a08f4b9f
Commit
a08f4b9f
authored
19 years ago
by
pfdietz
Browse files
Options
Downloads
Patches
Plain Diff
Begin adding non-error tests of DEFINE-COMPILE-MACRO
parent
b48cf534
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ansi-tests/define-compiler-macro.lsp
+62
-0
62 additions, 0 deletions
ansi-tests/define-compiler-macro.lsp
with
62 additions
and
0 deletions
ansi-tests/define-compiler-macro.lsp
+
62
−
0
View file @
a08f4b9f
...
...
@@ -24,3 +24,65 @@
nil nil)
program-error)
t)
;;; Non-error tests
(deftest define-compiler-macro.1
(let* ((sym (gensym))
(macro-def-form
`(define-compiler-macro ,sym (x y)
(declare (special *x*))
(setf *x* t)
`(+ ,x ,y 1)))
(fun-def-form
`(defun ,sym (x y) (+ x y 1))))
(values
(equalt (list sym) (multiple-value-list (eval fun-def-form)))
(equalt (list sym) (multiple-value-list (eval macro-def-form)))
(notnot (typep (compiler-macro-function sym) 'function))
(eval `(,sym 6 19))
(let ((fn (compile nil `(lambda (a b) (,sym a b)))))
(let ((*x* nil))
(declare (special *x*))
(list (funcall fn 12 123) *x*)))))
t t t 26 (136 nil))
(deftest define-compiler-macro.2
(let* ((sym (gensym))
(macro-def-form
`(define-compiler-macro ,sym (&whole form &rest args)
(declare (special *x*) (ignore args))
(setf *x* t)
(return-from ,sym form)))
(fun-def-form
`(defun ,sym (x) x)))
(values
(equalt (list sym) (multiple-value-list (eval fun-def-form)))
(equalt (list sym) (multiple-value-list (eval macro-def-form)))
(notnot (typep (compiler-macro-function sym) 'function))
(eval `(,sym 'a))
(let ((fn (compile nil `(lambda (a) (,sym a)))))
(let ((*x* nil))
(declare (special *x*))
(list (funcall fn 'b) *x*)))))
t t t a (b nil))
(deftest define-compiler-macro.3
(let* ((sym (gensym))
(macro-def-form
`(define-compiler-macro ,sym (&whole form &rest args)
(declare (special *x*) (ignore args))
(setf *x* t)
(return-from ,sym form)))
(ordinary-macro-def-form
`(defmacro ,sym (x) x)))
(values
(equalt (list sym) (multiple-value-list (eval ordinary-macro-def-form)))
(equalt (list sym) (multiple-value-list (eval macro-def-form)))
(notnot (typep (compiler-macro-function sym) 'function))
(eval `(,sym 'a))
(let ((fn (compile nil `(lambda (a) (,sym a)))))
(let ((*x* nil))
(declare (special *x*))
(list (funcall fn 'b) *x*)))))
t t t a (b nil))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment