On 29/07/14 04:58, Alex Shinn wrote:
> On Mon, Jul 28, 2014 at 10:09 PM, John Cowan <[email protected]
> <mailto:[email protected]>> wrote:
>
> Alex Shinn scripsit:
>
> > If people think it's useful I'd consider walking pairs and vectors.
>
> They are the most important cases, because the expected value is
> expressed as a literal value, and that can only be a list or vector.
>
>
> Actually, the expected value can be anything. Literals
> may be the more common case though.
As an interesting case in point, I have written a bunch of tests for
procedures that have side-effects (where all I'm testing is that they
don't raise any conditions or whatever) of the form:
(test "Do foo" (void) (do-foo! ...))
...which works, because I make sure I return (void) rather than some
arbitrary expression from my side-effecting procedures!
I've also thrown together a few macros for a common case - I have a
constructor that makes an (opaque) object, and I want to test that the
construction doesn't raise conditions, while keeping the value for later
use. I do it with:
(define-syntax test-define
(syntax-rules ()
((_ var expr)
(test-define (->string '(define var expr)) var expr))
((_ name var expr)
(begin
(define var (void))
(test-no-errors name (set! var expr))))))
(define-syntax test-define-values
(syntax-rules ()
((_ (var ...) expr)
(test-define-values (->string '(define-values (var ...) expr)) (var
...) expr))
((_ name (var ...) expr)
(begin
(define var (void)) ...
(test-no-errors name (set!-values (var ...) expr))))))
Then I can do the likes of:
(test-define "Create key-stream writer" ksw (make-key-stream-writer* a
'test-ks))
(test-define-values "Close key-stream writer" (ks-hash ks-reused?)
((key-stream-writer-finish! ksw)))
ABS
--
Alaric Snell-Pym
http://www.snell-pym.org.uk/alaric/
_______________________________________________
Chicken-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-users