Browse files

Renamed form-utils into pile (as in "pile o' stuff that doesn't have …

…a better place now).
  • Loading branch information...
1 parent a90c5ab commit 1c1ee9af36ad31243795cda85c0355de8e5ff84f @marick committed Jan 27, 2013
View
1 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
View
8 src/midje/checking/checkers/collection.clj
@@ -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})
@@ -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.
View
18 src/midje/checking/checkers/collection_comparison.clj
@@ -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.
@@ -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
@@ -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."
@@ -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 []}))
@@ -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)))
@@ -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)))
View
6 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
@@ -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
View
1 src/midje/checking/checkers/simple.clj
@@ -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]))
View
1 src/midje/checking/examples.clj
@@ -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]
View
1 src/midje/data/prerequisite_state.clj
@@ -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]]
View
6 src/midje/error_handling/background_validations.clj
@@ -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
View
10 src/midje/parsing/0_to_fact_form/formulas.clj
@@ -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]))
@@ -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]))
@@ -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."
View
6 src/midje/parsing/1_to_explicit_form/facts.clj
@@ -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]
@@ -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:
View
6 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]))
@@ -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])}
View
7 src/midje/parsing/2_to_lexical_maps/examples.clj
@@ -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
@@ -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]
@@ -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)))
View
1 src/midje/parsing/2_to_lexical_maps/fakes.clj
@@ -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
View
4 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]))
@@ -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]))))
View
2 src/midje/parsing/lexical_maps.clj
@@ -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)))
) ; ---------------------------------------------------------------
View
6 src/midje/parsing/other/arglists.clj
@@ -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]))
@@ -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)
View
3 src/midje/parsing/util/arrows.clj
@@ -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
View
3 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]
View
1 src/midje/repl.clj
@@ -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]))
View
7 src/midje/semi_sweet.clj
@@ -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
@@ -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
@@ -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")]
View
1 src/midje/sweet.clj
@@ -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
View
20 src/midje/util.clj
@@ -1,21 +1,21 @@
(ns ^{:doc "Utility code for testing private vars."}
midje.util
- (:use [midje.util.form-utils :only [macro-for]]))
+ (:require [midje.util.pile :as pile]))
(defmacro expose-testables
"Enables testing of vars in the target ns which have ^:testable metadata.
Note that the namespace names should not be quoted."
[target-ns]
- (macro-for [[sym var] (ns-interns target-ns)
- :when (:testable (meta var))]
- `(-> (def ~sym ~var)
- (alter-meta! merge (meta ~var)))))
+ (pile/macro-for [[sym var] (ns-interns target-ns)
+ :when (:testable (meta var))]
+ `(-> (def ~sym ~var)
+ (alter-meta! merge (meta ~var)))))
(defmacro testable-privates
"Intern into the current namespace the symbols from the specified namespace"
[namespace & symbols]
- (macro-for [sym symbols, :let [var (ns-resolve namespace sym)]]
- `(-> (def ~sym ~var)
- (alter-meta! merge
- (assoc (meta ~var)
- :testable true)))))
+ (pile/macro-for [sym symbols, :let [var (ns-resolve namespace sym)]]
+ `(-> (def ~sym ~var)
+ (alter-meta! merge
+ (assoc (meta ~var)
+ :testable true)))))
View
22 src/midje/util/form_utils.clj → src/midje/util/pile.clj
@@ -1,11 +1,9 @@
(ns ^{:doc "Functions that are somewhat general purpose, but seem too obscure to be in midje.clojure.core.
- A placeholder for wiser decisions someday."}
@AlexBaranosky
Collaborator
AlexBaranosky added a line comment Feb 2, 2013

Funnily enough, at Runa we have a analogous namespace called utils.homeless for all the things that don't have a home yet. Same principle there I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
- midje.util.form-utils
- (:use midje.clojure.core
- midje.parsing.util.core)
- (:require [clojure.zip :as zip]))
+ A cue to wiser placement decisions someday."}
+ midje.util.pile
+ (:use midje.clojure.core))
-;;; Maps
+ ;;; Maps
(defn tack-on-to
"Conj new values onto appropriate keys of a map"
@@ -18,7 +16,7 @@
(defn sort-map [m]
(into (sorted-map) m))
-;;; Sequences
+ ;;; Sequences
(defn apply-pairwise
"(apply-pairwise [inc dec] [1 1] [2 2]) => [ [2 0] [3 1] ]
@@ -29,8 +27,6 @@
functions)
arglists))
-
-
(defn pop-if
"Extracts optional arg (that we assume is present if the pred is true) from head of args"
[pred args]
@@ -48,9 +44,7 @@
-
-
-;;; Higher-order predicate helpers
+ ;;; Higher-order predicate helpers
(defn any-pred-from
"Returns a function that returns strictly true iff any
@@ -67,7 +61,7 @@
:else (recur remainder))))))
-;;; Definition helpers
+ ;;; Definition helpers
(defmacro macro-for
"Macroexpands the body once for each of the elements in the
@@ -85,5 +79,3 @@
`(defmethod ~name ~dval ~args
~@body)))
-
-
View
19 test/midje/parsing/2_to_lexical_maps/t_examples.clj
@@ -1,12 +1,11 @@
(ns midje.parsing.2-to-lexical-maps.t-examples
- (:use [clojure.test] ;; This is used to check production mode with deftest.
- [midje.sweet]
- [midje.parsing.2-to-lexical-maps.examples]
- [midje.util form-utils]
- [midje.test-util]
+ (:use clojure.test ;; This is used to check production mode with deftest.
+ midje.sweet
+ midje.parsing.2-to-lexical-maps.examples
+ midje.test-util
midje.util)
- (:require [clojure.zip :as zip]
- [midje.config :as config]
+ (:require [midje.config :as config]
+ [midje.util.pile :as pile]
[midje.emission.api :as emit]))
(expose-testables midje.parsing.2-to-lexical-maps.examples)
@@ -77,10 +76,10 @@
(fact "Note that lexical scoping is obeyed"
(count (:arg-matchers fake-1)) => 1
- (apply-pairwise (:arg-matchers fake-1) [5] [nil]) => [[true] [false]]
+ (pile/apply-pairwise (:arg-matchers fake-1) [5] [nil]) => [[true] [false]]
(count (:arg-matchers fake-2)) => 2
- (apply-pairwise (:arg-matchers fake-2) [5 5] [1 1]) => [ [false true]
- [true false] ])
+ (pile/apply-pairwise (:arg-matchers fake-2) [5 5] [1 1]) => [ [false true]
+ [true false] ])
(fact "Result supplied"
((:result-supplier fake-0)) => 2
View
3 test/midje/test_util.clj
@@ -3,8 +3,7 @@
midje.checkers
[midje.checking.extended-equality :only [extended-=]]
[midje.checking.extended-falsehood :only [extended-false?]]
- midje.error-handling.exceptions
- [midje.util.form-utils :only [macro-for]])
+ midje.error-handling.exceptions)
(:require midje.clojure.core
[midje.config :as config]
[clojure.string :as str]
View
4 test/midje/util/t_form_utils.clj → test/midje/util/t_pile.clj
@@ -1,5 +1,5 @@
-(ns midje.util.t-form-utils
- (:use [midje.util.form-utils])
+(ns midje.util.pile
+ (:use [midje.util.pile])
(:use [midje.sweet])
(:use [midje.test-util]))

0 comments on commit 1c1ee9a

Please sign in to comment.