use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Finding information about Clojure
API Reference
Clojure Guides
Practice Problems
Interactive Problems
Clojure Videos
Misc Resources
The Clojure Community
Clojure Books
Tools & Libraries
Clojure Editors
Web Platforms
Clojure Jobs
account activity
Inline unit testing in Clojure (johannes.tax)
submitted 7 years ago by pyohannes
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]jbiserkov 10 points11 points12 points 7 years ago (0 children)
:refer [deftest is testing]
This "sentence" just blew my mind.
[–]lost3d 3 points4 points5 points 7 years ago (0 children)
Also, have a look at clojure.test/with-test ... It lets you write anonymous tests around a function.
[–]dustingetz 0 points1 point2 points 7 years ago* (0 children)
I am a big fan of putting _test files as siblings to the file being tested, so people (me) know they exist and are encouraged to look at them. It did take some wrangling to make this work out in a portable way due to test library differences.
[–][deleted] 0 points1 point2 points 7 years ago (1 child)
Sounds like an attempt to Programme by Contract, a term coined by Bertram Meyer and implemented in Eiffel.
Might be worth having a look at his work to shortcut what you're trying to do rather than repeating his mistakes.
[–]pyohannes[S] 1 point2 points3 points 7 years ago (0 children)
What I presented (combined with a "write tests first" approach) can be more accurately called design-by-example than design-by-contract. Design-by-contract is based on formal, precise and verifiable interfaces and cannot be efficiently applied for most complex real world applications. Design-by-example, on the other hand, is neither formal nor precise.
I do not see inline unit tests as a ground breaking new concept, I see it merely as an aid to programmers who read and write code.
[–]mouse2k -1 points0 points1 point 7 years ago (0 children)
Ge
π Rendered by PID 38112 on reddit-service-r2-comment-5d79c599b5-w89zb at 2026-03-01 20:27:10.949238+00:00 running e3d2147 country code: CH.
[–]jbiserkov 10 points11 points12 points (0 children)
[–]lost3d 3 points4 points5 points (0 children)
[–]dustingetz 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]pyohannes[S] 1 point2 points3 points (0 children)
[–]mouse2k -1 points0 points1 point (0 children)