[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^
    [get-value (-> any/c)])))

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

(define-unit blah1@
  (export blah^)

  (define (get-value)

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

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

  (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@
  (export blah^)

  (define (get-value)

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

  (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?


Posted on the users mailing list.