TestableBoolean

object TestableBoolean extends Testable[Boolean]
trait Testable[Boolean]
class Object
trait Matchable
class Any

Value members

Concrete methods

override def lt(x: Boolean, y: Boolean): Boolean
Definition Classes
def parse: Src => Boolean

Inherited methods

def checkInvariant(x: Boolean): Unit

Throws an exception if an invariant fails. Otherwise, returns Unit.

Throws an exception if an invariant fails. Otherwise, returns Unit.

checkInvariant defaults to {}. Override this default for types that have meaningful internal invariants that you want to check automatically. Indicate that an invariant has been violated by throwing an exception, preferably with a meaningful error message. Note that checkInvariant will be called on each answer before comparing to the expected answer. That comparison would presumably also fail, so the advantage of checkInvariant is that it can display a different error message for failed invariants than ordinary errors, which matters because failed invariants often provide better clues for debugging than ordinary errors.

For example, checkInvariant might check if the keys in a binary search tree are ordered in the way they should be, and throw an exception if they aren't (ideally including a useful description in the message of the exception).

Inherited from:
Testable
def copy(x: Boolean): Boolean

Returns a deep copy of x.

Returns a deep copy of x.

Intended for storing copies of mutable inputs for later display in error messages. Also used by testV where the validation function needs access to the original state of the input.

Because so many types in Scala are immutable, the default implementation of copy simply returns the original value. This method must be overwritten for mutable values and also for immutable collections that could contain mutable values.

Inherited from:
Testable
def equiv(x: Boolean, y: Boolean): Boolean

Tests if x and y are equivalent.

Tests if x and y are equivalent.

Used to check if the result of a function is equivalent to the expected result, to determine whether a test passed.

The defalt implementation for equiv uses ==, because that's usually what we want. In situations where we want a broader notion of equivalance, we need to override equiv with an appropriate definition.

For example, if a function returns a list of integers, but the order of those integers doesn't matter, then we may want to create a new instance of Testable[List[Int]] with

 override def equiv(x: List[Int], y: List[Int]): Boolean = (x.sorted == y.sorted)

As another example, floating-point numbers typically need a notion of equivalence where numbers can be considered "close enough", even though that wreaks havoc with traditional properties of equivalence such as transitivity.

Inherited from:
Testable
final def format(x: Boolean): String

Returns a possibly-formatted string representing the given top-level value for display to the user.

Returns a possibly-formatted string representing the given top-level value for display to the user.

A top-level value is one that is a direct argument to or the direct result from a function being tested. All nested values should be displayed using show.

For example, if a function returns a BinaryTree, that result will be displayed in a graphical format, but if a function returns a list of BinaryTrees, that list (including the trees) will be displayed in a single-line format.

Equivalent to _format except includes a check for null.

To change the behavior of format, override _format instead.

Inherited from:
Testable
def label(name: String, x: Boolean): String
Inherited from:
Testable
def multiequiv[T](iter1: Iterator[T], iter2: Iterator[T], T: Testable[T]): Boolean

Check if two collections are equivalent.

Check if two collections are equivalent.

The collections are given as iterators. To be equivalent, the two iterators must be the same length, and the value at each position of iter1 must be equivalent to the value at the same position in iter2.

When multiequiv is called, the collections must be converted to iterators, and might need to be normalized, usually by sorting, so that corresponding elements end up in corresponding order. (Typcially such normalization would be needed for unordered collections but not for ordered collections.)

Inherited from:
Testable
def multilt[T](iter1: Iterator[T], iter2: Iterator[T], T: Testable[T]): Boolean

Check if one collection is considered "less than" another collection.

Check if one collection is considered "less than" another collection.

Typically used when normalizing a collection of collections.

The collections are given as iterators, which are compared lexicographically.

When multilt is called, the collections must be converted to iterators, and may need to be normalized, usually by sorting, so that corresponding elements end up in corresponding order. (Typically such normalization would be needed for unordered collections but not for ordered collections.)

Inherited from:
Testable
def parseAndCheck(src: Src): Boolean

Like parse but also checks that the parsed value satisfies any invariant expected of a value of this type. Throws an exception in an invariant is not met.

Like parse but also checks that the parsed value satisfies any invariant expected of a value of this type. Throws an exception in an invariant is not met.

Inherited from:
Testable
final def show(x: Boolean): String

Returns a string representing the given value for display to the user.

Returns a string representing the given value for display to the user.

The returned string should normally not contain any line breaks, except possibly when a line break occurs in the contents of a quoted String or Char.

Equivalent to _show except includes a check for null.

To change the behavior of show, override _show instead.

Inherited from:
Testable

Concrete fields

val name: String