diff options
Diffstat (limited to 'tests/011')
-rw-r--r-- | tests/011/macros-1.expected | 2 | ||||
-rw-r--r-- | tests/011/macros-1.txr | 24 | ||||
-rw-r--r-- | tests/011/macros-2.expected | 12 | ||||
-rw-r--r-- | tests/011/macros-2.txr | 27 | ||||
-rw-r--r-- | tests/011/special-1.expected | 1 | ||||
-rw-r--r-- | tests/011/special-1.txr | 8 |
6 files changed, 74 insertions, 0 deletions
diff --git a/tests/011/macros-1.expected b/tests/011/macros-1.expected new file mode 100644 index 00000000..66039383 --- /dev/null +++ b/tests/011/macros-1.expected @@ -0,0 +1,2 @@ +((42) (a)) +((1 1) (2 3)) diff --git a/tests/011/macros-1.txr b/tests/011/macros-1.txr new file mode 100644 index 00000000..35b9d472 --- /dev/null +++ b/tests/011/macros-1.txr @@ -0,0 +1,24 @@ +@(do + (progn + (defmacro rem-num (:env menv some-form) + (let ((expanded (macroexpand some-form menv))) + (if (numberp (car expanded)) + (cdr expanded) + some-form))) + + (prinl + (macrolet ((foo () '(1 list 42)) + (bar () '(list 'a))) + (symacrolet ((x (bar))) + (list (rem-num (foo)) (rem-num x))))) + + (prinl + (let ((x 0)) + (symacrolet ((a (inc x))) + (list + (let* ((a a) + (b a)) + (list a b)) + (let ((a a) + (b a)) + (list a b)))))))) diff --git a/tests/011/macros-2.expected b/tests/011/macros-2.expected new file mode 100644 index 00000000..90fb118b --- /dev/null +++ b/tests/011/macros-2.expected @@ -0,0 +1,12 @@ +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +(block #:brk-blk-0004 (for nil ((< i 100) nil) nil (block #:cnt-blk-0003 (if (< (inc i) 20) (return-from #:cnt-blk-0003)) (if (> i 30) (return-from #:brk-blk-0004)) (prinl i)))) diff --git a/tests/011/macros-2.txr b/tests/011/macros-2.txr new file mode 100644 index 00000000..0d63a13b --- /dev/null +++ b/tests/011/macros-2.txr @@ -0,0 +1,27 @@ +@(do + (defmacro while ((condition : result) . body) + (let ((cblk (gensym "cnt-blk-")) + (bblk (gensym "brk-blk-"))) + '(macrolet ((break (value) '(return-from ,',bblk ,value))) + (symacrolet ((break (return-from ,bblk)) + (continue (return-from ,cblk))) + (block ,bblk + (for () (,condition ,result) () + (block ,cblk ,*body))))))) + + (let ((i 0)) + (while ((< i 100)) + (if (< (inc i) 20) + continue) + (if (> i 30) + break) + (prinl i))) + + (prinl + (sys:expand + '(while ((< i 100)) + (if (< (inc i) 20) + continue) + (if (> i 30) + break) + (prinl i))))) diff --git a/tests/011/special-1.expected b/tests/011/special-1.expected new file mode 100644 index 00000000..ce013625 --- /dev/null +++ b/tests/011/special-1.expected @@ -0,0 +1 @@ +hello diff --git a/tests/011/special-1.txr b/tests/011/special-1.txr new file mode 100644 index 00000000..7e51c483 --- /dev/null +++ b/tests/011/special-1.txr @@ -0,0 +1,8 @@ +@(do + (defmacro with-output-to-string ((var) . forms) + '(let ((,var (make-string-output-stream))) + (progn ,*forms (get-string-from-stream ,var)))) + + (let ((x (with-output-to-string (*stdout*) + (format t "hello")))) + (put-line x))) |