From 56276f2c185d138ad3359294c3e17f2514443c3f Mon Sep 17 00:00:00 2001 From: jem Date: Tue, 28 May 2019 08:43:23 +0200 Subject: [PATCH] added bindings --- main/src/data_test.clj | 6 +++--- test/src/data_test_test.clj | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/main/src/data_test.clj b/main/src/data_test.clj index 611c177..327f836 100644 --- a/main/src/data_test.clj +++ b/main/src/data_test.clj @@ -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))))))) diff --git a/test/src/data_test_test.clj b/test/src/data_test_test.clj index 9d77cce..e02cd7f 100644 --- a/test/src/data_test_test.clj +++ b/test/src/data_test_test.clj @@ -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))))