My favorite poor-man's test-feedback-loop in Clojure is to use the built-in core.assert function to put tests at the bottom of the source file in combination with my editor's eval-buffer command.
Test DSLs, test directory/file boilerplate, and setting up an autorun cycle are the three things that constitute enough of a barrier to prevent me from testing, so those are the three things this example eludes.
Here's a file of a `to-slug` function that normalizes drug names into URL slugs.
;; Production code
...
(defn to-slug [s]
(hyphenize (simplify-name s)))
;; Tests
(defn assert-slug [a b] (assert (= (to-slug a) b)))
(assert-slug "ocusert pilo-20" "ocusert-pilo")
(assert-slug "ogen .625" "ogen")
(assert-slug "ogen 1.25" "ogen")
(assert-slug "hydralazine hydrochloride, hydrochlorothiazide and reserpine"
"hydralazine-hydrochloride")
(assert-slug "hydralazine hydrochloride w/ hydrochlorothiazide 100/50"
"hydralazine-hydrochloride")
;; Sandbox
(to-slug "00-d-amphetamine")
Every time I hit C-c C-k (eval-buffer in Emacs w/ nrepl), the asserts are run which will throw an error on failure.And since eval-buffer always returns the result of the last expression evaluated, the above "Sandbox" section represents whatever case I'm currently trying to extend `to-slug` support for. The result of which is returned on every eval-buffer.
In this case, `to-slug` doesn't correctly handle "00-d-amphetamine" yet, so as I modify the production code to handle it, I can mash eval-buffer after every change to (1) see if my change introduces regressions and (2) visualize my progress on handling "00-d-amphetamine". Once it works, I add an "00-d-amphetamine" assert-slug and move on to the next case.
As to-slug matures, I can then move the asserts to a dedicated test directory if I want to and replace the slime with minimal case tests. -- Things that otherwise slow down my exploration phase.
----
I think core.assert fills the chasm of a function's/file's lifecycle between "I'm not even sure if I want this function or what its input/output will look like" and "my source code definitely needs this and this is its API".
In Ruby, I like https://github.com/sconover/wrong.