Skip to content

Commit c8daa5c

Browse files
committed
Check fail() too; and clarify docs
1 parent e8fb98f commit c8daa5c

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

β€ŽR/expect-that.Rβ€Ž

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
#' Learn more about creating your own expectations in
99
#' `vignette("custom-expectation")`.
1010
#'
11-
#' @param message Failure message to send to the user. It's best practice to
12-
#' describe both what is expected and what was actually received.
11+
#' @param message A character vector describing the failure. The
12+
#' first element should describe the expected value, and the second (and
13+
#' optionally subsequence) elements should describe what was actually seen.
1314
#' @param info Character vector continuing additional information. Included
1415
#' for backward compatibility only and new expectations should not use it.
1516
#' @param srcref Location of the failure. Should only needed to be explicitly
@@ -41,6 +42,9 @@ fail <- function(
4142
trace_env = caller_env(),
4243
trace = NULL
4344
) {
45+
check_character(message)
46+
check_character(info, all_null = TRUE)
47+
4448
trace <- trace %||% capture_trace(trace_env)
4549
message <- paste(c(message, info), collapse = "\n")
4650
expectation("failure", message, srcref = srcref, trace = trace)

β€ŽR/expectation.Rβ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
#' `vignette("custom-expectation")` for details.
66
#'
77
#' @param ok `TRUE` or `FALSE` indicating if the expectation was successful.
8-
#' @param failure_message Message to show if the expectation failed.
8+
#' @param failure_message A character vector describing the failure. The
9+
#' first element should describe the expected value, and the second (and
10+
#' optionally subsequence) elements should describe what was actually seen.
911
#' @inheritParams fail
1012
#' @return An expectation object from either `succeed()` or `fail()`.
1113
#' with a `continue_test` restart.

β€Žman/expect.Rdβ€Ž

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žman/fail.Rdβ€Ž

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žman/succeed.Rdβ€Ž

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
Β (0)