Skip to content

Commit

Permalink
Renamed form-utils into pile (as in "pile o' stuff that doesn't have …
Browse files Browse the repository at this point in the history
…a better place now).
  • Loading branch information
marick committed Jan 27, 2013
1 parent a90c5ab commit 1c1ee9a
Show file tree
Hide file tree
Showing 26 changed files with 74 additions and 93 deletions.
1 change: 0 additions & 1 deletion src/midje/checking/checkers/chatty.clj
@@ -1,7 +1,6 @@
(ns ^{:doc "Checkers that explain more about a failure."}
midje.checking.checkers.chatty
(:use midje.clojure.core
midje.util.form-utils
[midje.checking.checkers.util :only [named-as-call]]
[midje.checking.extended-falsehood :only [data-laden-falsehood?
as-data-laden-falsehood
Expand Down
8 changes: 4 additions & 4 deletions src/midje/checking/checkers/collection.clj
Expand Up @@ -3,11 +3,11 @@
(ns ^{:doc "Checkers for collections and strings."}
midje.checking.checkers.collection
(:use midje.clojure.core
[midje.util.form-utils :only [macro-for]]
[midje.checking.checkers collection-util util chatty defining collection-comparison]
midje.checking.extended-equality
[midje.checking.extended-falsehood :only [extended-true?]]
[midje.error-handling.exceptions :only [user-error]]))
[midje.error-handling.exceptions :only [user-error]])
(:require [midje.util.pile :as pile]))


(def #^:private looseness-modifiers #{:in-any-order :gaps-ok})
Expand Down Expand Up @@ -241,8 +241,8 @@ just is also useful if you don't care about order:
(every? #(extended-= % expected) actual))))

(defmacro #^:private generate-n-of-checkers []
(macro-for [[num num-word] [[1 "one"] [2 "two"] [3 "three"] [4 "four"] [5 "five"]
[6 "six"] [7 "seven"] [8 "eight"] [9 "nine"] [10 "ten"]]]
(pile/macro-for [[num num-word] [[1 "one"] [2 "two"] [3 "three"] [4 "four"] [5 "five"]
[6 "six"] [7 "seven"] [8 "eight"] [9 "nine"] [10 "ten"]]]
(let [name (symbol (str num-word "-of"))
docstring (cl-format nil "Checks whether a sequence contains precisely ~R result~:[s, and \n that they each match~;, and \n that it matches~] the checker.
Expand Down
18 changes: 9 additions & 9 deletions src/midje/checking/checkers/collection_comparison.clj
Expand Up @@ -4,11 +4,11 @@
midje.checking.checkers.collection-comparison
(:use midje.clojure.core
[clojure.math.combinatorics :only [permutations]]
[midje.util.form-utils :only [tack-on-to sort-map]]
[midje.util.object-utils :only [function-name named-function?]]
[midje.checking.checkers collection-util util chatty defining]
midje.checking.extended-equality
[clojure.string :only [join]]))
midje.checking.extended-equality)
(:require [clojure.string :as str]
[midje.util.pile :as pile]))

;; There is an annoying only-semi-similarity between maps and sequences.
;; These are the generic functions.
Expand All @@ -21,10 +21,10 @@
(fn [midje-classification _elements_] midje-classification))

(defmethod collection-string ::map [_midje-classification_ elements]
(str "{" (join ", " (sort elements)) "}"))
(str "{" (str/join ", " (sort elements)) "}"))

(defmethod collection-string ::not-map [_midje-classification_ elements]
(str "[" (join " " elements) "]"))
(str "[" (str/join " " elements) "]"))
;;-

(defmulti best-actual-match
Expand All @@ -35,7 +35,7 @@
(str "Best match found: " (pr-str (:actual-found comparison))))

(defmethod best-actual-match ::map [_midje-classification_ comparison]
(str "Best match found: " (pr-str (sort-map (:actual-found comparison)))))
(str "Best match found: " (pr-str (pile/sort-map (:actual-found comparison)))))

(defmulti best-expected-match
"Describe the best list of expected values found in the comparison."
Expand Down Expand Up @@ -109,7 +109,7 @@
(concat (:expected-skipped-over candidate) (rest walking-expected))
best-so-far
(merge
(tack-on-to candidate
(pile/tack-on-to candidate
:actual-found (first walking-actual)
:expected-found (first walking-expected))
{:expected-skipped-over []}))
Expand All @@ -119,7 +119,7 @@
(recur walking-actual
(rest walking-expected)
best-so-far
(tack-on-to candidate
(pile/tack-on-to candidate
:expected-skipped-over (first walking-expected)))

(not (empty? (rest walking-actual)))
Expand Down Expand Up @@ -210,7 +210,7 @@
(rest walking-actual)
(rest walking-expected)
best-so-far
(tack-on-to candidate
(pile/tack-on-to candidate
:actual-found (first walking-actual)
:expected-found (first walking-expected)))

Expand Down
6 changes: 3 additions & 3 deletions src/midje/checking/checkers/defining.clj
@@ -1,6 +1,6 @@
(ns ^{:doc "Various ways to define checkers."}
midje.checking.checkers.defining
(:use [midje.util.form-utils :only [pop-docstring pop-opts-map]]))
(:require [midje.util.pile :as pile]))

(defn as-checker
"Label a function as a checker. This is only required if
Expand Down Expand Up @@ -59,8 +59,8 @@
"
{:arglists '([name docstring? attr-map? bindings+bodies])}
[name & args]
(let [[docstring more-args] (pop-docstring args)
[attr-map bindings+bodies] (pop-opts-map more-args)]
(let [[docstring more-args] (pile/pop-docstring args)
[attr-map bindings+bodies] (pile/pop-opts-map more-args)]
(working-with-arglists+bodies name docstring attr-map bindings+bodies))))

(defmacro checker
Expand Down
1 change: 0 additions & 1 deletion src/midje/checking/checkers/simple.clj
Expand Up @@ -9,7 +9,6 @@
[midje.checking.checkers.util :only [named-as-call]]
[midje.error-handling.exceptions :only [captured-throwable?]]
[midje.util.ecosystem :only [clojure-1-3? +M -M *M]]
[midje.util.form-utils :only [def-many-methods]]
[clojure.algo.monads :only [domonad set-m]])
(:import [midje.error_handling.exceptions ICapturedThrowable]))

Expand Down
1 change: 0 additions & 1 deletion src/midje/checking/examples.clj
Expand Up @@ -4,7 +4,6 @@
[midje.checking.extended-equality :only [extended-= evaluate-checking-function]]
[midje.error-handling.exceptions :only [captured-throwable]]
midje.data.prerequisite-state
midje.util.form-utils
midje.util.laziness)
(:require [midje.config :as config]
[midje.emission.boundaries :as emission-boundary]
Expand Down
1 change: 0 additions & 1 deletion src/midje/data/prerequisite_state.clj
Expand Up @@ -2,7 +2,6 @@
midje.data.prerequisite-state
(:use midje.clojure.core
[midje.util.object-utils :only [object-name]]
midje.util.form-utils
[midje.checking.extended-equality :only [extended-= extended-list-=]]
[midje.util.thread-safe-var-nesting :only [namespace-values-inside-out
with-altered-roots]]
Expand Down
6 changes: 3 additions & 3 deletions src/midje/error_handling/background_validations.clj
Expand Up @@ -5,13 +5,13 @@
validation-error-report-form validate when-valid]]
[midje.parsing.util.arrows :only [start-of-checking-arrow-sequence? take-arrow-sequence]]
[midje.parsing.1-to-explicit-form.background :only [seq-headed-by-setup-teardown-form?]]
[midje.parsing.1-to-explicit-form.prerequisites :only [metaconstant-prerequisite?]]
[midje.util.form-utils :only [def-many-methods]]))
[midje.parsing.1-to-explicit-form.prerequisites :only [metaconstant-prerequisite?]])
(:require [midje.util.pile :as pile]))

