You can use `call-with-values' and wrap it in a helper:

#lang racket
(require rackunit)

(define (call-with-values->list p . args)
  (call-with-values (λ()(apply p args)) list))

(define (some-proc x y)
  (values y x))

(check-equal? (call-with-values->list some-proc 2 1)
              (list 1 2))


(Usually I abbreviate `call-with-values->list' to `cvl'.)
I wonder why there is not something similar in the main distribution though.

Laurent


On Sun, Oct 6, 2013 at 5:51 PM, Manfred Lotz <[email protected]> wrote:

> Hi there,
> Assume a function which returns values. I couldn't find anything in
> rackunit to test such a function out of the box.
>
> Simple example:
>
> (define (mval)
>   (values 1 2 3))
>
>
> Now I like to test it using rackunit. The only idea I have is:
>
>   (let-values ([(x y z) (mval)])
>     (check-equal? (list x y z) (list 1 2 3)))
>
> Works fine. However, I can imagine this could be done better and/or
> easier.
>
>
> --
> Manfred
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to