Check out `make-check-location` and friends, and maybe `with-check-info*` https://docs.racket-lang.org/rackunit/api.html?q=define-check#%28def._%28%28lib._rackunit%2Fmain..rkt%29._make-check-location%29%29
You may have to combine with the syntax-information extracted from the syntax object `stx`. On Thu, May 7, 2020 at 10:22 AM Dexter Lagan <dexterla...@gmail.com> wrote: > Hi, > > I made a simple macro which saves me the trouble of defining a test > module, requiring RackUnit and then declaring '(module+ test' after each > procedure definition, as I like to keep unit tests close by. The repo : > > https://github.com/DexterLagan/assert > > Here's the macro, apologies for the broken formatting : > > (define-syntax (assert stx) > (syntax-parse stx > [(_ ?a ?b) > #'(module+ test > (require rackunit) > (check-equal? ?a ?b #'?a))] > [(_ ?a) > #'(module+ test > (require rackunit) > (check-true ?a #'?a))])) > > The macro works great, and I was able to pipe through an assertion message > through rackunit's check-equal? and other procedures. > I have one question however: would there be a way to make DrRacket point > to the failed assertion line instead of the macro itself when a failure > occurs? Here's a screenshot of how it looks like at the moment: > > [image: assert.PNG] > > It would be even better if DrRacket highlighted the (assert ...) line > itself, but I'm asking a bit much :) If assert is an actual module, I'm not > sure where DrRacket would then point at. > I also have doubts about whenever Racket will remove the test module once > compiled. Since macros are processed at compile-time, I'm guessing it would > remove the test module right after, but let me know if you have a more > definite answer. > > Dex > > -- > 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. > To view this discussion on the web visit > https://groups.google.com/d/msgid/racket-users/CACUENrLX%3D9ix2kv9MNpp3nNoSN%3DsWBx%2BFTRdwNyNA7EiVWQ0mA%40mail.gmail.com > <https://groups.google.com/d/msgid/racket-users/CACUENrLX%3D9ix2kv9MNpp3nNoSN%3DsWBx%2BFTRdwNyNA7EiVWQ0mA%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CABNTSaFdxOGAFw9cZcPqVxb6pXFT68WMuCNMta8dBG5GeLW74A%40mail.gmail.com.