Skip to content

Commit

Permalink
Merge pull request #342 from nealrichardson/master
Browse files Browse the repository at this point in the history
Fix failure_msg and success_msg for throws_error
  • Loading branch information
hadley committed Jan 12, 2016
2 parents b455a58 + 4650f50 commit be428eb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# testthat 0.11.0.9000

* Fix failure message for `throws_error` in case where no error is raised (@nealrichardson, #342).

* Added [Catch](https://github.com/philsquared/Catch) for unit testing of C++ code.
See `?use_catch()` for more details. (@kevinushey)

Expand Down
4 changes: 2 additions & 2 deletions R/expectations-matches.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ throws_error <- function(regexp = NULL, ...) {
if (no_error) {
return(expectation(
identical(regexp, NA),
"code raised an error",
"code didn't raise an error"
"code didn't raise an error",
"code raised an error"
))
}

Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-expectations.r
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ test_that("errors are caught with throws_error", {
test_that("failure to throw an error is a failure", {
res <- throws_error()(log(1))
expect_that(res$passed, is_false())
expect_output(res, "code didn't raise an error")

res <- throws_error("error")(log(1))
expect_that(res$passed, is_false())
Expand Down

0 comments on commit be428eb

Please sign in to comment.