org.scalatest.matchers.Matchers

class BeWord

[source: org/scalatest/matchers/Matchers.scala]

final class BeWord
extends AnyRef
This class is part of the ScalaTest matchers DSL. Please see the documentation for ShouldMatchers or MustMatchers for an overview of the matchers DSL.

Class BeWord contains an apply method that takes a Symbol, which uses reflection to find and access a Boolean property and determine if it is true. If the symbol passed is 'empty, for example, the apply method will use reflection to look for a public Java field named "empty", a public method named "empty", or a public method named "isEmpty". If a field, it must be of type Boolean. If a method, it must take no parameters and return Boolean. If multiple candidates are found, the apply method will select based on the following algorithm:

FieldMethod"is" MethodResult
   Throws TestFailedException, because no candidates found
  isEmpty()Invokes isEmpty()
 empty() Invokes empty()
 empty()isEmpty()Invokes empty() (this can occur when BeanProperty annotation is used)
empty  Accesses field empty
empty isEmpty()Invokes isEmpty()
emptyempty() Invokes empty()
emptyempty()isEmpty()Invokes empty() (this can occur when BeanProperty annotation is used)
Author
Bill Venners
Method Summary
def < [T](right : T)(implicit view$1 : (T) => scala.Ordered[T]) : Matcher[T]
This method enables the following syntax:
     result should be < (7)
                      ^
     
def <= [T](right : T)(implicit view$3 : (T) => scala.Ordered[T]) : Matcher[T]
This method enables the following syntax:
     result should be <= (7)
                      ^
     
def === (right : Any) : Matcher[Any]
This method enables the following syntax:
     result should be === (7)
                      ^
     
def > [T](right : T)(implicit view$2 : (T) => scala.Ordered[T]) : Matcher[T]
This method enables the following syntax:
     result should be > (7)
                      ^
     
def >= [T](right : T)(implicit view$4 : (T) => scala.Ordered[T]) : Matcher[T]
This method enables the following syntax:
     result should be >= (7)
                      ^
     
def a [S <: AnyRef](bePropertyMatcher : BePropertyMatcher[S]) : Matcher[S]
This method enables the following syntax, where fileMock is, for example, of type File and file refers to a BePropertyMatcher[File]:
     fileMock should not { be a (file) }
                              ^
     
