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

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

I already thanked Jay, but his help was not sufficient for my ignorance.

Here's my latest attempt:

#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 blah@ foo@ expected)
  (define-unit-binding the-foo@
    foo@
    (import (tag blah@ blah^))
    (export (tag foo@ foo^)))

  (check-equal? (to-string) expected))

The problem is that to-string isn't recognized, so I need to invoke
the unit and have the function inside it be available.

I think I'm close...

Todd

On Tue, May 11, 2010 at 9:16 AM, Jay McCarthy <jay.mccarthy at gmail.com> wrote:
> 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
>


Posted on the users mailing list.