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

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

Thank you, again!

For the enlightenment of other people who search later (including me,
when I forget how this works), here's the code that works:

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

  (define (get-value)
    'x))

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

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

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

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

(define (make-blah-test-suite name blah@ foo@ expected)
  (define-unit-binding the-blah@
    blah@
    (import)
    (export blah^))
  (define-unit-binding the-foo@
    foo@
    (import blah^)
    (export foo^))
  (define-values/invoke-unit/infer
    (export foo^)
    (link the-blah@ the-foo@))

  (test-suite name
    (check-equal? (to-string) expected)))

(define blah at 1-test-suite
  (make-blah-test-suite "blah1@ Test Suite" blah1@ foo1@ "3"))


Posted on the users mailing list.