Re: [racket-users] catching a contract violation in a unit test with check-exn

2017-11-25 Thread Tim Hanson
Thanks again. I've tweaked and commented the end of Mathias's example: (module+ test (check-exn exn:fail:contract? (lambda () (f 1))) ; violates contract by returning non-integer (check-exn exn:fail:contract? (lambda () (f 'a ; violates contract by being called with a non-integer and

Re: [racket-users] catching a contract violation in a unit test with check-exn

2017-11-18 Thread Tim Hanson
Beautiful! Thanks to both of you. Can't wait to try it out. Cheers, Tim -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com

Re: [racket-users] catching a contract violation in a unit test with check-exn

2017-11-18 Thread Matthias Felleisen
Hers is what Sam means with an example: #lang racket (module+ test (require rackunit)) ;; --- in file (module server racket (provide (contract-out (f (-> integer? integer? (define (f x) (if (= x 1) "hello world" x))) ;; --- in text client (require 'server) (module+ te

Re: [racket-users] catching a contract violation in a unit test with check-exn

2017-11-18 Thread Sam Tobin-Hochstadt
The second argument to check-exn needs to be a thunk. Sam On Nov 18, 2017 7:32 AM, "Tim Hanson" wrote: > Hi, I guess this didn't find the right subject matter expert yet. Would it > be better to ask a specific person or use a different channel? > Cheers, tbh > > -- > You received this message b

[racket-users] catching a contract violation in a unit test with check-exn

2017-11-18 Thread Tim Hanson
Hi, I guess this didn't find the right subject matter expert yet. Would it be better to ask a specific person or use a different channel? Cheers, tbh -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiv

[racket-users] catching a contract violation in a unit test with check-exn

2017-11-12 Thread Tim Hanson
hi, As part of something I'm working on I want to convert a stream of values into a stream of pairs of values, e.g. 1 2 3 4 becomes (1 2) (3 4) The following seems to work fine: (define (pairwise-stream astream) (if (stream-empty? astream) empty-stream (stream-cons (c