5

Testing runtime behavior is very well documented but with the advent of powerful type systems and macro system one might be interested in testing compile-time behavior.

For instance when writing a library that provides compile-time guarantees. Say I'm building a set of test matchers and I want to make sure a matcher is as type-safe as I claim it to be.

List(1,2) must beEqualTo(Set(1,2)) // should fail at compile-time

I can see in the scala compiler project that most of the tests are functional tests where the compiler output is asserted by comparing it with a reference file. Is there a convention for such tests? An SBT plugin?

Thanks

Bruno Bieth
  • 2,317
  • 20
  • 31
  • 6
    The canonical Q&A is http://stackoverflow.com/q/15125457/1296806 where partest gets a mention but the consensus is that a macro that runs the type check is the best solution. Note that there is a subtle difference between type checking and surviving to the end of compilation. – som-snytt Oct 08 '13 at 09:14
  • Very good! I looked for something like that but couldn't find it... Thanks! – Bruno Bieth Oct 08 '13 at 15:33

0 Answers0