Skip to content

Commit 6c6adbe

Browse files
committed
Let Parinfer "fix" the formatting
Also satisfy a couple of clj-kondo complaints.
1 parent cd19335 commit 6c6adbe

File tree

4 files changed

+68
-66
lines changed

4 files changed

+68
-66
lines changed

deps.edn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
:cljdoc {:extra-deps {planck/planck {:mvn/version "2.23.0"}}}
1515
:cljs-runner
1616
{:extra-deps {olical/cljs-test-runner {:mvn/version "3.7.0"},
17-
pjstadig/humane-test-output {:mvn/version "0.10.0"}},
17+
pjstadig/humane-test-output {:mvn/version "0.10.0"}},
1818
:extra-paths ["src" "test" "cljs-test-runner-out/gen"],
1919
:main-opts ["-m" "cljs-test-runner.main" "--doo-opts"
20-
"dooopts.edn" "-x" "planck"]}}}
20+
"dooopts.edn" "-x" "planck"]}}}

src/expectations/clojure/test.cljc

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
#?(:clj [clojure.test :as t]
1313
:cljs [cljs.test :include-macros true :as t])
1414
#?(:cljs [cljs.spec.alpha :as s])
15-
#?@(:cljs [pjstadig.humane-test-output pjstadig.util
16-
pjstadig.print])))
15+
#?@(:cljs [pjstadig.humane-test-output
16+
pjstadig.print
17+
pjstadig.util])))
1718

1819
(def humane-test-output?
1920
"If Humane Test Output is available, activate it, and enable compatibility
@@ -115,7 +116,9 @@
115116
[& expecteds]
116117
(bad-usage "more"))
117118

118-
(defn ^:no-doc spec? [e]
119+
(defn ^:no-doc spec?
120+
"Detects whether an expected expression seems to be a Spec."
121+
[e]
119122
(and (keyword? e)
120123
#?(:clj (try (require 'clojure.spec.alpha)
121124
(when-let [get-spec (resolve 'clojure.spec.alpha/get-spec)]
@@ -296,11 +299,11 @@
296299
(t/is (~'=? e# submap# '~form) ~msg'))
297300
(throw (#?(:clj IllegalArgumentException.
298301
:cljs js/Error.)
299-
"'in' requires map or sequence"))))
302+
"'in' requires map or sequence"))))
300303
:else
301304
(throw (#?(:clj IllegalArgumentException.
302305
:cljs js/Error.)
303-
"'in' requires map or sequence")))))
306+
"'in' requires map or sequence")))))
304307

