[plt-scheme] parameterized test-suites with units?

From: Todd O'Bryan (toddobryan at gmail.com)
Date: Tue May 11 09:13:43 EDT 2010

The example below is illustrative:

Basically, I have two signatures with units that satisfy them. To test
the units, I link them and use standard Scheme Unit tests.

#lang scheme
(require schemeunit)

(define-signature blah^
  ((contracted
    [get-value (-> any/c)])))

(define-signature foo^
  ((contracted
    [to-string (-> string?)])))

(define-unit blah1@
  (import)
  (export blah^)

  (define (get-value)
    3))

(define-unit foo@
  (import blah^)
  (export foo^)

  (define (to-string)
    (format "~a" (get-value))))

(define-values/invoke-unit/infer
  (export foo^)
  (link blah1@ foo@))

(check-equal? (as-string) "3")

Unfortunately, I have multiple implementations of the same signature
and want to test all of them.

(define-unit blah2@
  (import)
  (export blah^)

  (define (get-value)
    'x))

What I'd like to do is something like

(define (make-foo-test-suite blah@ expected-value)
   ...)

so I could do

(define blah1 at -test (make-foo-test-suite blah1@ "3")
(define blah2 at -test (make-foo-test-suite blah2@ "x")

Unfortunately, I can't replace the ... in make-foo-test-suite with

(define-values/invoke-unit/infer
  (export foo^)
  (link blah@ foo@))

because the (link ...) part expects blah@ not to be a formal
parameter. Clearly I want to use something other than
(define-values/invoke-unit/infer ...). Unfortunately, I can't figure
out what it is that I want to use. :-)

Any help?

Thanks,
Todd


Posted on the users mailing list.