added bindings

This commit is contained in:
jem 2019-05-28 08:43:23 +02:00
parent 9503aeddaf
commit 56276f2c18
2 changed files with 6 additions and 4 deletions

View file

@ -26,15 +26,15 @@
[test-name :- s/Keyword]
(runner/run-tests (runner/create-test-runner test-name)))
(defmacro defdatatest [n & body]
(defmacro defdatatest [n bindings & body]
(when ct/*load-tests*
(let [namespaced-test-key# (keyword (str *ns*) (name n))
file-prefix# (fl/data-test-spec-file-prefix namespaced-test-key#)]
`(def ~(vary-meta n assoc
:test `(fn []
(let [testdata# (fl/load-test-data ~file-prefix#)
~(symbol 'input) (:input testdata#)
~(symbol 'expectation) (:expectation testdata#)]
~(symbol (first bindings)) (:input testdata#)
~(symbol (second bindings)) (:expectation testdata#)]
~@body))
:data-spec-prefix file-prefix#)
(fn [] (ct/test-var (var ~n)))))))

View file

@ -38,7 +38,9 @@
(is (sut/test-with-data ::should-test-with-data-record-version)))
; ---------------------------- macro -----------------------------
(sut/defdatatest should-test-with-data-macro-version (is (= input expectation)))
(sut/defdatatest should-test-with-data-macro-version [input expectation]
(is (= input expectation)))
(macroexpand-1 '(sut/defdatatest should-test-with-data-macro-version (is (= 1 1))))