Rob Browning <[email protected]> writes: > Tomas Volf <[email protected]> writes: > >> The specification basically just says that >> >> --8<---------------cut here---------------start------------->8--- >> (test-group suite-name decl-or-expr ...) >> >> Equivalent to: >> >> (if (not (test-to-skip% suite-name)) >> (dynamic-wind >> (lambda () (test-begin suite-name)) >> (lambda () decl-or-expr ...) >> (lambda () (test-end suite-name)))) >> --8<---------------cut here---------------end--------------->8--- > > I did wonder whether the "..." in the spec was meant as a formal macro > pattern, or meant it more informally, and perhaps didn't mean to allow > "none" such that > > (test-group-with-cleanup "foo" something) > > treats something as cleanup, which I suspect might more often hide a > mistake than anything else.
Your guess is as good as mine :) But I did read it as a formal macro pattern. Only use case I can think of for no body is to run the clean-up conditionally, based on current skip specifiers. But that seems pretty niche, and it is achievable by using #t for decl-or-expr, if required. > In any case, if it does mean for "..." to mean zero or more, and really > does intend the (lambda () declr-or-expr ...) expansion, then I wonder > if we could and might want to add an explicit error for "no body" > instead of expanding to (lambda ()), which currently fails in a more > mysterious way. For example: > > (define-syntax test-group > (syntax-rules () > ((_ suite-name) (syntax-error "Empty test-group body")) > ...)) > > We could also augment test-group-with-cleanup to do something similar > when there's no body. > > Alternately, I suppose we could consider allowing the empty body via an > expansion of (lambda () #f decl-or-expr ...) if we didn't think that was > forbidden. I think allowing this would mask bugs, even the GnuCash fixed it with "it revealed a couple of misplaced closing parens". I have no strong opinion on special-casing the missing test body, should I send a patch? Tomas -- There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.
signature.asc
Description: PGP signature