305308
(and (sequential? e) (= 'more (first e)))
306309
(let [es (mapv (fn [e] `(expect ~e ~a ~msg ~ex? ~e')) (rest e))]
@@ -455,36 +458,36 @@
455458
(t/is (= e-val a-val) (difference-fn e-val a-val))))))
456459

457460
#?(:clj (defn use-fixtures
458-
"Wrap test runs in a fixture function to perform setup and
461+
"Wrap test runs in a fixture function to perform setup and
459462
teardown. Using a fixture-type of `:each` wraps every test
460463
individually, while `:once` wraps the whole run in a single function.
461464
462465
Like `cljs.test/use-fixtures`, also accepts hash maps with `:before`
463466
and/or `:after` keys that specify 0-arity functions to invoke
464467
before/after the test/run."
465-
[fixture-type & fs]
466-
(apply t/use-fixtures fixture-type
467-
(map (fn [f]
468-
(if (map? f)
469-
(fn [t]
470-
(when-let [before (:before f)]
471-
(before))
472-
(t)
473-
(when-let [after (:after f)]
474-
(after)))
475-
f))
476-
fs))))
468+
[fixture-type & fs]
469+
(apply t/use-fixtures fixture-type
470+
(map (fn [f]
471+
(if (map? f)
472+
(fn [t]
473+
(when-let [before (:before f)]
474+
(before))
475+
(t)
476+
(when-let [after (:after f)]
477+
(after)))
478+
f))
479+
fs))))
477480

478481
#?(:cljs (defmacro use-fixtures
479-
"Wrap test runs in a fixture function to perform setup and
482+
"Wrap test runs in a fixture function to perform setup and
480483
teardown. Using a fixture-type of `:each` wraps every test
481484
individually, while `:once` wraps the whole run in a single function.
482485
483486
Hands off to `cljs.test/use-fixtures`, also accepts hash maps with `:before`
484487
and/or `:after` keys that specify 0-arity functions to invoke
485488
before/after the test/run."
486-
[fixture-type & fs]
487-
`(cljs.test/use-fixtures ~fixture-type ~@fs)))
489+
[fixture-type & fs]
490+
`(cljs.test/use-fixtures ~fixture-type ~@fs)))
488491

489492
(defn from-clojure-test
490493
"Intern the specified symbol from `clojure.test` as a symbol in

test/expectations/clojure/test_macros.cljc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Macros to support testing the testing framework."
55
(:require #?(:clj [clojure.test :refer [is do-report] :as t]
66
:cljs [cljs.test :refer [do-report assert-expr]
7-
:refer-macros [is assert-expr] :as t])
7+
:refer-macros [is assert-expr] :as t])
88
#?(:cljs [cljs.spec.alpha :as s])
99
#?(:clj [expectations.clojure.test :as sut]
1010
:cljs [expectations.clojure.test :include-macros true :as sut])))
@@ -16,11 +16,11 @@
1616
(with-redefs [do-report (sut/all-report results#)]
1717
~expectation)
1818
(t/is (some (fn [fail#]
19-
(= '~failure (:actual fail#)))
19+
(= '~failure (:actual fail#)))
2020
(:fail @results#)))
2121
(when ~msg
2222
(t/is (some (fn [fail#]
23-
(re-find ~msg (:message fail#)))
23+
(re-find ~msg (:message fail#)))
2424
(:fail @results#))))))
2525

2626
(defmacro is-not
@@ -30,11 +30,11 @@
3030
(with-redefs [do-report (sut/all-report results#)]
3131
~expectation)
3232
(t/is (some (fn [fail#]
33-
(= ~failure (:actual fail#)))
33+
(= ~failure (:actual fail#)))
3434
(:fail @results#)))
3535
(when ~msg
3636
(t/is (some (fn [fail#]
37-
(re-find ~msg (:message fail#)))
37+
(re-find ~msg (:message fail#)))
3838
(:fail @results#))))))
3939

4040
(defmacro passes
@@ -47,6 +47,5 @@
4747
(with-redefs [do-report (sut/all-report results#)]
4848
~expectation)
4949
(t/is (some (fn [pass#]
50-
(~success (:actual pass#)))
50+
(~success (:actual pass#)))
5151
(:pass @results#)))))
52-

test/expectations/clojure/test_test.cljc

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@
99
#?(:clj [expectations.clojure.test-macros :refer
1010
[is-not' is-not passes]]
1111
:cljs [expectations.clojure.test-macros
12-
:refer-macros [is-not' is-not passes]])
12+
:refer-macros [is-not' is-not passes]])
1313

1414
#?(:clj [clojure.test :refer [deftest is do-report testing]]
1515
:cljs [cljs.test :include-macros true
16-
:refer [do-report assert-expr]
17-
:refer-macros [deftest is testing assert-expr
18-
use-fixtures]])
16+
:refer [do-report assert-expr]
17+
:refer-macros [deftest is testing assert-expr
18+
use-fixtures]])
1919
#?(:cljs [cljs.spec.alpha :as s])
2020
#?(:clj [expectations.clojure.test :refer
2121
[from-each in more more-of] :as sut]
2222
:cljs [expectations.clojure.test
23-
:include-macros true
24-
:as sut])))
23+
:include-macros true
24+
:as sut])))
2525

2626
; The macros are in test_macros.cljc to support Clojurescript.
2727

@@ -59,40 +59,40 @@
5959
#_(is-not' (sut/expect #"fool" "It's foobar!") (not (re-find #"fool" "It's foobar!"))))
6060

6161
#?(:clj (deftest exception-test
62-
(passes (sut/expect ArithmeticException (/ 12 0))
63-
(fn [ex]
64-
(let [t (Throwable->map ex)]
65-
(and (= "Divide by zero" (-> t :cause))
66-
(or (= 'java.lang.ArithmeticException (-> t :via first :type))
67-
(= java.lang.ArithmeticException (-> t :via first :type))))))))
62+
(passes (sut/expect ArithmeticException (/ 12 0))
63+
(fn [ex]
64+
(let [t (Throwable->map ex)]
65+
(and (= "Divide by zero" (-> t :cause))
66+
(or (= 'java.lang.ArithmeticException (-> t :via first :type))
67+
(= java.lang.ArithmeticException (-> t :via first :type))))))))
6868

6969
:cljs (deftest cljs-exception-test
7070
(passes (sut/expect js/Error (throw (ex-info "foo" {})))
7171
(fn [ex]
7272
(let [t (cljs.repl/Error->map ex)]
7373
(and (= "foo"
7474
(-> t :cause)) (or (= 'ExceptionInfo
75-
(->> t :via first :type))
76-
(= ExceptionInfo
77-
(->> t :via first :type)))))))))
75+
(->> t :via first :type))
76+
(= ExceptionInfo
77+
(->> t :via first :type)))))))))
7878

7979
#?(:clj (deftest class-test
80-
(is (sut/expect String (name :foo)))
81-
(is-not (sut/expect String :foo) clojure.lang.Keyword)))
80+
(is (sut/expect String (name :foo)))
81+
(is-not (sut/expect String :foo) clojure.lang.Keyword)))
8282

8383
#?(:cljs (deftest class-test
8484
(is (sut/expect cljs.core/List '(a b c)))
8585
(is-not (sut/expect cljs.core/List :foo) cljs.core/Keyword)))
8686

8787
#?(:clj (try
88-
(eval '(do
89-
(require '[clojure.spec.alpha :as s])
90-
(s/def :small/value (s/and pos-int? #(< % 100)))
91-
(deftest spec-test
92-
(is (sut/expect :small/value (* 13 4)))
93-
(is-not' (sut/expect :small/value (* 13 40)) (not (=? :small/value 520))))))
94-
(catch Throwable _
95-
(println "\nOmitting Spec tests for Clojure" (clojure-version)))))
88+
(eval '(do
89+
(require '[clojure.spec.alpha :as s])
90+
(s/def :small/value (s/and pos-int? #(< % 100)))
91+
(deftest spec-test
92+
(is (sut/expect :small/value (* 13 4)))
93+
(is-not' (sut/expect :small/value (* 13 40)) (not (=? :small/value 520))))))
94+
(catch Throwable _
95+
(println "\nOmitting Spec tests for Clojure" (clojure-version)))))
9696

9797
; Note :expectations.clojure.test/small-value is defined at the end of
9898
; expectations.clojure.test/test.cljc for cljs testing. Defining it here
@@ -148,17 +148,17 @@
148148

149149
; There is no cljs.test/with-test
150150
#?(:clj (sut/with-test
151-
(defn definition-test
152-
"Make sure expectations work with clojure.test/with-test."
153-
[a b c]
154-
(swap! d-t-counter inc)
155-
(* a b c))
156-
(println "\nRunning inline tests")
157-
(reset! d-t-counter 0)
158-
(is (= 0 @d-t-counter))
159-
(sut/expect 1 (definition-test 1 1 1))
160-
(sut/expect 6 (definition-test 1 2 3))
161-
(is (= 2 @d-t-counter))))
151+
(defn definition-test
152+
"Make sure expectations work with clojure.test/with-test."
153+
[a b c]
154+
(swap! d-t-counter inc)
155+
(* a b c))
156+
(println "\nRunning inline tests")
157+
(reset! d-t-counter 0)
158+
(is (= 0 @d-t-counter))
159+
(sut/expect 1 (definition-test 1 1 1))
160+
(sut/expect 6 (definition-test 1 2 3))
161+
(is (= 2 @d-t-counter))))
162162

163163
;; these would be failing tests in 1.x but not in 2.x:
164164
(sut/defexpect deftest-equivalence-0)

0 commit comments

Comments
 (0)