Skip to content

Commit e93c7ba

Browse files
committed
fix #19 by supporting regex as dynamic predicate
1 parent 07604ee commit e93c7ba

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
* 2.0.x in progress (alpha3?)
66
* Address #22 by adding `clj-kondo.exports` (this is just a first pass; the `:lint-as` mappings will probably be replaced by hooks in the future).
7+
* Fix #19 by supporting regex/patterns dynamically inside `?=` (as well as the compile-time support already in `expect`).
78
* Update `build-clj` to v0.5.0.
89
* Switch to `build.clj`/`tools.build` for CI/deploy.
910

src/expectations/clojure/test.cljc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@
174174
(valid?# e# a#)
175175
(fn? e#)
176176
(e# a#)
177+
(isa? (type e#)
178+
#?(:clj java.util.regex.Pattern
179+
:cljs (type #"regex")))
180+
(some? (re-find e# a#))
177181
:else
178182
(= e# a#))
179183
humane?# (and humane-test-output? (not (fn? e#)) (not ~conform?))]

test/expectations/clojure/test_test.cljc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,6 @@
194194
(is-not' (sut/expect "abcdef" (str "abc" "efg"))
195195
["abcefg"]
196196
#"(?is)(str \"abc\" \"efg\").*matches: \"abc\"")))
197+
198+
(deftest issue-19-regex-test
199+
(is (sut/expect (re-pattern "\\d+") "1000")))

0 commit comments

Comments
 (0)