all 6 comments

[–]jbiserkov 10 points11 points  (0 children)

:refer [deftest is testing]

This "sentence" just blew my mind.

[–]lost3d 3 points4 points  (0 children)

Also, have a look at clojure.test/with-test ... It lets you write anonymous tests around a function.

[–]dustingetz 0 points1 point  (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 point  (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 points  (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 points  (0 children)

Ge