Hi all, for testing my FunQL clojure graph query language against another query language (GReQL), I want to write tests like that:
(defcomparisontest class-count-restricted (gbjg) ;; GReQL version "count(V{ClassDefinition})" ;; FunQL variant 1 (vcount (gbjg) :cls 'ClassDefinition) ;; FunQL variant 2 (count (vseq (gbjg) :cls 'ClassDefinition))) So you provide the name of the test, the graph the query is evaluated on, a GReQL reference query, and arbitrary many FunQL forms that have to calculate the exact same result. I had such a macro that expects exactly one funql form, but while trying to extend that to arbitrary many funqls, I've reached the limit of my macro foo. That's what I have come up with: (defmacro defcomparisontest "Define a GReQL/FunQL comparison test with name n on graph g that asserts the equality of the results evaluating greql and all funqls." [n g greql & funqls] `(deftest ~n ~g ;; ensure the graph is loaded, if it is given as memoized function. (println "####################################################") (println "Comparison test:" ~(name n)) (let [gr# (do (print "GReQL evaluation time:") (jvalue-unpack (time (greql-eval ~g ~greql))))] (doseq [funql# '~funqls] (print "FunQL evaluation time:") (is (= gr# (time (let [r# funql#] (if (instance? clojure.lang.LazySeq r#) (doall r#) r#))))))))) Here, the problem is that the comparison compares the evaluation result of the greql query against gr# the unevaluated funql form. So I replaced the "(let [r# funql#]" with "(let [r# (eval funql#)]", but then I seem to have namespace issues. I get errors like java.lang.Exception: Unable to resolve symbol: vcount in this context java.lang.Exception: Unable to resolve symbol: vseq in this context which both are functions defined in funql.core, which my funql.test.core namespace uses; (:use [funql.core] :reload) in the ns definition. Could anyone with some advanced macro foo enlighten me how to do it right? By the way: in general, I would prefer if the expansion would contain a sequence of (do ...) blocks with one assertion, one for each funql in funqls, instead of the doseq. Thanks a bunch in advance! Tassilo -- 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