|
1 | 1 | #' Mock functions in a package. |
2 | 2 | #' |
3 | 3 | #' @description |
4 | | -#' `r lifecycle::badge("superseded")` |
| 4 | +#' `r lifecycle::badge("deprecated")` |
5 | 5 | #' |
6 | | -#' `with_mock()` and `local_mock()` are superseded in favour of |
| 6 | +#' `with_mock()` and `local_mock()` are deprecated in favour of |
7 | 7 | #' [with_mocked_bindings()] and [local_mocked_bindings()]. |
8 | 8 | #' |
9 | | -#' These works by using some C code to temporarily modify the mocked function |
10 | | -#' _in place_. This is abusive of R's internals, which makes it dangerous, and |
11 | | -#' no longer recommended. |
12 | | -#' |
13 | | -#' @section 3rd edition: |
14 | | -#' `r lifecycle::badge("deprecated")` |
15 | | -#' |
16 | | -#' `with_mock()` and `local_mock()` are deprecated in the third edition. |
| 9 | +#' These functions worked by using some C code to temporarily modify the mocked |
| 10 | +#' function _in place_. This was an abuse of R's internals and it is no longer |
| 11 | +#' permitted. |
17 | 12 | #' |
18 | 13 | #' @param ... named parameters redefine mocked functions, unnamed parameters |
19 | 14 | #' will be evaluated after mocking the functions |
|
26 | 21 | #' @return The result of the last unnamed parameter |
27 | 22 | #' @export |
28 | 23 | with_mock <- function(..., .env = topenv()) { |
29 | | - edition_deprecate(3, "with_mock()", "Please use with_mocked_bindings() instead") |
| 24 | + lifecycle::deprecate_warn("3.3.0", "with_mock()", "with_mocked_bindings()") |
30 | 25 |
|
31 | 26 | dots <- eval(substitute(alist(...))) |
32 | 27 | mock_qual_names <- names(dots) |
@@ -61,7 +56,7 @@ with_mock <- function(..., .env = topenv()) { |
61 | 56 | #' @export |
62 | 57 | #' @rdname with_mock |
63 | 58 | local_mock <- function(..., .env = topenv(), .local_envir = parent.frame()) { |
64 | | - edition_deprecate(3, "local_mock()", "Please use local_mocked_bindings() instead") |
| 59 | + lifecycle::deprecate_warn("3.3.0", "local_mock()", "local_mocked_bindings()") |
65 | 60 |
|
66 | 61 | mocks <- extract_mocks(list(...), .env = .env) |
67 | 62 | on_exit <- bquote( |
|
0 commit comments