def a [S <: AnyRef](right : scala.Symbol) : Matcher[S]
This method enables the following syntax:
     fileMock should not { be a ('file) }
                              ^
     
def an [S <: AnyRef](right : scala.Symbol) : Matcher[S]
This method enables the following syntax:
     animal should not { be an ('elephant) }
                            ^
     
def an [S <: AnyRef](bePropertyMatcher : BePropertyMatcher[S]) : Matcher[S]
This method enables the following syntax, where keyEvent is, for example, of type KeyEvent and actionKey refers to a BePropertyMatcher[KeyEvent]:
     keyEvent should not { be an (actionKey) }
                              ^
     
def apply (o : Null) : Matcher[AnyRef]
This method enables the following syntax:
     object should be (null)
                      ^
     
def apply (right : Boolean) : Matcher[Boolean]
This method enables the following syntax:
     result should be (true)
                      ^
     
def apply [S <: AnyRef](right : scala.Symbol) : Matcher[S]
This method enables the following syntax:
     set should be ('empty)
                   ^
     
def apply (right : Any) : Matcher[Any]
This method enables be to be used for equality comparison. Here are some examples:
     object should be (None)
                      ^
     object should be (Some(1))
                      ^
     result should be (true)
                      ^
     result should be (false)
                      ^
     sum should be (19)
                   ^
     
def apply (intTolerance : IntTolerance) : Matcher[Int]
This method enables the following syntax:
     sevenInt should be (7 plusOrMinus 2)
                         ^
     
def apply [T](right : BeMatcher[T]) : Matcher[T]
This method enables the following syntax, where num is, for example, of type Int and odd refers to a BeMatcher[Int]:
     num should be (odd)
                   ^
     
def apply (shortTolerance : ShortTolerance) : Matcher[Short]
This method enables the following syntax:
     sevenShort should be (7.toShort plusOrMinus 2.toShort)
                         ^
     
def apply (doubleTolerance : DoubleTolerance) : Matcher[Double]
This method enables the following syntax:
     sevenDotOh should be (7.1 plusOrMinus 0.2)
                          ^
     
def apply [T](bePropertyMatcher : BePropertyMatcher[T]) : Matcher[T]
This method enables the following syntax, where open refers to a BePropertyMatcher:
     door should be (open)
                    ^
     
def apply (longTolerance : LongTolerance) : Matcher[Long]
This method enables the following syntax:
     sevenLong should be (7L plusOrMinus 2L)
                         ^
     
def apply (byteTolerance : ByteTolerance) : Matcher[Byte]
This method enables the following syntax:
     sevenByte should be (7.toByte plusOrMinus 2.toByte)
                         ^
     
def apply (floatTolerance : FloatTolerance) : Matcher[Float]
This method enables the following syntax:
     sevenDotOhFloat should be (7.1f plusOrMinus 0.2f)
                               ^
     
def theSameInstanceAs (right : AnyRef) : Matcher[AnyRef]
This method enables the following syntax:
     object should be theSameInstancreAs (anotherObject)
                      ^
     
Methods inherited from AnyRef
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Method Details
def <[T](right : T)(implicit view$1 : (T) => scala.Ordered[T]) : Matcher[T]
This method enables the following syntax:
     result should be < (7)
                      ^
     

Note that the less than operator will be invoked on be in this expression, not on a result of passing be to should, as with most other operators in the matchers DSL, because the less than operator has a higher precedence than should. Thus in the above case the first expression evaluated will be be < (7), which results in a matcher that is passed to should.

This method also enables the following syntax:

     result should not (be < (7))
                           ^
     

def >[T](right : T)(implicit view$2 : (T) => scala.Ordered[T]) : Matcher[T]
This method enables the following syntax:
     result should be > (7)
                      ^
     

Note that the greater than operator will be invoked on be in this expression, not on a result of passing be to should, as with most other operators in the matchers DSL, because the greater than operator has a higher precedence than should. Thus in the above case the first expression evaluated will be be > (7), which results in a matcher that is passed to should.

This method also enables the following syntax:

     result should not (be > (7))
                           ^
     

def <=[T](right : T)(implicit view$3 : (T) => scala.Ordered[T]) : Matcher[T]
This method enables the following syntax:
     result should be <= (7)
                      ^
     

Note that the less than or equal to operator will be invoked on be in this expression, not on a result of passing be to should, as with most other operators in the matchers DSL, because the less than or equal to operator has a higher precedence than should. Thus in the above case the first expression evaluated will be be <= (7), which results in a matcher that is passed to should.

This method also enables the following syntax:

     result should not (be <= (7))
                           ^
     

def >=[T](right : T)(implicit view$4 : (T) => scala.Ordered[T]) : Matcher[T]
This method enables the following syntax:
     result should be >= (7)
                      ^
     

Note that the greater than or equal to operator will be invoked on be in this expression, not on a result of passing be to should, as with most other operators in the matchers DSL, because the greater than or equal to operator has a higher precedence than should. Thus in the above case the first expression evaluated will be be >= (7), which results in a matcher that is passed to should.

This method also enables the following syntax:

     result should not (be >= (7))
                           ^
     

def ===(right : Any) : Matcher[Any]
This method enables the following syntax:
     result should be === (7)
                      ^
     

Note that the === operator will be invoked on be in this expression, not on a result of passing be to should, as with most other operators in the matchers DSL, because the ===n operator has a higher precedence than should. Thus in the above case the first expression evaluated will be be === (7), which results in a matcher that is passed to should.

This method also enables the following syntax:

     result should not (be === (7))
                           ^
     

def a[S <: AnyRef](right : scala.Symbol) : Matcher[S]
This method enables the following syntax:
     fileMock should not { be a ('file) }
                              ^
     

def a[S <: AnyRef](bePropertyMatcher : BePropertyMatcher[S]) : Matcher[S]
This method enables the following syntax, where fileMock is, for example, of type File and file refers to a BePropertyMatcher[File]:
     fileMock should not { be a (file) }
                              ^
     

def an[S <: AnyRef](right : scala.Symbol) : Matcher[S]
This method enables the following syntax:
     animal should not { be an ('elephant) }
                            ^
     

def an[S <: AnyRef](bePropertyMatcher : BePropertyMatcher[S]) : Matcher[S]
This method enables the following syntax, where keyEvent is, for example, of type KeyEvent and actionKey refers to a BePropertyMatcher[KeyEvent]:
     keyEvent should not { be an (actionKey) }
                              ^
     

def apply(doubleTolerance : DoubleTolerance) : Matcher[Double]
This method enables the following syntax:
     sevenDotOh should be (7.1 plusOrMinus 0.2)
                          ^
     

def apply(floatTolerance : FloatTolerance) : Matcher[Float]
This method enables the following syntax:
     sevenDotOhFloat should be (7.1f plusOrMinus 0.2f)
                               ^
     

def apply(longTolerance : LongTolerance) : Matcher[Long]
This method enables the following syntax:
     sevenLong should be (7L plusOrMinus 2L)
                         ^
     

def apply(intTolerance : IntTolerance) : Matcher[Int]
This method enables the following syntax:
     sevenInt should be (7 plusOrMinus 2)
                         ^
     

def apply(shortTolerance : ShortTolerance) : Matcher[Short]
This method enables the following syntax:
     sevenShort should be (7.toShort plusOrMinus 2.toShort)
                         ^
     

def apply(byteTolerance : ByteTolerance) : Matcher[Byte]
This method enables the following syntax:
     sevenByte should be (7.toByte plusOrMinus 2.toByte)
                         ^
     

def theSameInstanceAs(right : AnyRef) : Matcher[AnyRef]
This method enables the following syntax:
     object should be theSameInstancreAs (anotherObject)
                      ^
     

def apply(right : Boolean) : Matcher[Boolean]
This method enables the following syntax:
     result should be (true)
                      ^
     

def apply(o : Null) : Matcher[AnyRef]
This method enables the following syntax:
     object should be (null)
                      ^
     

def apply[S <: AnyRef](right : scala.Symbol) : Matcher[S]
This method enables the following syntax:
     set should be ('empty)
                   ^
     

def apply[T](right : BeMatcher[T]) : Matcher[T]
This method enables the following syntax, where num is, for example, of type Int and odd refers to a BeMatcher[Int]:
     num should be (odd)
                   ^
     

def apply[T](bePropertyMatcher : BePropertyMatcher[T]) : Matcher[T]
This method enables the following syntax, where open refers to a BePropertyMatcher:
     door should be (open)
                    ^
     

def apply(right : Any) : Matcher[Any]
This method enables be to be used for equality comparison. Here are some examples:
     object should be (None)
                      ^
     object should be (Some(1))
                      ^
     result should be (true)
                      ^
     result should be (false)
                      ^
     sum should be (19)
                   ^
     


Copyright (C) 2001-2010 Artima, Inc. All rights reserved.