Contracts mediate boundaries between parts of your program and sometimes tests should go across the boundary (to help test the contracts) and sometimes they should go inside (to test internal functions). You have to pick one or the other with a given test module tho.
Robby On Friday, May 22, 2015, Atticus <attic...@posteo.org> wrote: > That's good to know. That means my previous conclusion is wrong > and I'm not forced to use define/contract when using test submodules. > > Robby Findler <ro...@eecs.northwestern.edu <javascript:;>> writes: > > > For that kind of situation, you should consider writing your test > > submodule like this: > > > > #lang racket > > > > (define (add1 x y) > > (integer? integer? . -> . integer?) > > (+ x y)) > > > > (provide (contract-out [add1 (integer? integer? . -> . integer?)])) > > > > (module* test racket > > (require (submod "..")) > > (add1 #f #f)) > > > > > > Robby > > > > > > On Thu, May 21, 2015 at 10:58 PM, Matthew Butterick <m...@mbtype.com > <javascript:;>> wrote: > >>> Are there any advantages/disadvantages of using test submodules vs > >>> separate test files? Or is it just a matter of personal preference? > >>> > >>> It looks like that test submodules are more convenient and flexible but > >>> I observed that test submodules increase the start up time of racket > >>> scripts. > >> > >> > >> If you're using contracts, you want your tests to cross the contract > >> boundaries. If you attach your contracts at the module boundary (a > common > >> practice), then submodule tests will not trigger the contracts. (Example > >> below.) So putting these tests in a separate file is the better option. > >> > >> ;;;;; > >> #lang racket > >> > >> (define/contract (add1 x y) > >> (integer? integer? . -> . integer?) > >> (+ x y)) > >> > >> (provide (contract-out [add2 (integer? integer? . -> . integer?)])) > >> (define (add2 x y) > >> (+ x y)) > >> > >> (module+ test > >> (require rackunit) > >> (check-exn exn:fail? (λ _ (add1 20.5 21.5))) > >> (check-equal? (add2 20.5 21.5) 42.0)) ; surprise! > >> ;;;;; > >> > >> > >> > >> > >> -- > >> 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 <javascript:;>. > >> For more options, visit https://groups.google.com/d/optout. > > > > -- > > 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 <javascript:;>. > > For more options, visit https://groups.google.com/d/optout. > > -- > 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 <javascript:;>. > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.