Excellent, thanks! The actual macro is indeed a little more complicated, but the test assertions are limited to (is (= ...)), so replacing = with ~'= works perfectly.
On Tuesday, October 10, 2017 at 3:10:37 AM UTC-6, Gary Verhaegen wrote: > > is is looking for specific patterns and, if it can't find a known one, > defaults to assuming its argument is a random predicate and prints that. > > So what's happening here is the syntax quote expands (resolves) = to > clojure.core/= and thus it doesn't match the pattern for = anymore. > > So you'd need for = to not be expanded and stay as exactly the = symbol > after macroexpansion. There are various ways to achieve that, but I can't > think of a generic, elegant one. In the trivial example you posted you can > just replace = with ~'=, I think, though that might not be so easy on more > complex macros. > > You can also take a look at the assert-expr and report multimethods in > clojure.test. > > On 9 Oct 2017, at 22:32, Timothy Baldridge <tbald...@gmail.com > <javascript:>> wrote: > > The problem isn't the macro, it's your use of syntax quoting. `(= x y) > gets expanded at read-time into `(clojure.core/= x y)`. Not much you can do > about that. Although I'd suggest perhaps changing your code a bit to not > require macros. > > deftest mostly just creates a defn with some extra metadata and the like. > One option would be to use a dynamic var to setup your config information. > Or better yet have the test itself read the config data the way your normal > app would. This not only exercises the same config codepaths, but it also > keeps the code quite functional. > > On Mon, Oct 9, 2017 at 2:40 PM, Matt Grimm <matt.t...@gmail.com > <javascript:>> wrote: > >> Hello, >> >> I'm generating deftest's using a helper macro that takes a variety of >> test parameters and though the tests function correctly, the output of a >> failed test is not exactly right. The expect value is shown as the >> un-evaluated test form, and the actual value is shown as the result of >> evaluating the test form. I realize 'is' is a macro itself, but I'm not >> quite sure how to expand or escape the guts of my macro to make the output >> match that of a normal test. >> >> Whereas a normal test failure looks like this (some output elided): >> >> user=> (deftest normal-test >> #_=> (is (= [0 1 5] (range 3)))) >> #'user/normal-test >> user=> (run-tests) >> >> FAIL in (normal-test) >> >> expected: [0 1 5] >> actual: ((0 1 2)) >> >> A failure for a deftest defined within a macro comes out like this: >> >> user=> (defmacro defnesttest [v] >> #_=> `(deftest nested-test >> #_=> (is (= [0 1 5] ~v)))) >> #'user/defnesttest >> user=> (defnesttest (range 3)) >> #'user/nested-test >> user=> (run-tests) >> >> FAIL in (nested-test) >> >> expected: (clojure.core/= [0 1 5] (range 3)) >> actual: false >> >> Thanks for any insight, >> m. >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clo...@googlegroups.com >> <javascript:> >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> clojure+u...@googlegroups.com <javascript:> >> 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+u...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > “One of the main causes of the fall of the Roman Empire was that–lacking > zero–they had no way to indicate successful termination of their C > programs.” > (Robert Firth) > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clo...@googlegroups.com <javascript:> > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+u...@googlegroups.com <javascript:> > 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+u...@googlegroups.com <javascript:>. > For more options, visit https://groups.google.com/d/optout. > > -- 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/d/optout.