Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

CLJS-493: get should accept any type

This patch introduces a default case for ILookup as per discussion on
the ticket. Tests are introduced for both direct and higher-order
calls.
  • Loading branch information...
commit 7b9fccd9a2502c1984c1880176a6b0d310151520 1 parent 1a094e4
@michalmarczyk michalmarczyk authored swannodette committed
Showing with 13 additions and 1 deletion.
  1. +6 −1 src/cljs/cljs/core.cljs
  2. +7 −0 test/cljs/cljs/core_test.cljs
View
7 src/cljs/cljs/core.cljs
@@ -815,7 +815,12 @@ reduces them without incurring seq initialization"
(extend-type default
IEquiv
- (-equiv [x o] (identical? x o)))
+ (-equiv [x o] (identical? x o))
+
+ ILookup
+ (-lookup [x k] nil)
+
+ (-lookup [x k not-found] not-found))
(defn conj
"conj[oin]. Returns a new collection with the xs
View
7 test/cljs/cljs/core_test.cljs
@@ -1836,5 +1836,12 @@
(assert (= [js/undefined 1 2] ((fn [& more] more) js/undefined 1 2)))
(assert (= [js/undefined 4 5] ((fn [a b & more] more) 1 2 js/undefined 4 5)))
+ ;; CLJS-493
+
+ (assert (nil? (get 42 :anything)))
+ (assert (identical? (get 42 :anything :not-found) :not-found))
+ (assert (nil? (first (map get [42] [:anything]))))
+ (assert (identical? (first (map get [42] [:anything] [:not-found])) :not-found))
+
:ok
)
Please sign in to comment.
Something went wrong with that request. Please try again.