From 06f2a462c99e58d2f2b4d3de59baf79f98b84803 Mon Sep 17 00:00:00 2001 From: Brandon Bloom Date: Sun, 17 Jun 2012 23:44:39 -0700 Subject: [PATCH] Import memfn macro and add tests --- src/clj/cljs/core.clj | 2 +- test/cljs/cljs/core_test.cljs | 2 ++ 2 files changed, 3 insertions(+), 1 deletions(-) diff --git a/src/clj/cljs/core.clj b/src/clj/cljs/core.clj index 70c1509..d6ef171 100644 --- a/src/clj/cljs/core.clj +++ b/src/clj/cljs/core.clj @@ -40,7 +40,7 @@ doto extend-protocol fn for if-let if-not let letfn loop - or + memfn or when when-first when-let when-not while]) (def fast-path-protocols diff --git a/test/cljs/cljs/core_test.cljs b/test/cljs/cljs/core_test.cljs index eae66ac..7c97315 100644 --- a/test/cljs/cljs/core_test.cljs +++ b/test/cljs/cljs/core_test.cljs @@ -1291,12 +1291,14 @@ (assert (= 3 (. "abc" -length))) (assert (= "bc" (.substring s 1))) (assert (= "bc" (.substring "abc" 1))) + (assert (= "bc" ((memfn substring start) s 1))) (assert (= "bc" (. s substring 1))) (assert (= "bc" (. s (substring 1)))) (assert (= "bc" (. s (substring 1 3)))) (assert (= "bc" (.substring s 1 3))) (assert (= "ABC" (. s (toUpperCase)))) (assert (= "ABC" (. "abc" (toUpperCase)))) + (assert (= "ABC" ((memfn toUpperCase) s))) (assert (= "BC" (. (. s (toUpperCase)) substring 1))) (assert (= 2 (.-length (. (. s (toUpperCase)) substring 1))))) -- 1.7.9.1