diff options
author | fogus <mefogus@gmail.com> | 2010-11-19 20:16:32 -0500 |
---|---|---|
committer | Stuart Halloway <stu@thinkrelevance.com> | 2010-11-29 21:07:40 -0500 |
commit | 3a3bf705c6d8029f98f82b8cc1d7a3030a3cf5d3 (patch) | |
tree | 6a0ac01936ce717715b9ec473bd82761fc1a4b6e | |
parent | 4ea0cfa7892a5062066a0e56cc789023a064b6d2 (diff) |
Added tests and updated docs for init-proxy and update-proxy. Also updated the docstrings.
Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
-rw-r--r-- | src/clj/clojure/core_proxy.clj | 5 | ||||
-rw-r--r-- | test/clojure/test_clojure/java_interop.clj | 15 |
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) |