[plt-scheme] parameterized test-suites with units?
You want "define-unit-binding". That takes a unit expr, like blah@,
and gives it a static unit binding inside a new scope.
Jay
On Tue, May 11, 2010 at 7:13 AM, Todd O'Bryan <toddobryan at gmail.com> wrote:
> 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
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
--
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://teammccarthy.org/jay
"The glory of God is Intelligence" - D&C 93