Skip to content

Commit

Permalink
fix #35
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Corfield <[email protected]>
  • Loading branch information
seancorfield committed May 4, 2024
1 parent a25e662 commit e819aeb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
Only accretive/fixative changes will be made from now on.

* 2.1.next in progress
* Address [#31](https://github.com/clojure-expectations/clojure-test/issues/31) by adding more examples to `more-of`.
* Address [#35](https://github.com/clojure-expectations/clojure-test/issues/35) by treating any symbol starting with `expect` as an Expectations macro for the 2-argument form.
* Address [#33](https://github.com/clojure-expectations/clojure-test/issues/33) by expanding the README introduction.
* Address [#31](https://github.com/clojure-expectations/clojure-test/issues/31) by adding more examples to `more-of`.
* Update dev/test dependencies.

* 2.1.188 -- 2023-10-22
Expand Down
4 changes: 2 additions & 2 deletions src/expectations/clojure/test.cljc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;; copyright (c) 2018-2023 sean corfield, all rights reserved
;; copyright (c) 2018-2024 sean corfield, all rights reserved

(ns expectations.clojure.test
"This namespace provides compatibility with `clojure.test` and related tooling.
Expand Down Expand Up @@ -424,7 +424,7 @@
[e]
(when (and (coll? e) (not (vector? e)))
(or (and (symbol? (first e))
(= "expect" (name (first e))))
(str/starts-with? (name (first e)) "expect"))
(some contains-expect? e))))

(defmacro defexpect
Expand Down
28 changes: 14 additions & 14 deletions test/expectations/clojure/test_test.cljc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;; copyright (c) 2019-2023 sean corfield, all rights reserved
;; copyright (c) 2019-2024 sean corfield, all rights reserved

(ns expectations.clojure.test-test
"Test the testing framework -- this is sometimes harder than you might think!
Expand Down Expand Up @@ -126,19 +126,19 @@
(is-not' (sut/expect {:foo 1} (in {:foo 2 :cat 4})) (not= {:foo 1} {:foo 2}))

;; TODO: need better tests here
(deftest grouping-more-more-of-from-each
(sut/expecting "numeric behavior"
(sut/expect (more-of {:keys [a b]}
even? a
odd? b)
{:a (* 2 13) :b (* 3 13)})
(sut/expect pos? (* -3 -5)))
(sut/expecting "string behavior"
(sut/expect (more #"foo" "foobar" #(str/starts-with? % "f"))
(str "f" "oobar"))
(sut/expect #"foo"
(from-each [s ["l" "d" "bar"]]
(str "foo" s))))))
(deftest grouping-more-more-of-from-each
(sut/expecting "numeric behavior"
(sut/expect (more-of {:keys [a b]}
even? a
odd? b)
{:a (* 2 13) :b (* 3 13)})
(sut/expect pos? (* -3 -5)))
(sut/expecting "string behavior"
(sut/expect (more #"foo" "foobar" #(str/starts-with? % "f"))
(str "f" "oobar"))
(sut/expect #"foo"
(from-each [s ["l" "d" "bar"]]
(str "foo" s))))))

(deftest more-evals-once
(let [counter (atom 1)]
Expand Down

0 comments on commit e819aeb

Please sign in to comment.