Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions R/expect-that.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,3 @@ fail <- function(
succeed <- function(message = "Success has been forced", info = NULL) {
expect(TRUE, message, info = info)
}

#' Negate an expectation
#'
#' This negates an expectation, making it possible to express that you
#' want the opposite of a standard expectation. This function is deprecated
#' and will be removed in a future version.
#'
#' @param f an existing expectation function
#' @keywords internal
#' @export
not <- function(f) {
warning("`not()` is deprecated.", call. = FALSE)
stopifnot(is.function(f))

negate <- function(expt) {
expect(
!expectation_success(expt),
failure_message = paste0("NOT(", expt$message, ")"),
srcref = expt$srcref
)
}

function(...) {
negate(capture_expectation(f(...)))
}
}
26 changes: 26 additions & 0 deletions R/old-school.R
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,29 @@ takes_less_than <- function(amount) {
)
}
}

#' Negate an expectation
#'
#' This negates an expectation, making it possible to express that you
#' want the opposite of a standard expectation. This function is deprecated
#' and will be removed in a future version.
#'
#' @param f an existing expectation function
#' @keywords internal
#' @export
not <- function(f) {
warning("`not()` is deprecated.", call. = FALSE)
stopifnot(is.function(f))

negate <- function(expt) {
expect(
!expectation_success(expt),
failure_message = paste0("NOT(", expt$message, ")"),
srcref = expt$srcref
)
}

function(...) {
negate(capture_expectation(f(...)))
}
}
2 changes: 1 addition & 1 deletion man/not.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading