diff --git a/.clj-kondo/com.github.seancorfield/expectations/config.edn b/.clj-kondo/com.github.seancorfield/expectations/config.edn index 0365b78..d94f1be 100644 --- a/.clj-kondo/com.github.seancorfield/expectations/config.edn +++ b/.clj-kondo/com.github.seancorfield/expectations/config.edn @@ -1,9 +1,10 @@ {:hooks {:analyze-call {expectations.clojure.test/more-> - hooks.com.github.seancorfield.expectations/more->}} + hooks.com.github.seancorfield.expectations/more-> + expectations.clojure.test/more-of + hooks.com.github.seancorfield.expectations/more-of}} :lint-as {expectations.clojure.test/defexpect clojure.test/deftest expectations.clojure.test/from-each clojure.core/for - expectations.clojure.test/more-of clj-kondo.lint-as/def-catch-all expectations.clojure.test/=? clojure.core/=}} diff --git a/.clj-kondo/com.github.seancorfield/expectations/hooks/com/github/seancorfield/expectations.clj_kondo b/.clj-kondo/com.github.seancorfield/expectations/hooks/com/github/seancorfield/expectations.clj_kondo index 8b1cd96..35476be 100644 --- a/.clj-kondo/com.github.seancorfield/expectations/hooks/com/github/seancorfield/expectations.clj_kondo +++ b/.clj-kondo/com.github.seancorfield/expectations/hooks/com/github/seancorfield/expectations.clj_kondo @@ -10,3 +10,20 @@ (api/token-node 'nil) tail))] {:node rewritten})) + +(defn more-of [{:keys [node]}] + (let [bindings (fnext (:children node)) + pairs (partition 2 (nnext (:children node))) + rewritten + (api/list-node + (list* + (api/token-node 'let) + (api/vector-node (vector bindings (api/token-node 'nil))) + (map (fn [[e a]] + (api/list-node + (list + (api/token-node '=?) + e + a))) + pairs)))] + {:node rewritten})) diff --git a/CHANGELOG.md b/CHANGELOG.md index b471cd3..00eeab8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Only accretive/fixative changes will be made from now on. * 2.1.next in progress + * Address [#29](https://github.com/clojure-expectations/clojure-test/issues/29) by providing a "hook" for `more-of`. * Update `tools.build` to 0.9.6 (and get rid of `template/pom.xml` in favor of new `:pom-data` option to `b/write-pom`). * 2.1.182 -- 2023-09-29 diff --git a/deps.edn b/deps.edn index e043e1a..92b8ad1 100755 --- a/deps.edn +++ b/deps.edn @@ -13,6 +13,8 @@ :1.11 {:override-deps {org.clojure/clojure {:mvn/version "1.11.1"}}} :master {:override-deps {org.clojure/clojure {:mvn/version "1.12.0-master-SNAPSHOT"}}} + :kondo ; for debugging hooks + {:extra-deps {clj-kondo/clj-kondo {:mvn/version "RELEASE"}}} ;; running tests/checks of various kinds: :test ; can also run clojure -X:test {:extra-paths ["test"] diff --git a/resources/clj-kondo.exports/com.github.seancorfield/expectations/config.edn b/resources/clj-kondo.exports/com.github.seancorfield/expectations/config.edn index 0365b78..d94f1be 100644 --- a/resources/clj-kondo.exports/com.github.seancorfield/expectations/config.edn +++ b/resources/clj-kondo.exports/com.github.seancorfield/expectations/config.edn @@ -1,9 +1,10 @@ {:hooks {:analyze-call {expectations.clojure.test/more-> - hooks.com.github.seancorfield.expectations/more->}} + hooks.com.github.seancorfield.expectations/more-> + expectations.clojure.test/more-of + hooks.com.github.seancorfield.expectations/more-of}} :lint-as {expectations.clojure.test/defexpect clojure.test/deftest expectations.clojure.test/from-each clojure.core/for - expectations.clojure.test/more-of clj-kondo.lint-as/def-catch-all expectations.clojure.test/=? clojure.core/=}} diff --git a/resources/clj-kondo.exports/com.github.seancorfield/expectations/hooks/com/github/seancorfield/expectations.clj_kondo b/resources/clj-kondo.exports/com.github.seancorfield/expectations/hooks/com/github/seancorfield/expectations.clj_kondo index 8b1cd96..35476be 100644 --- a/resources/clj-kondo.exports/com.github.seancorfield/expectations/hooks/com/github/seancorfield/expectations.clj_kondo +++ b/resources/clj-kondo.exports/com.github.seancorfield/expectations/hooks/com/github/seancorfield/expectations.clj_kondo @@ -10,3 +10,20 @@ (api/token-node 'nil) tail))] {:node rewritten})) + +(defn more-of [{:keys [node]}] + (let [bindings (fnext (:children node)) + pairs (partition 2 (nnext (:children node))) + rewritten + (api/list-node + (list* + (api/token-node 'let) + (api/vector-node (vector bindings (api/token-node 'nil))) + (map (fn [[e a]] + (api/list-node + (list + (api/token-node '=?) + e + a))) + pairs)))] + {:node rewritten})) diff --git a/test/expectations/clojure/test_test.cljc b/test/expectations/clojure/test_test.cljc index 7aa51d3..0b28ed6 100644 --- a/test/expectations/clojure/test_test.cljc +++ b/test/expectations/clojure/test_test.cljc @@ -22,6 +22,7 @@ [from-each in more more-> more-of =?] :as sut] :cljs [expectations.clojure.test :include-macros true + :refer-macros [from-each in more more-> more-of =?] :as sut]))) ; The macros are in test_macros.cljc to support ClojureScript.