[racket-dev] check-match?

From: Shriram Krishnamurthi (sk at cs.brown.edu)
Date: Mon Nov 19 20:18:30 EST 2012

We use test in PLAI, and I suggested it in that context (eg,
unification, where you don't care about the gensym'ed names of logic
variables), which is probably why it got called that.

On Mon, Nov 19, 2012 at 8:01 PM, Robby Findler
<robby at eecs.northwestern.edu> wrote:
> Yeah, that is very nice! (It should begin with "check" not "test" tho,
> right?)
>
> Robby
>
>
> On Monday, November 19, 2012, Matthias Felleisen wrote:
>>
>>
>> That is cute. Why don't you just create a pull request and Ryan can
>> integrate it into rackunit? -- Matthias
>>
>>
>>
>>
>>
>> On Nov 19, 2012, at 4:22 PM, Joe Gibbs Politz wrote:
>>
>> > A small suggestion:
>> >
>> > I used roughly this macro (credit Jonah Kagan) recently to help me write
>> > some tests for parsing code that agnostic to which source position is
>> > generated in the parse:
>> >
>> > (define-syntax test/match
>> >   (syntax-rules ()
>> >     [(test/match actual expected pred)
>> >      (let ([actual-val actual])
>> >        (with-check-info* (list (make-check-actual actual-val)
>> >                                (make-check-expected 'expected))
>> >                          (thunk (check-true (match actual-val
>> >                                                 [expected pred]
>> >                                                 [_ false])))))]
>> >
>> >     [(test/match actual expected)
>> >      (test/match actual expected true)]))
>> >
>> > Shriram remarked that he was surprised some sort of check-match wasn't
>> > in rackunit already.  Is it worth adding something like this?
>> >
>> > I'm doing things like:
>> >
>> > (test/match (parse "5 'foo'") (s-block _ (list (s-num _ 5) (s-str _
>> > "foo"))))
>> >
>> > Where the structs s-block, s-num, and s-str all expect a srcloc as their
>> > first argument, but I don't care about it for these tests.
>> >
>> > The actual use is at:
>> >
>> >
>> > https://github.com/brownplt/pyret-lang/blob/master/src/tests/parse-tests.rkt#L36
>> >
>> > That file would be much, much uglier without this macro.
>> >
>> > Cheers,
>> > Joe P.
>> >
>> > _________________________
>> >  Racket Developers list:
>> >  http://lists.racket-lang.org/dev
>>
>
> _________________________
>   Racket Developers list:
>   http://lists.racket-lang.org/dev
>

Posted on the dev mailing list.