org.specs2.matcher

MatchResult

trait MatchResult[+T] extends ResultLike

Result of a Match.

A MatchResult contains several information about a match on an expectable:

- the expectable value, to allow the chaining of matches - a pair of messages ok message / ko message to allow the easy creation of the negation of a match

A MatchResult can be transformed to a simple Result object to be the body of an Example.

There are different kinds of MatchResults, some of them being only created to support English-like combination of Matchers:

1 must be equalTo(1) and not be equalTo(2)

In an Expectation like the one above, there is a left to right evaluation:

  1. be is a NeutralMatcher, returning a NeutralMatch doing nothing yet, just storing the expectable

2. equalTo(1) is a real Matcher which is applied to the NeutralMatch MatchResult thanks to an implicit definition in the BeHaveAnyMatchers trait. This yields a MatchSuccess result

3. not creates a NotMatcher and can be and-ed with the previous MatchSuccess to yield a AndMatch(MatchSuccess, NotMatch), with NotMatch being the result of applying the NotMatcher to the expectable. This AndMatch is evaluated to create a AndNotMatch(MatchSuccess, MatchSkip)

Basically this is like forming an evaluation structure which will be resolved when the next 'real' matcher will arrive

4. the AndNotMatch get nows it be method called with the equalTo Matcher. This results in equalTo being applied to the AndNotMatch, effectively doing: MatchSuccess and MatchSkip.apply(equalTo(2).not), which is MatchSuccess and expectable.applyMatcher(equalTo(2).not) which is MatchSuccess

See also

org.specs2.matcher.BeHaveMatchersSpec for examples

Linear Supertypes
ResultLike, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. MatchResult
  2. ResultLike
  3. AnyRef
  4. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract val expectable: Expectable[T]

    the value being matched

  2. abstract def negate: MatchResult[T]

    returns

    the negation of this result

  3. abstract def setExpectable[S >: T](e: Expectable[S]): MatchResult[S]

    set a different expectable for this matcher

Concrete Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. def applyMatcher(m: Matcher[T]): MatchResult[T]

    alias for the apply method, to be used outside specs2

  7. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  8. def be[S >: T <: AnyRef](s: S): MatchResult[T]

  9. def be(m: Matcher[T]): MatchResult[T]

    apply the matcher

  10. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  11. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  12. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  13. def evaluate[S >: T]: MatchResult[S]

    the value being matched

    the value being matched

    Attributes
    protected[org.specs2]
  14. def filterTrace(f: (List[StackTraceElement]) ⇒ List[StackTraceElement]): MatchResult[T]

    filter the trace of this result (if there is one)

  15. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  16. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  17. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  18. def have(m: Matcher[T]): MatchResult[T]

    apply the matcher

  19. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  20. def isSuccess: Boolean

  21. def message: String

  22. def mute: MatchResult[T]

    returns

    the MatchResult with no messages

  23. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  24. final def notify(): Unit

    Definition Classes
    AnyRef
  25. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  26. def orSkip: MatchResult[T]

  27. def orThrow: MatchResult[T]

  28. def setMessage(message: String): MatchResult[T]

    set a new failure message on this match result

  29. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  30. def toResult: Result

    Definition Classes
    MatchResult → ResultLike
  31. def toString(): String

    Definition Classes
    AnyRef → Any
  32. def updateMessage(f: (String) ⇒ String): MatchResult[T]

    update the failure message of this match result

  33. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  34. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  35. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from ResultLike

Inherited from AnyRef

Inherited from Any

Ungrouped