diff --git a/src/pluto/reader/destructuring.cljc b/src/pluto/reader/destructuring.cljc index 1035fd4..0fab7a6 100644 --- a/src/pluto/reader/destructuring.cljc +++ b/src/pluto/reader/destructuring.cljc @@ -76,5 +76,7 @@ * :errors, a vector of errors encountered during the destructuring" [bindings s] (cond - (sequential? s) (destructure-seq bindings s) - (map? s) (destructure-assoc bindings s))) + (sequential? bindings) + (destructure-seq bindings s) + (map? bindings) + (destructure-assoc bindings s))) diff --git a/test/pluto/reader/destructuring_test.cljc b/test/pluto/reader/destructuring_test.cljc index 0922b0a..a128e82 100644 --- a/test/pluto/reader/destructuring_test.cljc +++ b/test/pluto/reader/destructuring_test.cljc @@ -17,6 +17,8 @@ (is (= {:data '{all [1 2 3]}} (destructuring/destructure-seq '[_ _ _ :as all] [1 2 3])))) (deftest destructure-assoc + (is (= {:data '{a nil b nil}} + (destructuring/destructure-assoc '{a :a b :b} nil))) (is (= {:data '{a 1 b 2}} (destructuring/destructure-assoc '{a :a b :b} {:a 1 :b 2}))) #_ @@ -35,6 +37,7 @@ (destructuring/destructure-assoc '{a :a b :b c [:c 4] :as all} {:a 1 :b 2 :d 3})))) (deftest destructure + (is (= {:data '{a nil}} (destructuring/destructure '{a :a} nil))) (is (= {:data '{a 1}} (destructuring/destructure '[a] [1]))) (is (= {:data '{a 1 b 2}} (destructuring/destructure '[a {b :b}] [1 {:b 2}]))) (is (= {:data '{a 1 b 2 c 3}} (destructuring/destructure '[a [b [c]]] [1 [2 [3]]])))