Skip to content
Browse files

Move object-utils into pile.clj

  • Loading branch information...
1 parent 1c1ee9a commit 65aef4f28bea4d134aa13c7db360928aeb32689d @marick committed Jan 27, 2013
View
9 src/midje/checking/checkers/collection_comparison.clj
@@ -4,7 +4,6 @@
midje.checking.checkers.collection-comparison
(:use midje.clojure.core
[clojure.math.combinatorics :only [permutations]]
- [midje.util.object-utils :only [function-name named-function?]]
[midje.checking.checkers collection-util util chatty defining]
midje.checking.extended-equality)
(:require [clojure.string :as str]
@@ -54,8 +53,8 @@
comparison
expected
(fn [item]
- (if (named-function? item)
- (function-name item)
+ (if (pile/named-function? item)
+ (pile/function-name item)
(pr-str item)))
" (in that order)"))
@@ -64,8 +63,8 @@
comparison
(vals expected)
(fn [[k v]]
- (if (named-function? v)
- (str (pr-str k) " " (function-name v))
+ (if (pile/named-function? v)
+ (str (pr-str k) " " (pile/function-name v))
(str (pr-str k) " " (pr-str v))))
"")))
View
6 src/midje/checking/checkers/util.clj
@@ -1,9 +1,9 @@
(ns midje.checking.checkers.util
- (:use midje.clojure.core
- [midje.util.object-utils :only [name-object]]))
+ (:use midje.clojure.core)
+ (:require [midje.util.pile :as pile]))
(defn named-as-call
"Adds a string name that looks like a function call to
a function's metadata under :name"
[name expected function]
- (name-object function (format "(%s %s)" name expected)))
+ (pile/name-object function (format "(%s %s)" name expected)))
View
12 src/midje/data/prerequisite_state.clj
@@ -1,15 +1,15 @@
(ns ^{:doc "The semi-sweet representation of provided forms."}
midje.data.prerequisite-state
(:use midje.clojure.core
- [midje.util.object-utils :only [object-name]]
[midje.checking.extended-equality :only [extended-= extended-list-=]]
[midje.util.thread-safe-var-nesting :only [namespace-values-inside-out
with-altered-roots]]
[midje.emission.deprecation :only [deprecate]]
- [midje.parsing.arrow-symbols]
- [clojure.tools.macro :only [macrolet]])
- (:require [midje.data.metaconstant :as metaconstant]
+ [midje.parsing.arrow-symbols])
+ (:require [clojure.tools.macro :as macro]
[midje.config :as config]
+ [midje.util.pile :as pile]
+ [midje.data.metaconstant :as metaconstant]
[midje.emission.api :as emit]
[midje.parsing.2-to-lexical-maps.fakes :as parse-fakes])
(:import midje.data.metaconstant.Metaconstant))
@@ -72,7 +72,7 @@
(default-function fake-with-usable-default))))
(defn- ^{:testable true } handle-mocked-call [function-var actual-args fakes]
- (macrolet [(counting-nested-calls [& forms]
+ (macro/macrolet [(counting-nested-calls [& forms]
`(try
(swap! *call-action-count* inc)
~@forms
@@ -103,7 +103,7 @@
(defn- data-fakes-binding-map [data-fakes]
(apply merge-with metaconstant/merge-metaconstants (for [{:keys [var contained]} data-fakes]
- {var (Metaconstant. (object-name var) contained)})))
+ {var (Metaconstant. (pile/object-name var) contained)})))
(defn binding-map [fakes]
(let [[data-fakes fn-fakes] (separate :data-fake fakes)]
View
10 src/midje/emission/plugins/util.clj
@@ -2,12 +2,12 @@
midje.emission.plugins.util
(:use midje.clojure.core
[clojure.repl :only [demunge]])
- (:require [midje.emission.clojure-test-facade :as ctf]
+ (:require [clojure.string :as str]
+ [midje.util.pile :as pile]
+ [midje.emission.clojure-test-facade :as ctf]
[midje.emission.colorize :as color]
[midje.error-handling.exceptions :as exception]
- [midje.util.object-utils :as object]
- gui-diff.internal
- [clojure.string :as str]))
+ gui-diff.internal))
;; The theory here was that using clojure.test output would allow text
@@ -51,7 +51,7 @@
;; rebinding `#'foo` does not change the value of `foo`. Having been reminded
;; occasionally that she's working with vars might help a perplexed user
;; become unperplexed.
- (let [name (object/object-name prerequisite-var)]
+ (let [name (pile/object-name prerequisite-var)]
(if name
(str "#'" name)
(pr-str prerequisite-var))))
View
23 src/midje/parsing/2_to_lexical_maps/examples.clj
@@ -3,27 +3,16 @@
(:use midje.clojure.core
midje.parsing.util.core
midje.parsing.util.zip
- [midje.util.object-utils :only [object-name]]
- [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.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
- with-altered-roots]]
- [midje.parsing.util.wrapping :only [with-wrapping-target]]
- [clojure.algo.monads :only [defmonad domonad]]
+ [clojure.algo.monads :only [domonad]]
[midje.parsing.arrow-symbols]
midje.error-handling.validation-errors
- midje.error-handling.semi-sweet-validations
- [clojure.tools.macro :only [macrolet]])
- (:require [midje.util.pile :as pile]
- [midje.data.metaconstant :as metaconstant]
- [midje.data.nested-facts :as nested-facts]
- [clojure.zip :as zip]
+ midje.error-handling.semi-sweet-validations)
+ (:require [clojure.zip :as zip]
[midje.config :as config]
- [midje.parsing.util.fnref :as fnref]
+ [midje.util.pile :as pile]
[midje.error-handling.exceptions :as exceptions]
+ [midje.data.metaconstant :as metaconstant]
+ [midje.data.nested-facts :as nested-facts]
[midje.parsing.lexical-maps :as lexical-maps]
[midje.emission.api :as emit])
(:import midje.data.metaconstant.Metaconstant))
View
21 src/midje/parsing/2_to_lexical_maps/fakes.clj
@@ -3,28 +3,13 @@
(:use midje.clojure.core
midje.parsing.util.core
midje.parsing.util.zip
- [midje.util.object-utils :only [object-name]]
- [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.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
- with-altered-roots]]
- [midje.parsing.util.wrapping :only [with-wrapping-target]]
- [clojure.algo.monads :only [defmonad domonad]]
[midje.parsing.arrow-symbols]
midje.error-handling.validation-errors
- midje.error-handling.semi-sweet-validations
- [clojure.tools.macro :only [macrolet]])
- (:require [midje.data.metaconstant :as metaconstant]
- [clojure.zip :as zip]
- [midje.config :as config]
- [midje.parsing.util.fnref :as fnref]
+ midje.error-handling.semi-sweet-validations)
+ (:require [midje.parsing.util.fnref :as fnref]
[midje.error-handling.exceptions :as exceptions]
[midje.parsing.lexical-maps :as lexical-maps]
- [midje.emission.api :as emit])
- (:import midje.data.metaconstant.Metaconstant))
+ [midje.emission.api :as emit]))
(defn fake? [form]
(or (first-named? form "fake")
View
14 src/midje/util/object_utils.clj
@@ -1,14 +0,0 @@
-(ns ^{:doc "Functions having to do with looking at an object at runtime."}
- midje.util.object-utils)
-
-(defn named-function? [x]
- (:name (meta x)))
-
-(defn object-name [obj]
- (:name (meta obj)))
-
-(defn function-name [funobj]
- (object-name funobj))
-
-(defn name-object [object name]
- (vary-meta object assoc :name name))
View
15 src/midje/util/pile.clj
@@ -3,6 +3,21 @@
midje.util.pile
(:use midje.clojure.core))
+;;; Named things
+
+(defn named-function? [x]
+ (:name (meta x)))
+
+(defn object-name [obj]
+ (:name (meta obj)))
+
+(defn function-name [funobj]
+ (object-name funobj))
+
+(defn name-object [object name]
+ (vary-meta object assoc :name name))
+
+
;;; Maps
(defn tack-on-to

0 comments on commit 65aef4f

Please sign in to comment.
Something went wrong with that request. Please try again.