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

form-starting-withclj

(form-starting-with zloc val)
source

match-expr?clj

(match-expr? match-sym node)
source

probe-paramsclj

(probe-params orig)
source

refactor!clj

(refactor! {:keys [path str rewrite wrap-in-flow] :as opts})
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 z sym-before sym-after rewrite
                              wrap-in-flow force-probe-params]
                       :as opts})

Given a map with a zipper :z, :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 a zipper :z, :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-ns-decclj

(refactor-ns-dec {:keys [z rewrite wrap-in-flow] :as opts})

Given a map with :path to a file or a string :str, returns a zipper with all of the ns declarations 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?]]

If :wrap-in-flow is true, then ensures that this line is in the ns declaration

[state-flow.core :refer [flow]]

Given a map with :path to a file or a string :str, returns
a zipper with all of the ns declarations 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?]]

If `:wrap-in-flow` is true, then ensures that this line is in
the ns declaration

  [state-flow.core :refer [flow]]
sourceraw docstring

refactor-refer-matchclj

(refactor-refer-match opts zloc)
source

refactor-refer-match*clj

(refactor-refer-match* zloc)
source

refer?clj

(refer? zloc sym)
source

replace-valueclj

(replace-value zloc)
source

require-cljtest-refer-match?clj

(require-cljtest-refer-match? 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

require-formclj

(require-form zloc)
source

require-state-flow-core-formclj

(require-state-flow-core-form zloc)
source

require-state-flow-core-refer-flowclj

(require-state-flow-core-refer-flow opts zloc)
source

require-state-flow-core-refer-flow*clj

(require-state-flow-core-refer-flow* zloc)
source

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

× close