(def #^:private possible-wrapping-targets #{:facts, :contents, :checks })
(def #^:private possible-state-descriptions #{"before" "after" "around"})

(def-many-methods validate ["before" "after" "around"] [[state-description wrapping-target expression :as form]]
(pile/def-many-methods validate ["before" "after" "around"] [[state-description wrapping-target expression :as form]]
(cond
(and (#{"after" "around"} (name state-description)) (not= 3 (count form)))
(validation-error-report-form form
Expand Down
10 changes: 5 additions & 5 deletions src/midje/parsing/0_to_fact_form/formulas.clj
Expand Up @@ -7,9 +7,9 @@
[midje.parsing.1-to-explicit-form.future-facts :only [future-prefixes]]
[clojure.algo.monads :only [domonad]]
[clojure.string :only [join]]
[midje.util.form-utils]
[clojure.walk :only [prewalk]])
(:require [midje.emission.boundaries :as emission-boundary]
(:require [midje.util.pile :as pile]
[midje.emission.boundaries :as emission-boundary]
[midje.emission.api :as emit]
[midje.emission.state :as state]
[midje.emission.plugins.silence :as emission-silence]))
Expand All @@ -34,8 +34,8 @@
`(midje.sweet/fact ~docstring ~@body))

(defn- deconstruct-formula-args [args]
(let [[docstring? more-args] (pop-docstring args)
[opts-map [bindings & body]] (pop-opts-map more-args)]
(let [[docstring? more-args] (pile/pop-docstring args)
[opts-map [bindings & body]] (pile/pop-opts-map more-args)]
[docstring? opts-map bindings body]))


Expand Down Expand Up @@ -88,7 +88,7 @@


(defmacro generate-future-formula-variants []
(macro-for [name future-formula-variant-names]
(pile/macro-for [name future-formula-variant-names]
`(defmacro ~(symbol name)
"ALPHA/EXPERIMENTAL (subject to change)
Formula that will not be run. Generates 'WORK TO DO' report output as a reminder."
Expand Down
6 changes: 3 additions & 3 deletions src/midje/parsing/1_to_explicit_form/facts.clj
Expand Up @@ -22,12 +22,12 @@
against-background-facts-and-checks-wrappers
against-background?]]
[midje.parsing.1-to-explicit-form.metaconstants :only [predefine-metaconstants-from-form]]
[midje.util.form-utils :only [def-many-methods]]
[midje.util.laziness :only [eagerly]]
[midje.parsing.util.zip :only [skip-to-rightmost-leaf]]
[swiss-arrows.core :only [-<>]])
(:require [clojure.zip :as zip])
(:require [midje.checking.facts :as fact-checking]
(:require [midje.util.pile :as pile]
[midje.checking.facts :as fact-checking]
[midje.data.compendium :as compendium]
[midje.parsing.1-to-explicit-form.future-facts :as parse-future-facts]
[midje.parsing.2-to-lexical-maps.folded-fakes :as parse-folded-fakes]
Expand Down Expand Up @@ -155,7 +155,7 @@

;;; There could be validation here, but none has proven useful.

(def-many-methods validate ["fact" "facts"] [[fact-or-facts & args :as form]]
(pile/def-many-methods validate ["fact" "facts"] [[fact-or-facts & args :as form]]
;; Removed the check for no arrow because (1) it gives me too many false
;; positives and (2) doesn't fit with new handling of tabulate. Replace
;; someday with a version that correctly detects forms like this:
Expand Down
6 changes: 3 additions & 3 deletions src/midje/parsing/1_to_explicit_form/future_facts.clj
@@ -1,8 +1,8 @@
(ns ^{:doc "Parsing future-facts."}
midje.parsing.1-to-explicit-form.future-facts
(:use midje.parsing.util.core)
(:use [midje.util.form-utils :only [macro-for]])
(:require [midje.parsing.util.file-position :as position]
(:require [midje.util.pile :as pile]
[midje.parsing.util.file-position :as position]
[midje.data.nested-facts :as nested-facts]
[midje.parsing.1-to-explicit-form.metadata :as parse-metadata]
[midje.emission.api :as emit]))
Expand All @@ -17,7 +17,7 @@
(str prefix fact-or-facts)))

(defmacro generate-variants []
(macro-for [name future-fact-variant-names]
(pile/macro-for [name future-fact-variant-names]
`(defmacro ~(symbol name)
"Fact that will not be run. Generates 'WORK TO DO' report output as a reminder."
{:arglists '([& forms])}
Expand Down
7 changes: 3 additions & 4 deletions src/midje/parsing/2_to_lexical_maps/examples.clj
Expand Up @@ -7,8 +7,6 @@
[midje.checkers :only [exactly]]
[midje.checking.checkers.defining :only [checker? checker-makers]]
[midje.parsing.1-to-explicit-form.expects :only [expect? up-to-full-expect-form]]
[midje.util.form-utils :only [map-difference
def-many-methods ]]
[midje.checking.extended-equality :only [extended-= extended-list-=]]
[midje.parsing.util.file-position :only [user-file-position]]
[midje.util.thread-safe-var-nesting :only [namespace-values-inside-out
Expand All @@ -19,7 +17,8 @@
midje.error-handling.validation-errors
midje.error-handling.semi-sweet-validations
[clojure.tools.macro :only [macrolet]])
(:require [midje.data.metaconstant :as metaconstant]
(:require [midje.util.pile :as pile]
[midje.data.metaconstant :as metaconstant]
[midje.data.nested-facts :as nested-facts]
[clojure.zip :as zip]
[midje.config :as config]
Expand All @@ -32,7 +31,7 @@
(defmulti expect-expansion (fn [_call-form_ arrow & _rhs_]
(name arrow)))

(def-many-methods expect-expansion [=> =not=> =deny=>]
(pile/def-many-methods expect-expansion [=> =not=> =deny=>]
[call-form arrow expected-result fakes overrides]
`(let [check# (lexical-maps/example ~call-form ~arrow ~expected-result ~overrides)]
(midje.checking.examples/check-one check# ~fakes)))
Expand Down
1 change: 0 additions & 1 deletion src/midje/parsing/2_to_lexical_maps/fakes.clj
Expand Up @@ -7,7 +7,6 @@
[midje.checkers :only [exactly]]
[midje.checking.checkers.defining :only [checker? checker-makers]]
[midje.parsing.1-to-explicit-form.expects :only [expect? up-to-full-expect-form]]
[midje.util.form-utils :only [map-difference]]
[midje.checking.extended-equality :only [extended-= extended-list-=]]
[midje.parsing.util.file-position :only [user-file-position]]
[midje.util.thread-safe-var-nesting :only [namespace-values-inside-out
Expand Down
4 changes: 2 additions & 2 deletions src/midje/parsing/2_to_lexical_maps/folded_fakes.clj
@@ -1,9 +1,9 @@
(ns ^{:doc "Unfolding prerequisites like `(f (g 1)) => 3`"}
midje.parsing.2-to-lexical-maps.folded-fakes
(:use midje.parsing.util.zip
[midje.util.form-utils :only [map-difference]]
[midje.checking.checkers.defining :only [checker? checker-makers]])
(:require [clojure.zip :as zip]
[midje.util.pile :as pile]
[midje.parsing.1-to-explicit-form.expects :as expects]
[midje.parsing.util.fnref :as fnref]))

Expand Down Expand Up @@ -79,7 +79,7 @@
(let [overrides (drop 4 target)
augmented-substitutions (augment-substitutions substitutions target)
flattened-target (flatten-fake target augmented-substitutions)
generated-fakes (generate-fakes (map-difference augmented-substitutions substitutions) overrides)]
generated-fakes (generate-fakes (pile/map-difference augmented-substitutions substitutions) overrides)]
[(conj finished flattened-target),
(concat generated-fakes (rest pending)),
augmented-substitutions]))))
Expand Down
2 changes: 1 addition & 1 deletion src/midje/parsing/lexical_maps.clj
Expand Up @@ -29,7 +29,7 @@
:function-under-test (clojure.core/fn [] (cons a [2])),
:description (midje.data.nested-facts/descriptions)}
{:arrow '=>, :call-form '(cons a [2])}
(midje.util.form-utils/hash-map-duplicates-ok
(midje.clojure.core/hash-map-duplicates-ok
:position
(midje.parsing.util.file-position/line-number-known 2)))
) ; ---------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions src/midje/parsing/other/arglists.clj
Expand Up @@ -5,7 +5,7 @@
[midje.error-handling.exceptions :only [user-error]])
(:require [midje.emission.levels :as levels]
[midje.config :as config]
[midje.util.form-utils :as form]
[midje.util.pile :as pile]
[midje.data.fact :as fact]))


Expand Down Expand Up @@ -40,15 +40,15 @@

(defn desired-fact-predicate-from [desireds]
(vary-meta
(form/any-pred-from (map appropriate-matcher-for desireds))
(pile/any-pred-from (map appropriate-matcher-for desireds))
assoc :created-from desireds))


(defn separate-filters
([args plain-argument?]
(let [[filters remainder]
(separate #(and (not (plain-argument? %))
((form/any-pred-from [string? regex? fn? keyword?]) %))
((pile/any-pred-from [string? regex? fn? keyword?]) %))
args)]
[filters
(desired-fact-predicate-from filters)
Expand Down
3 changes: 1 addition & 2 deletions src/midje/parsing/util/arrows.clj
Expand Up @@ -2,8 +2,7 @@
midje.parsing.util.arrows
(:use midje.clojure.core
midje.parsing.util.core
midje.parsing.arrow-symbols
[midje.util form-utils])
midje.parsing.arrow-symbols)
(:require [clojure.zip :as zip]))

;; Arrow groupings
Expand Down
3 changes: 1 addition & 2 deletions src/midje/parsing/util/fnref.clj
@@ -1,8 +1,7 @@
(ns ^{:doc "A fnref is the first symbol-or-var in a list. These utilities
allow you to interpret it in multiple ways."}
midje.parsing.util.fnref
(:use midje.clojure.core
[midje.util.form-utils]))
(:use midje.clojure.core))


(defn classify-function-reference [reference]
Expand Down
1 change: 0 additions & 1 deletion src/midje/repl.clj
Expand Up @@ -13,7 +13,6 @@
[midje.emission.boundaries :as emission-boundary]
[midje.emission.colorize :as color]
[midje.emission.api :as emit]
[midje.util.form-utils :as form]
[midje.util.ecosystem :as ecosystem]
[midje.util.scheduling :as scheduling]))

Expand Down
7 changes: 4 additions & 3 deletions src/midje/semi_sweet.clj
Expand Up @@ -3,7 +3,7 @@
midje.semi-sweet
(:use midje.clojure.core
midje.data.prerequisite-state
[midje.util debugging form-utils]
[midje.util debugging]
[midje.emission.deprecation :only [deprecate]]
midje.error-handling.validation-errors
midje.error-handling.semi-sweet-validations
Expand All @@ -13,7 +13,8 @@
midje.production-mode
[clojure.algo.monads :only [domonad]]
[clojure.string :only [join]])
(:require [midje.data.nested-facts :as nested-facts]
(:require [midje.util.pile :as pile]
[midje.data.nested-facts :as nested-facts]
[midje.parsing.lexical-maps :as lexical-maps]
[midje.emission.api :as emit]
midje.checking.examples
Expand All @@ -29,7 +30,7 @@
;;; Interface: unfinished

(letfn [(unfinished* [names]
(macro-for [name names]
(pile/macro-for [name names]
`(do
(defn ~name [& args#]
(let [pprint# (partial cl-format nil "~S")]
Expand Down
1 change: 0 additions & 1 deletion src/midje/sweet.clj
Expand Up @@ -12,7 +12,6 @@
midje.error-handling.exceptions
midje.error-handling.validation-errors
midje.util.debugging
[midje.util.form-utils :only [macro-for]]
[midje.parsing.util.wrapping :only [put-wrappers-into-effect]]
[midje.parsing.util.file-position :only [set-fallback-line-number-from]]
[midje.parsing.1-to-explicit-form.facts :only [complete-fact-transformation
Expand Down

0 comments on commit 1c1ee9a

Please sign in to comment.