Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report error when attempting prerequisite for private function #141

Merged
merged 2 commits into from
Jun 15, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/midje/error_handling/semi_sweet_validations.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
[midje.util.form-utils :only [fnref-var-object]]))

(letfn [(compiler-will-inline-fn? [fnref]
(contains? (meta (fnref-var-object fnref)) :inline))]
(contains? (meta (fnref-var-object fnref)) :inline))
(exposed-testable? [fnref]
(contains? (meta (fnref-var-object fnref)) :testable))]

(defmethod validate "fake" [[_fake_ & fake-form :as form]]
(let [funcall (first fake-form)]
Expand All @@ -23,6 +25,14 @@
form
(cl-format nil "You cannot override the function `~S`: it is inlined by the Clojure compiler." (first funcall)))

(exposed-testable? (first funcall))
(validation-error-report-form
form
"A prerequisite cannot be specified on a function exposed via expose-testables."
(cl-format nil "Instead, specify it directly on the var: #'~S/~S"
(-> (first funcall) fnref-var-object meta :ns ns-name)
(first funcall)))

:else
form))))

Expand Down