summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/clj/clojure/core_proxy.clj5
-rw-r--r--test/clojure/test_clojure/java_interop.clj15
2 files changed, 18 insertions, 2 deletions
diff --git a/src/clj/clojure/core_proxy.clj b/src/clj/clojure/core_proxy.clj
index 8fe4517b..830f5ce8 100644
--- a/src/clj/clojure/core_proxy.clj
+++ b/src/clj/clojure/core_proxy.clj
@@ -273,7 +273,7 @@
correspond to methods of the proxy superclass/superinterfaces) to
fns (which must take arguments matching the corresponding method,
plus an additional (explicit) first arg corresponding to this, and
- sets the proxy's fn map."
+ sets the proxy's fn map. Returns the proxy."
{:added "1.0"}
[^IProxy proxy mappings]
(. proxy (__initClojureFnMappings mappings))
@@ -287,7 +287,8 @@
updates (via assoc) the proxy's fn map. nil can be passed instead of
a fn, in which case the corresponding method will revert to the
default behavior. Note that this function can be used to update the
- behavior of an existing instance without changing its identity."
+ behavior of an existing instance without changing its identity.
+ Returns the proxy."
{:added "1.0"}
[^IProxy proxy mappings]
(. proxy (__updateClojureFnMappings mappings))
diff --git a/test/clojure/test_clojure/java_interop.clj b/test/clojure/test_clojure/java_interop.clj
index 77ed538b..09273f50 100644
--- a/test/clojure/test_clojure/java_interop.clj
+++ b/test/clojure/test_clojure/java_interop.clj
@@ -118,6 +118,21 @@
; proxy, proxy-super
+(deftest test-proxy-chain
+ (testing "That the proxy functions can chain"
+ (are [x y] (= x y)
+ (-> (get-proxy-class Object)
+ construct-proxy
+ (init-proxy {})
+ (update-proxy {"toString" (fn [this] "chain chain chain")})
+ str)
+ "chain chain chain"
+
+ (-> (proxy [Object] [] (toString [] "superfuzz bigmuff"))
+ (update-proxy {"toString" (fn [this] "chain chain chain")})
+ str)
+ "chain chain chain")))
+
(deftest test-bases
(are [x y] (= x y)