Yeah, that is very nice! (It should begin with "check" not "test" tho, right?)<div><br></div><div>Robby<br><br>On Monday, November 19, 2012, Matthias Felleisen wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
That is cute. Why don't you just create a pull request and Ryan can integrate it into rackunit? -- Matthias<br>
<br>
<br>
<br>
<br>
<br>
On Nov 19, 2012, at 4:22 PM, Joe Gibbs Politz wrote:<br>
<br>
> A small suggestion:<br>
><br>
> 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:<br>
><br>
> (define-syntax test/match<br>
> (syntax-rules ()<br>
> [(test/match actual expected pred)<br>
> (let ([actual-val actual])<br>
> (with-check-info* (list (make-check-actual actual-val)<br>
> (make-check-expected 'expected))<br>
> (thunk (check-true (match actual-val<br>
> [expected pred]<br>
> [_ false])))))]<br>
><br>
> [(test/match actual expected)<br>
> (test/match actual expected true)]))<br>
><br>
> Shriram remarked that he was surprised some sort of check-match wasn't in rackunit already. Is it worth adding something like this?<br>
><br>
> I'm doing things like:<br>
><br>
> (test/match (parse "5 'foo'") (s-block _ (list (s-num _ 5) (s-str _ "foo"))))<br>
><br>
> 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.<br>
><br>
> The actual use is at:<br>
><br>
> <a href="https://github.com/brownplt/pyret-lang/blob/master/src/tests/parse-tests.rkt#L36" target="_blank">https://github.com/brownplt/pyret-lang/blob/master/src/tests/parse-tests.rkt#L36</a><br>
><br>
> That file would be much, much uglier without this macro.<br>
><br>
> Cheers,<br>
> Joe P.<br>
><br>
> _________________________<br>
> Racket Developers list:<br>
> <a href="http://lists.racket-lang.org/dev" target="_blank">http://lists.racket-lang.org/dev</a><br>
<br>
</blockquote></div>