added bindings

pull/1/head
jem 5 years ago
parent 9503aeddaf
commit 56276f2c18

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

@ -38,7 +38,9 @@
(is (sut/test-with-data ::should-test-with-data-record-version))) (is (sut/test-with-data ::should-test-with-data-record-version)))
; ---------------------------- macro ----------------------------- ; ---------------------------- 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)))) (macroexpand-1 '(sut/defdatatest should-test-with-data-macro-version (is (= 1 1))))

Loading…
Cancel
Save