Created
January 15, 2013 16:21
-
-
Save rboyd/4539826 to your computer and use it in GitHub Desktop.
@gfredericks_ protocol/record code for mocking java obj to check for call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clobal=> (defprotocol IFoo (foo [this])) | |
IFoo | |
clobal=> (defrecord MyClass [state] (foo [this] (swap! state assoc :foo :called))) | |
ClassCastException clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol clojure.core/ns-resolve (core.clj:3944) | |
clobal=> (defrecord MyClass [state] IFoo (foo [this] (swap! state assoc :foo :called))) | |
clobal.MyClass | |
clobal=> (def ob (MyClass. (atom {}))) | |
#'clobal/ob | |
clobal=> @(.state ob) | |
{} | |
clobal=> (.foo ob) | |
{:foo :called} | |
clobal=> @(.state ob) | |
{:foo :called} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment