Open EECOLOR opened 9 years ago
private val beRight =
new Assertion[Either[_, _]] {
def assert(s: => Either[_, _]) =
if (s.isRight) Success(success)
else Failure("Expected Right")
}
private val beLeft: Assertion[Either[Any, _]] = beLeft(None)
private def beLeft[T](expected: => T): Assertion[Either[T, _]] = beLeft(Some(expected))
private def beLeft[T](expected: => Option[T]) =
new Assertion[Either[T, _]] {
def assert(s: => Either[T, _]) =
s match {
case Left(value) => Success(expected map (value is _) getOrElse success)
case _ => Failure("Expected Left")
}
}
Should we collect them in a separate library?