Inside

object Inside extends Inside

Companion object that facilitates the importing of the inside construct as an alternative to mixing it in. One use case is to import the inside construct so you can use it in the Scala interpreter:

$ scala -cp scalatest-1.8.jar
Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_29).
Type in expressions to have them evaluated.
Type :help for more information.

scala> import org.scalatest._
import org.scalatest._

scala> import matchers.Matchers._
import matchers.Matchers._

scala> import Inside._
import Inside._

scala> inside (List(1, 2, 3)) { case List(x, y, z) =>
   |   y should equal (2)
   | }

scala> inside (List(1, 2, 3)) { case List(x, y, z) =>
    |   x should equal (2)
    | }
org.scalatest.TestFailedException: 1 did not equal 2, inside List(1, 2, 3)
 at org.scalatest.matchers.Matchers$class.newTestFailedException(Matchers.scala:150)
 at org.scalatest.matchers.Matchers$.newTestFailedException(Matchers.scala:2331)
 at org.scalatest.matchers.Matchers$ShouldMethodHelper$.shouldMatcher(Matchers.scala:873)
 ...
Companion:
class
trait Inside
class Object
trait Matchable
class Any
Inside.type

Value members

Concrete methods

def insideWithPos[T, U](value: T, pf: PartialFunction[T, U], pos: Position): U

Inherited methods

inline def inside[T, U](value: T)(pf: PartialFunction[T, U]): U

Inspects inside the passed value using the passed partial function.

Inspects inside the passed value using the passed partial function.

The inside method checks to see whether the partial function passed as the second curried parameter is defined at the value passed as the first parameter, and if so, passes that value to the partial function.

If the partial function is not defined at the passed value, inside will throw a TestFailedException with a detail message describing the problem. Otherwise, if the partial function returns normally, inside will return normally. If the partial function completes abruptly with an exception that mixes in ModifiableMessage (such as TestFailedException), inside will append the value's toString of to the exception's detail message, and rethrow it. If the exception thrown by the partial function does not mix in ModifiableMessage, inside completes abruptly with that same exception.

Value parameters:
pf

the partial function to use to inspect inside the passed value

value

the value inside of which to inspect

Throws:
TestFailedException

if the passed partial function is not defined at the passed value

Inherited from:
Inside