(... don't you wish you could edit your post). And shoot, the last example should have been the following (I had forgot to remove the (constantly nil) parts:
*(def ^:dynamic *view* (atom* * {:old-model [nil nil nil nil nil nil]* * :quiz [nil nil nil nil nil nil nil]* * :loc nil}))* * * *(defn view [] @*view*)* * * *(defn random-loc []* * (let [loc (-> (view) :loc random-walk-loc)* * loc (if (= 0 (g/uniform 0 100)) (f/quiz) loc)]* * (swap! *view* assoc :loc loc)* * loc))* * * *(generative/defspec* * check-on-quiz-view* * b/quiz-view* * [^{:tag `random-loc} loc* * ^{:tag (clojure.core/constantly :ignored)} key* * ^{:tag `view} value])* On Friday, September 20, 2013 12:01:41 AM UTC-7, Stephen Cagle wrote: > > * > (ns com.samedhi.app.test.behavior-test > (:require > [clojure.test.generative :as generative]) > > (:use > [com.samedhi.quizry.app.test.defspec :only [defspec]] > )) > > * > *... ommited content ...* > * > * > *(def ^:dynamic *view* nil)* > * > * > *(binding [*view* (atom ;; > this is line 69* > * {:old-model [nil nil nil nil nil nil]* > * :quiz [nil nil nil nil nil nil nil]* > * :loc nil})]* > * * > * (defn view [] @*view*)* > * * > * (defn random-loc []* > * (let [loc (-> (view) :loc random-walk-loc)* > * loc (if (= 0 (g/uniform 0 100)) (f/new-loc) loc)]* > * (swap! *view* assoc :loc loc)* > * loc))* > * > * > * (generative/defspec* > * check-on-quiz-view* > * b/quiz-view* > * [^{:tag `random-loc} loc* > * ^{:tag (clojure.core/constantly :ignored)} key* > * ^{:tag `view} value]))* > > Gives me the error: > *Exception in thread "main" java.lang.RuntimeException: Can't embed > object in code, maybe print-dup not defined: Unbound: > #'com.samedhi.app.test.behavior-test/random-loc, > compiling:(com/samedhi/app/test/behavior_test.clj:69:1) > * > > I vaguely understand that this is saying that something in here does not > have a print-dup method on it, and as such, cannot be "codified". How do I > determine what the problem is? > > You might wonder why I am using a binding anyway? defspec is from > test.generative. This defspec is testing b/quiz-view with the supplied > argument vector. I have a dependency between the first argument (loc) and > the third argument (value), hence the shared atom. Furthermore, I wish each > succesive call to b/quiz-view to be a slight modification of the previous > value, where the loc has been randomly moved around a bit. Ocasionally (1 > in a 100), I just create a entirely new loc with f/new-loc. All of this > could have been done with a shared atom. However, it seems that > test.generative actually uses N-threads, which means I want each thread to > have its own atom. Hence, by my reasoning, the use of binding and > ^:dynamic. BTW, the tick before random-loc and view allows them to evaluate > in the the current namespace, as otherwise they would be evaluated in > clojure.core.generators (I don't really understand why). > > https://github.com/clojure/test.generative ;; just for reference > > I am obviously wrong in my implementation (it does not compile), I could > be wrong in my reasoning as well, but I am most worried about the fact that > I have no real idea *what* is not working here. Any help is appreciated. > -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.