sbt-doctest icon indicating copy to clipboard operation
sbt-doctest copied to clipboard

Check compile errors

Open fthomas opened this issue 9 years ago • 0 comments

In refined are examples that show compile errors in certain situations:

  /**
   * Creates a `scala.util.matching.Regex` from a validated string.
   *
   * Example: {{{
   * scala> import eu.timepit.refined.implicits._
   *      | import eu.timepit.refined.util.string.regex
   *
   * scala> regex(".*")
   * res1: scala.util.matching.Regex = .*
   *
   * scala> regex("{")
   * <console>:41: error: Predicate isValidRegex("{") failed: Illegal repetition
   * {
   *        regex("{")
   *              ^
   * }}}
   */
  def ...

The first example is verified by sbt-doctest but the second is not. It would be awesome if sbt-doctest could also verify non-compiling examples.

shapeless has something like this called illTyped which also can check the error message.

fthomas avatar Jul 30 '15 06:07 fthomas