Skip to content

Commit

Permalink
fix: rethrow a failure exception for ok and failure
Browse files Browse the repository at this point in the history
  • Loading branch information
etorreborre committed Jul 4, 2024
1 parent 3680da1 commit bfb0ea8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ trait ThrownExpectables extends ExpectationsCreation {
// overriding this method is necessary to include the ThrownExpectation trait into the stacktrace of the created match result
override def applyMatcher[S >: T](m: =>Matcher[S]): MatchResult[S] = super.applyMatcher(m)
override def check[S >: T](r: MatchResult[S]): MatchResult[S] = checkFailure(r)
override def checkResult(r: Result): Result = checkResultFailure(r)
override val desc = alias
override def map[S](f: T => S): Expectable[S] = createExpectable(f(value), desc)
override def mapDescription(d: Option[String => String]): Expectable[T] = createExpectable(value, d)
Expand Down Expand Up @@ -77,7 +78,7 @@ trait ThrownExpectables extends ExpectationsCreation {
r
}

/** this method can be overriden to throw exceptions when checking the match result */
/** this method can be overridden to throw exceptions when checking the match result */
override protected def checkMatchResultFailure[T](m: MatchResult[T]) = {
m match {
case f@MatchFailure(_, _, _, _, _) => throw new MatchFailureException(f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,9 @@ class MatchResultCombinatorsSpec extends mutable.Spec with ResultMatchers with M
"there is only one stored expectation (see #320)" ==> { stored must haveSize(1) }
stored.map(_.message).head must_== "'hello world' doesn't have size 10 but size 11"
}
"issue #1255 ok and failure must throw an exception" >> {
new MustThrownExpectations {
ok and failure
} must throwA[execute.FailureException]
}
}

0 comments on commit bfb0ea8

Please sign in to comment.