Fork me on GitHub
#meander
<
2020-03-06
>
timothypratley03:03:24

Any suggestions meander for test expression matching? (is (m/match x (a b c) true _ nil)) works but is a bit unsatisfying because if it doesn’t match doesn’t print out x

timothypratley03:03:43

Inverting to

(is (not (m/match method (a b c) false _ method)))))
Gives a better error message, but has double negative output which is a bit confusing )

timothypratley03:03:12

(is (= :match (m/match method (a b c) :match _ method)))
^^ this isn’t bad 🙂

timothypratley03:03:45

(defmacro is-match? [x pattern]
  `(is (= (m/match ~x ~pattern :match ~'_else ~x) :match)))
o_O

timothypratley03:03:01

(is-match? method (a b c))

timothypratley03:03:59

(is-match? method (defn (m/pred symbol? ?fn-name) (m/pred string? ?doc-string) & _))

noprompt03:03:06

@timothypratley Shared a cool idea: https://github.com/noprompt/meander/issues/116 I’d be interested in hearing what others think.

noprompt06:03:38

I love that I can actually read most of this code and see whats going without actually knowing what its purpose is. 🙂

noprompt06:03:55

Also, I think you’ll be really happy to know that in zeta you’ll be able to pattern matching and substitute strings too so you won’t need to do ~(str ,,,).

noprompt06:03:52

Oh and you’ll be able to m/let on the RHS. 🙂