Re: Custom test assertions in ClojureScript
Self-hosted should work the same way but it does require compiling the macro namespace in an extra step (ie. the $macros ns is created separately). I don't know how this is done for regular self-hosted. shadow-cljs has an extra build step for this that should take care of creating everything. -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/clojure/4c3edc2b-fb40-494c-a1e9-4ec071af722c%40googlegroups.com.
Re: Custom test assertions in ClojureScript
Thanks Thomas, That was very helpful. I tried your suggestion and it works in JVM ClojureScript. That method does not work on bootstrapped ClojureScript though. As far as I understand this is a result of bootstrapped ClojureScript evaluating the .clj(c) file in the same JavaScript environment. Bootstrapped ClojureScript tries to emulate the separate compilation phase by putting all vars defined in the .clj file in a new namespace ending with `$macros` suffix. In other words, I had to do something like the following in order for my assertion to work on both JVM and bootstrapped ClojureScript: > (defmethod #?(:cljs cljs.test$macros/assert-expr > :clj cljs.test/assert-expr) > ... Is this the best way to achieve this? Thanks, JS Thomas Heller writes: > Hey, > > cljs.test/assert-expr is part of the CLJ macro side so it can't be extended > from a CLJS REPL. You can write it in a .clj file and use (require-macros > 'that.ns) from the CLJS REPL or use :require-macros in the ns form that > uses the new assert-expr. > > HTH, > Thomas > > On Thursday, September 26, 2019 at 9:43:19 PM UTC+2, jvshahid wrote: >> >> Hi all, >> >> I am trying to implement custom assertions in ClojureScript. I tried to >> use defmethod but got the following error: >> >> > clojure -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version >> "1.10.520"}}}' -m cljs.main --repl --repl-env node >> > cljs.user=> (require '[cljs.test]) >> > nil >> > cljs.user=> (defmethod cljs.test/assert-expr 'foo [& arg]) >> > WARNING: Use of undeclared Var cljs.test/assert-expr at line 1 > repl> >> > Execution error (Error) at (:1). >> > No protocol method IMultiFn.-add-method defined for type undefined: >> > >> > cljs.user=> cljs.test/assert-expr >> > WARNING: Use of undeclared Var cljs.test/assert-expr at line 1 > repl> >> > nil >> >> What am I doing wrong? >> >> Thanks, >> >> JS >> -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/clojure/87impcm8bf.fsf%40gmail.com.
Re: Custom test assertions in ClojureScript
Hey, cljs.test/assert-expr is part of the CLJ macro side so it can't be extended from a CLJS REPL. You can write it in a .clj file and use (require-macros 'that.ns) from the CLJS REPL or use :require-macros in the ns form that uses the new assert-expr. HTH, Thomas On Thursday, September 26, 2019 at 9:43:19 PM UTC+2, jvshahid wrote: > > Hi all, > > I am trying to implement custom assertions in ClojureScript. I tried to > use defmethod but got the following error: > > > clojure -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version > "1.10.520"}}}' -m cljs.main --repl --repl-env node > > cljs.user=> (require '[cljs.test]) > > nil > > cljs.user=> (defmethod cljs.test/assert-expr 'foo [& arg]) > > WARNING: Use of undeclared Var cljs.test/assert-expr at line 1 repl> > > Execution error (Error) at (:1). > > No protocol method IMultiFn.-add-method defined for type undefined: > > > > cljs.user=> cljs.test/assert-expr > > WARNING: Use of undeclared Var cljs.test/assert-expr at line 1 repl> > > nil > > What am I doing wrong? > > Thanks, > > JS > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/clojure/69293a74-493f-4cf4-b7f9-e0dfc1050b2f%40googlegroups.com.
Custom test assertions in ClojureScript
Hi all, I am trying to implement custom assertions in ClojureScript. I tried to use defmethod but got the following error: > clojure -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version > "1.10.520"}}}' -m cljs.main --repl --repl-env node > cljs.user=> (require '[cljs.test]) > nil > cljs.user=> (defmethod cljs.test/assert-expr 'foo [& arg]) > WARNING: Use of undeclared Var cljs.test/assert-expr at line 1 > Execution error (Error) at (:1). > No protocol method IMultiFn.-add-method defined for type undefined: > > cljs.user=> cljs.test/assert-expr > WARNING: Use of undeclared Var cljs.test/assert-expr at line 1 > nil What am I doing wrong? Thanks, JS -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/clojure/875zlezvwv.fsf%40gmail.com.