chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Using epsilon in test egg


From: Alaric Snell-Pym
Subject: Re: [Chicken-users] Using epsilon in test egg
Date: Wed, 30 Jul 2014 14:08:38 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130713 Thunderbird/17.0.7

On 29/07/14 04:58, Alex Shinn wrote:
> On Mon, Jul 28, 2014 at 10:09 PM, John Cowan <address@hidden
> <mailto:address@hidden>> 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/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]