I just saw one of the "Rich Negotiations" on clojure.spec and really want to try it on my project. I am writing a series of tools for parsing C code using the eclipse CDT library , and I would like to indicate that my functions receive and emit AST Objects.
I think a very simple specification can be written for a function that takes the AST root and emits all the leaves of the tree as follows:
(import '(org.eclipse.cdt.core.dom.ast IASTNode))
(require '[clojure.spec :as s])
(defn ast-node? [node] (instance? IASTNode node))
(s/def ::ast-node ast-node?)
(s/fdef leaves :args ::ast-node :ret (s/coll-of ::ast-node))
However, when I try to implement the code (s/exercise leaves), I get an error message:
Unable to construct gen at: [] for:
xxx.x$leaves@xxx
How can I write my own generator for Java objects for a complete specification and implementation of my code?