Desidero estendere srfi-78 da una macro che verifica l'eccezione di sintassi. Voglio qualcosa del genere:Come rilevare l'eccezione di sintassi
#! /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))
È possibile a tutti? Altrimenti, come scriveresti i test per macrose?
So di test-read-eval-string
da srfi-64. Accetta una stringa, la traduce in un modulo e valuta questo modulo nell'ambiente iniziale. Voglio una macro che valuti la forma data nell'ambiente corrente e cattura le eccezioni.
che non dovrebbe funzionare per le macro come l'espansione delle macro va prima della valutazione del 'sicuro eval' – amakarov
Hm, funziona. Grazie. Cercherò di capire perché. – amakarov
Nota che il codice è quotato, quindi l'espansione avverrà solo in eval. – leppie