32f5d5dea7
This changes with syntax from (with [[x (expr)] (expr)] ...) to (with [x (expr) (expr)] ...). Should have no ill side effects apart from the syntax change. Closes #852. Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
36 lines
1.0 KiB
Hy
36 lines
1.0 KiB
Hy
(import [hy.contrib.walk [*]])
|
|
|
|
(def walk-form '(print {"foo" "bar"
|
|
"array" [1 2 3 [4]]
|
|
"something" (+ 1 2 3 4)
|
|
"cons!" (cons 1 2)
|
|
"quoted?" '(foo)}))
|
|
|
|
(defn collector [acc x]
|
|
(.append acc x)
|
|
nil)
|
|
|
|
(defn test-walk-identity []
|
|
(assert (= (walk identity identity walk-form)
|
|
walk-form)))
|
|
|
|
(defn test-walk []
|
|
(let [acc '()]
|
|
(assert (= (walk (partial collector acc) identity walk-form)
|
|
[nil nil]))
|
|
(assert (= acc walk-form)))
|
|
(let [acc []]
|
|
(assert (= (walk identity (partial collector acc) walk-form)
|
|
nil))
|
|
(assert (= acc [walk-form]))))
|
|
|
|
(defn test-walk-iterators []
|
|
(let [acc []]
|
|
(assert (= (walk (fn [x] (* 2 x)) (fn [x] x)
|
|
(drop 1 [1 [2 [3 [4]]]]))
|
|
[[2 [3 [4]] 2 [3 [4]]]]))))
|
|
|
|
(defn test-macroexpand-all []
|
|
(assert (= (macroexpand-all '(with [a 1 b 2 c 3] (for [d c] foo)))
|
|
'(with* [a 1] (with* [b 2] (with* [c 3] (do (for* [d c] (do foo)))))))))
|