Adding underscore macro tests.

This commit is contained in:
Alex Shinn 2014-09-04 08:02:41 +09:00
parent 1857b80bc8
commit 524edc0660

View file

@ -439,6 +439,26 @@
(be-like-begin3 sequence3) (be-like-begin3 sequence3)
(test 5 (sequence3 2 3 4 5)) (test 5 (sequence3 2 3 4 5))
;; underscore
(define-syntax count-to-2
(syntax-rules ()
((_) 0)
((_ _) 1)
((_ _ _) 2)
((_ . _) 'many)))
(test '(2 0 many)
(list (count-to-2 a b) (count-to-2) (count-to-2 a b c d)))
(define-syntax count-to-2_
(syntax-rules (_)
((_) 0)
((_ _) 1)
((_ _ _) 2)
((x . y) 'fail)))
(test '(2 0 fail fail)
(list (count-to-2_ _ _) (count-to-2_)
(count-to-2_ a b) (count-to-2_ a b c d)))
(define-syntax jabberwocky (define-syntax jabberwocky
(syntax-rules () (syntax-rules ()
((_ hatter) ((_ hatter)