Skip to content

Commit 1988ac8

Browse files
authored
Move expect_that() to old-school.R (#2128)
1 parent 3c45e5c commit 1988ac8

File tree

3 files changed

+39
-39
lines changed

3 files changed

+39
-39
lines changed

R/expect-that.R

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,3 @@
1-
#' Expect that a condition holds.
2-
#'
3-
#' @description
4-
#' `r lifecycle::badge("superseded")`
5-
#'
6-
#' An old style of testing that's no longer encouraged.
7-
#'
8-
#' @section 3rd edition:
9-
#' `r lifecycle::badge("deprecated")`
10-
#'
11-
#' This style of testing is formally deprecated as of the 3rd edition.
12-
#' Use a more specific `expect_` function instead.
13-
#'
14-
#' @param object Object to test.
15-
#'
16-
#' Supports limited unquoting to make it easier to generate readable failures
17-
#' within a function or for loop. See [quasi_label] for more details.
18-
#' @param condition, a function that returns whether or not the condition
19-
#' is met, and if not, an error message to display.
20-
#' @param label Used to customise failure messages. For expert use only.
21-
#' @param info Extra information to be included in the message. This argument
22-
#' is soft-deprecated and should not be used in new code. Instead see
23-
#' alternatives in [quasi_label].
24-
#' @return the (internal) expectation result as an invisible list
25-
#' @keywords internal
26-
#' @export
27-
#' @seealso [fail()] for an expectation that always fails.
28-
#' @examples
29-
#' expect_that(5 * 2, equals(10))
30-
#' expect_that(sqrt(2) ^ 2, equals(2))
31-
#' \dontrun{
32-
#' expect_that(sqrt(2) ^ 2, is_identical_to(2))
33-
#' }
34-
expect_that <- function(object, condition, info = NULL, label = NULL) {
35-
edition_deprecate(3, "expect_that()")
36-
condition(object)
37-
}
38-
391
#' `pass()` or `fail()` a test
402
#'
413
#' @description

R/old-school.R

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
1+
#' Expect that a condition holds.
2+
#'
3+
#' @description
4+
#' `r lifecycle::badge("superseded")`
5+
#'
6+
#' An old style of testing that's no longer encouraged.
7+
#'
8+
#' @section 3rd edition:
9+
#' `r lifecycle::badge("deprecated")`
10+
#'
11+
#' This style of testing is formally deprecated as of the 3rd edition.
12+
#' Use a more specific `expect_` function instead.
13+
#'
14+
#' @param object Object to test.
15+
#'
16+
#' Supports limited unquoting to make it easier to generate readable failures
17+
#' within a function or for loop. See [quasi_label] for more details.
18+
#' @param condition, a function that returns whether or not the condition
19+
#' is met, and if not, an error message to display.
20+
#' @param label Used to customise failure messages. For expert use only.
21+
#' @param info Extra information to be included in the message. This argument
22+
#' is soft-deprecated and should not be used in new code. Instead see
23+
#' alternatives in [quasi_label].
24+
#' @return the (internal) expectation result as an invisible list
25+
#' @keywords internal
26+
#' @export
27+
#' @seealso [fail()] for an expectation that always fails.
28+
#' @examples
29+
#' expect_that(5 * 2, equals(10))
30+
#' expect_that(sqrt(2) ^ 2, equals(2))
31+
#' \dontrun{
32+
#' expect_that(sqrt(2) ^ 2, is_identical_to(2))
33+
#' }
34+
expect_that <- function(object, condition, info = NULL, label = NULL) {
35+
edition_deprecate(3, "expect_that()")
36+
condition(object)
37+
}
38+
139
#' Old-style expectations.
240
#'
341
#' @description

man/expect_that.Rd

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

0 commit comments

Comments
 (0)