final class BeWord extends AnyRef
This class is part of the ScalaTest matchers DSL. Please see the documentation for Matchers
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:
Field | Method | "is" Method | Result |
---|---|---|---|
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() | |
empty | empty() | Invokes empty() | |
empty | empty() | isEmpty() | Invokes empty() (this can occur when BeanProperty annotation is used) |
- Source
- BeWord.scala
- Alphabetic
- By Inheritance
- BeWord
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new BeWord()
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- def <[T](right: T)(implicit arg0: Ordering[T]): Matcher[T]
This method enables the following syntax:
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 passingbe
toshould
, as with most other operators in the matchers DSL, because the less than operator has a higher precedence thanshould
. Thus in the above case the first expression evaluated will bebe < (7)
, which results in a matcher that is passed toshould
.This method also enables the following syntax:
result should not (be < (7)) ^
- def <=[T](right: T)(implicit arg0: Ordering[T]): Matcher[T]
This method enables the following syntax:
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 passingbe
toshould
, as with most other operators in the matchers DSL, because the less than or equal to operator has a higher precedence thanshould
. Thus in the above case the first expression evaluated will bebe <= (7)
, which results in a matcher that is passed toshould
.This method also enables the following syntax:
result should not (be <= (7)) ^
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def >[T](right: T)(implicit arg0: Ordering[T]): Matcher[T]
This method enables the following syntax:
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 passingbe
toshould
, as with most other operators in the matchers DSL, because the greater than operator has a higher precedence thanshould
. Thus in the above case the first expression evaluated will bebe > (7)
, which results in a matcher that is passed toshould
.This method also enables the following syntax:
result should not (be > (7)) ^
- def >=[T](right: T)(implicit arg0: Ordering[T]): Matcher[T]
This method enables the following syntax:
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 passingbe
toshould
, as with most other operators in the matchers DSL, because the greater than or equal to operator has a higher precedence thanshould
. Thus in the above case the first expression evaluated will bebe >= (7)
, which results in a matcher that is passed toshould
.This method also enables the following syntax:
result should not (be >= (7)) ^
- def a[S](aMatcher: AMatcher[S]): Matcher[S]
This method enables the following syntax, where
negativeNumber
is, for example, of typeAMatcher
:This method enables the following syntax, where
negativeNumber
is, for example, of typeAMatcher
:8 should not { be a (negativeNumber) } ^
- def a[S <: AnyRef](bePropertyMatcher: BePropertyMatcher[S]): Matcher[S]
This method enables the following syntax, where
fileMock
is, for example, of typeFile
andfile
refers to aBePropertyMatcher[File]
:This method enables the following syntax, where
fileMock
is, for example, of typeFile
andfile
refers to aBePropertyMatcher[File]
:fileMock should not { be a (file) } ^
- def a(right: Symbol)(implicit prettifier: Prettifier, pos: Position): Matcher[AnyRef]
This method enables the following syntax:
This method enables the following syntax:
fileMock should not { be a ('file) } ^
- def an[S](anMatcher: AnMatcher[S]): Matcher[S]
This method enables the following syntax, where
oddNumber
is, for example, of typeAnMatcher
:This method enables the following syntax, where
oddNumber
is, for example, of typeAnMatcher
:8 should not { be an (oddNumber) } ^
- def an[S <: AnyRef](bePropertyMatcher: BePropertyMatcher[S]): Matcher[S]
This method enables the following syntax, where
keyEvent
is, for example, of typeKeyEvent
andactionKey
refers to aBePropertyMatcher[KeyEvent]
:This method enables the following syntax, where
keyEvent
is, for example, of typeKeyEvent
andactionKey
refers to aBePropertyMatcher[KeyEvent]
:keyEvent should not { be an (actionKey) } ^
- def an(right: Symbol)(implicit prettifier: Prettifier, pos: Position): Matcher[AnyRef]
This method enables the following syntax:
This method enables the following syntax:
animal should not { be an ('elephant) } ^
- def apply(defined: DefinedWord): MatcherFactory1[Any, Definition]
This method enables syntax such as the following:
This method enables syntax such as the following:
array should be (defined) ^
- def apply(empty: EmptyWord): MatcherFactory1[Any, Emptiness]
This method enables syntax such as the following:
This method enables syntax such as the following:
array should be (empty) ^
- def apply(writable: WritableWord): MatcherFactory1[Any, Writability]
This method enables the following syntax, where
open
refers to aBePropertyMatcher
:This method enables the following syntax, where
open
refers to aBePropertyMatcher
:file should be (writable) ^
- def apply(readable: ReadableWord): MatcherFactory1[Any, Readability]
This method enables the following syntax, where
open
refers to aBePropertyMatcher
:This method enables the following syntax, where
open
refers to aBePropertyMatcher
:file should be (readable) ^
- macro def apply(anType: ResultOfAnTypeInvocation[_]): Matcher[Any]
This method enables the following syntax, where
open
refers to aBePropertyMatcher
:This method enables the following syntax, where
open
refers to aBePropertyMatcher
:result should be (an [Book]) ^
- macro def apply(aType: ResultOfATypeInvocation[_]): Matcher[Any]
This method enables the following syntax, where
open
refers to aBePropertyMatcher
:This method enables the following syntax, where
open
refers to aBePropertyMatcher
:result should be (a [Book]) ^
- def apply[A, U <: PartialFunction[A, _]](resultOfDefinedAt: ResultOfDefinedAt[A]): Matcher[U]
This method enables the following syntax, where
fraction
refers to aPartialFunction
:This method enables the following syntax, where
fraction
refers to aPartialFunction
:fraction should (be (definedAt (6)) and be (definedAt (8))) ^
- def apply(right: SortedWord): MatcherFactory1[Any, Sortable]
This method enables the following syntax, where
open
refers to aBePropertyMatcher
:This method enables the following syntax, where
open
refers to aBePropertyMatcher
:List(1, 2, 3) should be (sorted) ^
- def apply(right: Any): Matcher[Any]
This method enables
be
to be used for equality comparison.This method enables
be
to be used for equality comparison. Here are some examples:result should be (None) ^ result should be (Some(1)) ^ result should be (true) ^ result should be (false) ^ sum should be (19) ^
- def apply[T](bePropertyMatcher: BePropertyMatcher[T]): Matcher[T]
This method enables the following syntax, where
open
refers to aBePropertyMatcher
:This method enables the following syntax, where
open
refers to aBePropertyMatcher
:door should be (open) ^
- def apply[T](right: BeMatcher[T]): Matcher[T]
This method enables the following syntax, where
num
is, for example, of typeInt
andodd
refers to aBeMatcher[Int]
:This method enables the following syntax, where
num
is, for example, of typeInt
andodd
refers to aBeMatcher[Int]
:num should be (odd) ^
- def apply(right: Symbol)(implicit prettifier: Prettifier, pos: Position): Matcher[AnyRef]
This method enables the following syntax:
This method enables the following syntax:
set should be ('empty) ^
- def apply(o: Null): Matcher[AnyRef]
This method enables the following syntax:
This method enables the following syntax:
result should be (null) ^
- def apply(right: Boolean): Matcher[Boolean]
This method enables the following syntax:
This method enables the following syntax:
result should be (true) ^
- def apply[U](spread: Spread[U]): Matcher[U]
This method enables the following syntax for the "primitive" numeric types:
This method enables the following syntax for the "primitive" numeric types:
sevenDotOh should be (7.1 +- 0.2) ^
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def definedAt[A, U <: PartialFunction[A, _]](right: A): Matcher[U]
This method enables the following syntax, where
fraction
refers to aPartialFunction
:This method enables the following syntax, where
fraction
refers to aPartialFunction
:fraction should (be definedAt (6) and be definedAt (8)) ^
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def theSameInstanceAs(right: AnyRef): Matcher[AnyRef]
This method enables the following syntax:
This method enables the following syntax:
result should be theSameInstancreAs (anotherObject) ^
- def thrownBy(code: => Unit): ResultOfBeThrownBy
This method enables the following syntax:
This method enables the following syntax:
a[Exception] should (be thrownBy { "hi".charAt(-1) }) ^
- def toString(): String
Overrides toString to return "be"
Overrides toString to return "be"
- Definition Classes
- BeWord → AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
Deprecated Value Members
- def ===(right: Any)(implicit pos: Position): Matcher[Any]
The deprecation period for the "be ===" syntax has expired, and the syntax will now throw
NotAllowedException
. Please use should equal, should ===, shouldEqual, should be, or shouldBe instead.The deprecation period for the "be ===" syntax has expired, and the syntax will now throw
NotAllowedException
. Please use should equal, should ===, shouldEqual, should be, or shouldBe instead.Note: usually syntax will be removed after its deprecation period. This was left in because otherwise the syntax could in some cases still compile, but silently wouldn't work.
- Annotations
- @deprecated
- Deprecated
The deprecation period for the be === syntax has expired. Please use should equal, should ===, shouldEqual, should be, or shouldBe instead.