[racket] inline unit tests

From: Laurent (laurent.orseau at gmail.com)
Date: Wed Jun 6 01:45:52 EDT 2012

One feature that could be helpful here is code folding. DrRacket could then
propose different "views" of one source file (e.g., code only, code+tests,
tests only, etc.).
Not sure how to do it though.


On Wed, Jun 6, 2012 at 12:51 AM, John Clements <clements at brinckerhoff.org>wrote:

> On Jun 5, 2012, at 1:01 PM, David Janke wrote:
> I just finished reading the blog post about the pre-release submodules
> feature, and I'm curious what you all think about the new "test" submodule
> that allows inline unit tests...
> "The new raco test shell command runs the test submodule of a given
> module, so that raco test fish2.rkt checks that all the values of the fish
> list are numbers. The test submodule imports rackunit for its check form,
> but that import does not create a dependency on rackunit (which is a
> substantial library) for modules that import "fish2.rkt"; the dependency is
> only for the test submodule."
> (http://blog.racket-lang.org/2012/06/submodules.html)
> At first glance, the test submodule sounds like a cool idea, because your
> tests can help document your functions. But, I can also imagine files where
> the number of tests outnumber the lines of actual code. Plus, there's
> something to be said for keeping different parts of an application
> separate--tests vs. "work"
> On the other hand, unless you explicitly run the tests, they are
> effectively just comments, so no real harm in having them interspersed with
> the rest of the code, right?
> I'm fairly new to Racket and just wondering what the thinking is in the
> community. Inline unit tests pop up here and there in other languages
> (Python has doctest), but it's not really widespread. Seeing how it's going
> to be part of the Racket core, maybe it's a technique I should start using?
> My opinion:
> It's very convenient to be able to place unit tests next to the functions
> that they test while developing code.  I agree that you may want to
> refactor later, and gather the tests together. Submodules (and more
> specifically module+) allow both of these.
> John
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120606/aa824915/attachment-0001.html>

Posted on the users mailing list.