Skip to content

Commit

Permalink
Line numbers are now correct on alternate arrow forms.
Browse files Browse the repository at this point in the history
  • Loading branch information
marick committed Mar 24, 2011
1 parent 1c1612a commit 103e7dd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/midje/midje_forms/translating.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
(:use clojure.contrib.def
[clojure.contrib.seq :only [separate]]
midje.metaconstants
[midje.semi-sweet :only [all-arrows]]
[midje.util thread-safe-var-nesting wrapping form-utils laziness form-utils]
[midje.util.file-position :only [arrow-line-number]]
[midje.midje-forms building recognizing dissecting moving-around editing]
Expand All @@ -17,7 +18,7 @@
(loop [loc (zip/seq-zip form)]
(if (zip/end? loc)
(zip/root loc)
(recur (zip/next (cond (namespacey-match '(=>) loc)
(recur (zip/next (cond (namespacey-match all-arrows loc)
(add-line-number-to-end-of-arrow-sequence__then__no-movement
(arrow-line-number loc) loc)

Expand Down
1 change: 1 addition & 0 deletions src/midje/semi_sweet.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

(def expect-arrows [=> =not=> =deny=> =future=>])
(def fake-arrows [=> =streams=>])
(def all-arrows (concat expect-arrows fake-arrows))

(defn check-for-arrow [arrow]
(get {=> :check-match
Expand Down
7 changes: 1 addition & 6 deletions test/behaviors/t_line_number_reporting.clj
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,9 @@
(+ 1 1) =deny=> 2
(+ 1 1) =not=> 2
(+ 1 "1") =future=> "2")
(future-fact @reported => (just (contains {:position ["t_line_number_reporting.clj"
(fact @reported => (just (contains {:position ["t_line_number_reporting.clj"
(+ variant-position 3)]})
(contains {:position ["t_line_number_reporting.clj"
(+ variant-position 4)]})
(contains {:position ["t_line_number_reporting.clj"
(+ variant-position 5)]}))))

(future-fact "line-number-handling for =streams=>")



12 changes: 10 additions & 2 deletions test/midje/midje_forms/t_translating.clj
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,16 @@
(f 2) midje.sweet/=> midje.midje-forms.t-translating/a :position (midje.util.file-position/line-number-known 35))]
actual => expected))



(fact "various arrow forms have line numbers"
(let [original `(
(~(with-meta '(f 1) {:line 33}) => 2)
(~(with-meta '(f 1) {:line 33}) =not=> 2)
(~(with-meta '(f 1) {:line 33}) =streams=> 2)
(~(with-meta '(f 1) {:line 33}) =future=> 2))
actual (add-line-numbers original)]
(doseq [expansion actual]
(take-last 2 expansion)
=> '(:position (midje.util.file-position/line-number-known 33)))))

;; Translating sweet forms into their semi-sweet equivalent

Expand Down

0 comments on commit 103e7dd

Please sign in to comment.