object Requirements extends Requirements
Companion object that facilitates the importing of Requirements
members as
an alternative to mixing it in. One use case is to import Requirements
members so you can use
them in the Scala interpreter:
$scala -classpath scalatest.jar Welcome to Scala version 2.10.3.final (Java HotSpot(TM) Client VM, Java xxxxxx). Type in expressions to have them evaluated. Type :help for more information. scala> import org.scalactic.Requirements._ import org.scalactic.Requirements._ scala> val a = 1 a: Int = 1 scala> require(a == 2) java.lang.IllegalArgumentException: 1 did not equal 2 at org.scalactic.Requirements$RequirementsHelper.macroRequire(Requirements.scala:56) at .<init>(<console>:20) at .<clinit>(<console>) at .<init>(<console>:7) at .<clinit>(<console>) at $print(<console>) at sun.reflect.NativeMethodAccessorImpl.invoke...
- Source
- Requirements.scala
- Alphabetic
- By Inheritance
- Requirements
- Requirements
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- class RequirementsHelper extends Serializable
Helper class used by code generated by the
require
macro.
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- 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()
- macro def require(condition: Boolean, clue: Any)(implicit prettifier: Prettifier): Unit
Require that a boolean condition about an argument passed to a method, function, or constructor, and described in the given
clue
, is true.Require that a boolean condition about an argument passed to a method, function, or constructor, and described in the given
clue
, is true.If the condition is
true
, this method returns normally. Else, it throwsIllegalArgumentException
with theString
obtained by invokingtoString
on the specifiedclue
and appending that to the macro-generated error message as the exception's detail message.- condition
the boolean condition to check as requirement
- clue
an objects whose
toString
method returns a message to include in a failure report.
- Definition Classes
- Requirements
- Exceptions thrown
IllegalArgumentException
if the condition isfalse
.NullPointerException
ifmessage
isnull
.
- macro def require(condition: Boolean)(implicit prettifier: Prettifier): Unit
Require that a boolean condition is true about an argument passed to a method, function, or constructor.
Require that a boolean condition is true about an argument passed to a method, function, or constructor.
If the condition is
true
, this method returns normally. Else, it throwsIllegalArgumentException
.This method is implemented in terms of a Scala macro that will generate an error message. See the main documentation for this trait for examples.
- condition
the boolean condition to check as requirement
- Definition Classes
- Requirements
- Exceptions thrown
IllegalArgumentException
if the condition isfalse
.
- macro def requireNonNull(arguments: Any*)(implicit prettifier: Prettifier, pos: Position): Unit
Require that all passed arguments are non-null.
Require that all passed arguments are non-null.
If none of the passed arguments are
null
, this method returns normally. Else, it throwsNullArgumentException
with an error message that includes the name (as it appeared in the source) of each argument that wasnull
.- arguments
arguments to check for
null
value
- Definition Classes
- Requirements
- Exceptions thrown
NullArgumentException
if any of the arguments arenull
.
- macro def requireState(condition: Boolean, clue: Any)(implicit prettifier: Prettifier): Unit
Require that a boolean condition about the state of an object on which a method has been invoked, and described in the given
clue
, is true.Require that a boolean condition about the state of an object on which a method has been invoked, and described in the given
clue
, is true.If the condition is
true
, this method returns normally. Else, it throwsIllegalStateException
with theString
obtained by invokingtoString
on the specifiedclue
appended to the macro-generated error message as the exception's detail message.- condition
the boolean condition to check as a requirement
- clue
an object whose
toString
method returns a message to include in a failure report.
- Definition Classes
- Requirements
- Exceptions thrown
IllegalStateException
if the condition isfalse
.NullPointerException
ifmessage
isnull
.
- macro def requireState(condition: Boolean)(implicit prettifier: Prettifier): Unit
Require that a boolean condition is true about the state of an object on which a method has been invoked.
Require that a boolean condition is true about the state of an object on which a method has been invoked.
If the condition is
true
, this method returns normally. Else, it throwsIllegalStateException
.This method is implemented in terms of a Scala macro that will generate an error message.
- condition
the boolean condition to check as requirement
- Definition Classes
- Requirements
- Exceptions thrown
IllegalStateException
if the condition isfalse
.
- val requirementsHelper: RequirementsHelper
Helper instance used by code generated by macro assertion.
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- 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()