Claim represents a Boolean result with a description of what that result means.
Render is a typeclass to provide human-readable representations of values.
Render is a typeclass to provide human-readable representations of values.
This typeclass provides two major concrete benefits over the built-in toString method:
2. Authors can override representations locally to improve error reporting in their own tests.
Claimant attempts to provide instances for most built-in Scala types, as well as a handy macro for generating instances for Scala case classes. For example, the following code produces a Render[Rectangle] value, which will use Render[Double] instances recursively:
case class Rectangle(height: Double, width: Double)
object Rectangle { implicit renderForRectangle: Render[Rectangle] = Render.caseClass[Rectangle] }
This typeclass is very similar to cats.Show (and probably others). One major design difference is that for a given type T, if a specific Render[T] is not available, this typeclass will generate an instance that just uses .toString. This behavior is intended to balance the benefits of custom representations with not requiring authors to write a bunch of new code in order ot use Claimant.
Scribe represents a set of strategies for annotating expressions to produce more interesting String representations.
Scribe represents a set of strategies for annotating expressions to produce more interesting String representations.
The annotate method should return None in cases where the expression shape is not recognized. It is given a reference to the System because annotation might be recursive. (Currently recursive annotations are not used due to the complexity of displaying that information.)
The trees that result from annotate must be String expressions.
System encapsulates the strategies used by Claimant.
System encapsulates the strategies used by Claimant.
Tinkers describe how to decompose Boolean expressions, and scribes describe how to label _any_ expression. Together we use them to build labels for labeled Prop values.
Tinker represents a set of strategies for deconstructing Boolean
expressions into Claims (the deconstruct
method).
Tinker represents a set of strategies for deconstructing Boolean
expressions into Claims (the deconstruct
method).
The deconstruct method should return None in cases where the expression shape is not recognized. It is given a reference to the System because deconstruction is often recursive -- for example, deconstructing (x && y) may involve deconstructing x and deconstructing y independently.
Only c.Expr[Boolean] expressions can be deconstructed. A different process (annotation) is used to create labels -- see Scribe for more information.
Format provides supports building trees of different shapes with quasiquotes.
Format provides supports building trees of different shapes with quasiquotes.
The trees don't represent actual expressions, but rather represent String expressions involving concatenation of other Strings and String expressions.
These methods will also annotate the String with an optional value (representing the result of the expression).
Claim represents a Boolean result with a description of what that result means.
Claims can be composed using the same operators as Booleans, which correspond to recursive Claim subtypes (e.g. And, Or, etc.).
All claims can be converted into ScalaCheck Prop values. (The reverse is not true -- it's not possible to extra ScalaCheck labels from a Prop without running it.)