Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matcher for gensyms #29

Closed
thumbnail opened this issue Aug 21, 2020 · 0 comments · Fixed by #34
Closed

matcher for gensyms #29

thumbnail opened this issue Aug 21, 2020 · 0 comments · Fixed by #34

Comments

@thumbnail
Copy link
Member

thumbnail commented Aug 21, 2020

Context

macroexpand= is great; but unifies any symbol it recognizes as a gensym. providing a matcher-combinators matcher for gensyms allows for more specific matches

Task

  1. add a GensymMatcher + wrapper fns
  2. add readme examples

Additional resources

Blocked by #28, at least for the opt-in requirement of m-c.

In an internal project we use:

(defrecord GensymMatcher [expected]
 matcher-combinators.core/Matcher
 (match [_this actual]
   (let [value (symbol (string/replace actual #"(.?+)(\d)*" "$1"))]
     (if (= expected value)
       {:matcher-combinators.result/type   :match
        :matcher-combinators.result/value  value
        :matcher-combinators.result/weight 0}
       {:matcher-combinators.result/type   :mismatch
        :matcher-combinators.result/value  (model/->Mismatch expected value)
        :matcher-combinators.result/weight 1}))))
@thumbnail thumbnail changed the title matcher for macroexpansion matcher for gensyms Aug 21, 2020
thumbnail added a commit that referenced this issue Oct 6, 2020
@thumbnail thumbnail mentioned this issue Oct 6, 2020
26 tasks
thumbnail added a commit that referenced this issue Oct 8, 2020
* add gensym matcher

fixes #29

* apply regex suggestion

* add test-case

* formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant