Liking cljdoc? Tell your friends :D

state-flow.refactoring-tools.refactor-match

This ns contains tools to refactor from match? in the cljtest ns to the new version in the assertions.matcher-combinators ns.

This ns contains tools to refactor from match? in the cljtest
ns to the new version in the assertions.matcher-combinators ns.
raw docstring

match-expr?clj

(match-expr? match-sym node)
source

probe-paramsclj

(probe-params orig)
source

refactor-allclj

(refactor-all {:keys [path str sym-before sym-after rewrite wrap-in-flow
                      force-probe-params]
               :as opts})

Given a map with :path to a file or a string :str, returns a string with all of the match? expressions refactored as follows:

Given a match? expression e.g.

(match? <description> <actual> <expected>) ;; or (match? <description> <actual> <expected> <params>)

Returns an expect expression e.g.

(match? <expected> <actual>) ;; or (match? <expected> <actual> <params>)

With :wrap-in-flow set to true, returns e.g.

(flow <description> (match? <expected> <actual>)) ;; or (flow <description> (match? <expected> <actual> <params>))

Supported keys:

  • :str this or path are required - string source for the refactoring
  • :path this or str are required - path to source for refactoring
  • :rewrite optional (default false) - rewrites refactored code to the same path
  • :sym-before optional (default match?) - symbol to look for for match? expressions - use this key if you've got a qualified symbol
  • :sym-after optional (default match?) - symbol to replace :sym-before
  • :wrap-in-flow optional (default false) - set to true to wrap in a flow with the description from the source match? expression
  • :force-probe-params optional (default false) - makes probe params explicit (strongly recommended)

This is intended to help you in refactoring to the new match? function, however there are some things you'll need to do on your own:

  • before
    • ensure that the the match? expressions you wish to refactor use the same symbol (simple or qualified) before refactoring
  • after
    • reformat for whitespace (manually or w/ cljfmt)
  • before or after
    • update the ns declaration to include state-flow.assertions.matcher-combinators
      • if :sym-after is simple i.e. just match?, then :refer [match?]
      • if :sym-after is qualified, then use :as <alias>

WARNING: the old version of match? probes implicitly when actual is a step. The new version requires an explicit {:times-to-try <value gt 1>} to trigger polling, so leaving out :force-probe-params may result in tests failing because they need probe.

Given a map with :path to a file or a string :str, returns
a string with all of the match? expressions refactored as follows:

Given a match? expression e.g.

  (match? <description> <actual> <expected>)
  ;; or
  (match? <description> <actual> <expected> <params>)

Returns an expect expression e.g.

  (match? <expected> <actual>)
  ;; or
  (match? <expected> <actual> <params>)

With :wrap-in-flow set to true, returns e.g.

  (flow <description> (match? <expected> <actual>))
  ;; or
  (flow <description> (match? <expected> <actual> <params>))

Supported keys:
- :str                 this or path are required   - string source for the refactoring
- :path                this or str are required    - path to source for refactoring
- :rewrite             optional (default false)    - rewrites refactored code to the same path
- :sym-before          optional (default `match?`) - symbol to look for for match? expressions
                         - use this key if you've got a qualified symbol
- :sym-after           optional (default `match?`) - symbol to replace :sym-before
- :wrap-in-flow        optional (default false)    - set to true to wrap in a flow with the description
                                                     from the source match? expression
- :force-probe-params  optional (default false)    - makes probe params explicit (strongly recommended)

This is intended to help you in refactoring to the new match? function, however
there are some things you'll need to do on your own:

- before
  - ensure that the the `match?` expressions you wish to refactor use the same
    symbol (simple or qualified) before refactoring
- after
  - reformat for whitespace (manually or w/ cljfmt)
- before or after
  - update the ns declaration to include state-flow.assertions.matcher-combinators
    - if :sym-after is simple i.e. just `match?`, then `:refer [match?]`
    - if :sym-after is qualified, then use `:as <alias>`

WARNING: the old version of match? probes implicitly when `actual` is a step. The new
version requires an explicit `{:times-to-try <value gt 1>}` to trigger polling, so
leaving out :force-probe-params may result in tests failing because they need probe.
sourceraw docstring

refactor-match-exprclj

(refactor-match-expr {:keys [wrap-in-flow force-probe-params sym-after]} zloc)

If there is an exception, printlns the expression so you can find and handle it manually.

If there is an exception, printlns the expression so you can
find and handle it manually.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close