Skip to content

Instantly share code, notes, and snippets.

@rboyd
Created January 15, 2013 16:21
Show Gist options
  • Save rboyd/4539826 to your computer and use it in GitHub Desktop.
Save rboyd/4539826 to your computer and use it in GitHub Desktop.
@gfredericks_ protocol/record code for mocking java obj to check for call
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