I'm interested in using this library to generate DSLs. I'd like to write unit tests for the code generator to check that:
1) The generated code compiles, since as I understand it I could generate invalid code using treehugger
2) Certain usages of the generated code compile, and others don't - ie. testing that the DSLs work how I expect them to and provide the type safety I want
Scalatest provides assertCompiles which is a macro that can be applied to string literals, is there something similar I could use with treehugger's resultant AST (or even better the generated source code string)? I can't quite seem to find what I'm looking for, wondering if I might be barking up the wrong tree entirely.
Any help, tips or general pointers are very much appreciated
Joseph Whiting
Joseph Whiting
--
You received this message because you are subscribed to the Google Groups "treehugger-scala" group.
To unsubscribe from this group and stop receiving emails from it, send an email to treehugger-scala+unsubscribe@googlegroups.com.
To post to this group, send email to treehugger-scala@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/treehugger-scala/851e0855-729d-41f4-b3ae-50cfb5988adf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I think it depends on what you want to test.treehugger can generate String, so you can pass that along to assertCompiles if that's what you want.You can also test the behavior of the code by actually running it as part of integration test.You could use scripted for that - https://www.scala-sbt.org/1.x/docs/Testing-sbt-plugins.html-eugene
On Mon, Apr 9, 2018 at 7:30 AM, Joseph Whiting <whiti...@gmail.com> wrote:
Nice library, and the docs are great! Is it still active? If so I'd really appreciate some advice on how to test my usage of it.
I'm interested in using this library to generate DSLs. I'd like to write unit tests for the code generator to check that:
1) The generated code compiles, since as I understand it I could generate invalid code using treehugger
2) Certain usages of the generated code compile, and others don't - ie. testing that the DSLs work how I expect them to and provide the type safety I want
Scalatest provides assertCompiles which is a macro that can be applied to string literals, is there something similar I could use with treehugger's resultant AST (or even better the generated source code string)? I can't quite seem to find what I'm looking for, wondering if I might be barking up the wrong tree entirely.
Any help, tips or general pointers are very much appreciated
Joseph Whiting
--
You received this message because you are subscribed to the Google Groups "treehugger-scala" group.
To unsubscribe from this group and stop receiving emails from it, send an email to treehugger-sca...@googlegroups.com.
To post to this group, send email to treehugg...@googlegroups.com.