Skip to content

Instantly share code, notes, and snippets.

@MichaelDrogalis
Created August 10, 2012 13:22
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save MichaelDrogalis/1a69309438b44227e9ca to your computer and use it in GitHub Desktop.
(defmacro with-data
"Taken from a pull request of Clojure on GitHub.
Synonym of let. Use with ->> to provide binding after expressions (Haskell binding style)
Example:
(->> (+ x y) (where [x 3 y 2]))
which would expand to:
(let* [x 3 y 2] (+ x y))"
[& body]
`(let ~@body))
(defmacro with-specification [& bindings]
`(concat ~(vec bindings)
all ~(vec (flatten (partition 1 2 (rest bindings))))))
(->>
(fact (do-some-stuff-with-vars) => [my-expectations])
(with-data
(into [] (with-specification
my-expectations 1
b 2
c 2
d 4
e 5)))))))
; Exception in thread "main" java.lang.IllegalArgumentException: clojure.core/let requires a vector for its binding in job-record.test.service.job-record-service-test:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment