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

old-require?clj

(old-require? zloc)

Returns true if zloc represents a require vector with

  • state-flow.cljtest
  • :refer [match?] (not necessarily only match)
Returns true if zloc represents a require vector with
- state-flow.cljtest
- :refer [match?] (not necessarily only match)
sourceraw docstring

probe-paramsclj

(probe-params orig)
source

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

refactor-match-exprsclj

(refactor-match-exprs {: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-requireclj

(refactor-require {:keys [path str rewrite]})

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 an ns declaration with this in require:

[state-flow.cljtest :refer [match?]]

Refactor it to

[state-flow.assertions.matcher-combinators :refer [match?]]

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 an ns declaration with this in require:

  [state-flow.cljtest :refer [match?]]

Refactor it to

  [state-flow.assertions.matcher-combinators :refer [match?]]
sourceraw docstring

refactor-require*clj

(refactor-require* zloc)
source

refactor-require**clj

(refactor-require** zloc)
source

refer?clj

(refer? sym zloc)
source

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

× close