構文例外をテストするマクロでsrfi-78を拡張したいと思います。私はこのようなものが欲しい:
#! /usr/bin/env scheme-script
#!r6rs
(import (rnrs) (srfi :78 lightweight-testing))
; the macros I want to test
(define-syntax some-macros
(syntax-rules ()
[(_) 'ok]))
; the extension to srfi-78
(define-syntax check-exception
(syntax-rules ()
; ... some code ...
))
; tests
; prints "correct" or someting like that
(check (some-macros) => 'ok)
; should print "correct" (i. e. the test passed)
(check-exception (some-macros 'arg))
; should print "error"
; (i. e. the exception was not thrown as expected)
(check-exception (some-macros))
それは可能ですか?そうでない場合、マクロのテストをどのように記述しますか?
test-read-eval-string
私はsrfi-64から知っています。文字列を受け入れ、それをフォームに変換し、初期環境でこのフォームを評価します。現在の環境で特定のフォームを評価し、例外をキャッチするマクロが必要です。