Trait/Object

org.specs2.matcher

MatchResult

Related Docs: object MatchResult | package matcher

Permalink

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
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract val expectable: Expectable[T]

    Permalink

    the value being matched

  2. abstract def negate: MatchResult[T]

    Permalink

    returns

    the negation of this result

Concrete Value Members

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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

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

    Permalink
    Definition Classes
    AnyRef → Any
  4. def applyMatcher(m: Matcher[T]): MatchResult[T]

    Permalink

    alias for the apply method, to be used outside specs2

  5. final def asInstanceOf[T0]: T0

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

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

    Permalink

    apply the matcher

  8. def clone(): AnyRef

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

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

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

    Permalink

    the value being matched

    the value being matched

    Attributes
    protected[org.specs2]
  12. def finalize(): Unit

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

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

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

    Permalink

    apply the matcher

  16. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  17. def isSuccess: Boolean

    Permalink
  18. def message: String

    Permalink
  19. def mute: MatchResult[T]

    Permalink

    returns

    the MatchResult with no messages

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

    Permalink
    Definition Classes
    AnyRef
  21. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  22. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  23. def orSkip: MatchResult[T]

    Permalink
  24. def orThrow: MatchResult[T]

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

    Permalink

    set a new failure message on this match result

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

    Permalink
    Definition Classes
    AnyRef
  27. def toResult: Result

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

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

    Permalink

    update the failure message of this match result

  30. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from ResultLike

Inherited from AnyRef

Inherited from Any

Ungrouped