Skip to content

Commit

Permalink
Only walk var forms when the predicate passes
Browse files Browse the repository at this point in the history
  • Loading branch information
trptcolin committed Jun 23, 2014
1 parent fbf70b8 commit 02ec516
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/riddley/walk.clj
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
walk-exprs' (partial walk-exprs predicate handler special-form?)
x' (cond

(and (walkable? x) (= 'var (first x)))
(and (walkable? x) (= 'var (first x)) (predicate x))
(handler (eval x))

(and (walkable? x) (= 'quote (first x)))
Expand Down
15 changes: 12 additions & 3 deletions test/riddley/walk_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,19 @@
(deftest test-var-evaluation
(is (= #{#'riddley.walk-test/foo}
(let [acc (atom #{})]
(r/walk-exprs
(constantly false)
(r/walk-exprs
(constantly true)
#(do (swap! acc conj %) %)
'(#'riddley.walk-test/foo))
'#'riddley.walk-test/foo)
@acc))))

(deftest test-doesnt-walk-var-if-not-requested
(is (= #{}
(let [acc (atom #{})]
(r/walk-exprs
(constantly false)
#(do (swap! acc conj %) %)
'#'riddley.walk-test/foo)
@acc))))

(deftest catch-old-fn*-syntax
Expand Down

0 comments on commit 02ec516

Please sign in to comment.