Skip to content

Commit

Permalink
Update Expectations v2 port
Browse files Browse the repository at this point in the history
Closes #10
Closes #11
  • Loading branch information
NoahTheDuke committed Nov 21, 2024
1 parent f862ecb commit 576d574
Show file tree
Hide file tree
Showing 10 changed files with 689 additions and 356 deletions.
1 change: 1 addition & 0 deletions .clj-kondo/config.edn
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{:config-paths ["../resources/clj-kondo.exports/io.github.noahtheduke/lazytest"]
:cljc {:features [:clj]}
:linters {:clojure-lsp/unused-public-var {:level :off}
:unused-binding {:exclude-patterns ["^this"]}}}
7 changes: 7 additions & 0 deletions .clj-kondo/imports/io.github.noahtheduke/lazytest/config.edn
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
lazytest.experimental.interfaces.clojure-test/are clojure.test/are
;; xunit interface
lazytest.experimental.interfaces.xunit/defsuite clojure.core/def
;; Expectations v2
lazytest.extensions.expectations/from-each clojure.core/for
lazytest.extensions.expectations/=? clojure.core/=
}
:hooks {:analyze-call {;; Expectations v2
lazytest.extensions.expectations/more-> hooks.lazytest.expectations/more->
lazytest.extensions.expectations/more-of hooks.lazytest.expectations/more-of
}}
:linters {:clojure-lsp/unused-public-var
{:exclude-when-defined-by #{lazytest.core/defdescribe
lazytest.experimental.interfaces.xunit/defsuite
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
;; Copied from https://github.com/clojure-expectations/clojure-test/blob/b90ed5b24924238b3b16b0bbaaee4c3b05a1268a

(ns hooks.lazytest.expectations
(:require [clj-kondo.hooks-api :as api]))

(defn more-> [{:keys [node]}]
(let [tail (rest (:children node))
rewritten
(api/list-node
(list*
(api/token-node 'cond->)
(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 'fn)
(api/vector-node (vector bindings))
(map (fn [[e a]]
(api/list-node
(list
(api/token-node 'lazytest.core/expect)
e
a)))
pairs)))]
{:node rewritten}))
32 changes: 22 additions & 10 deletions .projections.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
{
"doc/*.md": {"type": "doc"},
"README.md": {"type": "doc"},
"src/clojure/*.clj": {
"type": "source",
"alternate": "test/clojure/{}_test.clj"
},
"test/clojure/*_test.clj": {
"type": "test",
"alternate": "src/clojure/{}.clj"
}
"doc/*.md": {
"type": "doc"
},
"README.md": {
"type": "doc"
},
"src/clojure/*.clj": {
"type": "source",
"alternate": "test/clojure/{}_test.clj"
},
"src/clojure/*.cljc": {
"type": "source",
"alternate": "test/clojure/{}_test.cljc"
},
"test/clojure/*_test.clj": {
"type": "test",
"alternate": "src/clojure/{}.clj"
},
"test/clojure/*_test.cljc": {
"type": "test",
"alternate": "src/clojure/{}.cljc"
}
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixed

- `around` context macro is now called once for all children. (See [#12](https://github.com/NoahTheDuke/lazytest/issues/12).)
- Update Expectations v2 port to allow for easier updating in the future and support all non-test definition functions/macros. (See [#10](https://github.com/NoahTheDuke/lazytest/issues/10) and [#11](https://github.com/NoahTheDuke/lazytest/issues/11).)

### Misc

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
lazytest.experimental.interfaces.clojure-test/are clojure.test/are
;; xunit interface
lazytest.experimental.interfaces.xunit/defsuite clojure.core/def
;; Expectations v2
lazytest.extensions.expectations/from-each clojure.core/for
lazytest.extensions.expectations/=? clojure.core/=
}
:hooks {:analyze-call {;; Expectations v2
lazytest.extensions.expectations/more-> hooks.lazytest.expectations/more->
lazytest.extensions.expectations/more-of hooks.lazytest.expectations/more-of
}}
:linters {:clojure-lsp/unused-public-var
{:exclude-when-defined-by #{lazytest.core/defdescribe
lazytest.experimental.interfaces.xunit/defsuite
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
;; Copied from https://github.com/clojure-expectations/clojure-test/blob/b90ed5b24924238b3b16b0bbaaee4c3b05a1268a

(ns hooks.lazytest.expectations
(:require [clj-kondo.hooks-api :as api]))

(defn more-> [{:keys [node]}]
(let [tail (rest (:children node))
rewritten
(api/list-node
(list*
(api/token-node 'cond->)
(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 'fn)
(api/vector-node (vector bindings))
(map (fn [[e a]]
(api/list-node
(list
(api/token-node 'lazytest.core/expect)
e
a)))
pairs)))]
{:node rewritten}))
Loading

0 comments on commit 576d574

Please sign in to comment.