Skip to content

Commit 3930d25

Browse files
committed
Merged origin/main into succeed-fail
2 parents 4417121 + 56707a8 commit 3930d25

File tree

8 files changed

+29
-127
lines changed

8 files changed

+29
-127
lines changed

NAMESPACE

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,13 @@ export(is.expectation)
145145
export(is_a)
146146
export(is_checking)
147147
export(is_equivalent_to)
148-
export(is_false)
149148
export(is_identical_to)
150149
export(is_informative_error)
151150
export(is_less_than)
152151
export(is_more_than)
153-
export(is_null)
154152
export(is_parallel)
155153
export(is_snapshot)
156154
export(is_testing)
157-
export(is_true)
158155
export(it)
159156
export(local_edition)
160157
export(local_mock)
@@ -164,7 +161,6 @@ export(local_snapshotter)
164161
export(local_test_context)
165162
export(local_test_directory)
166163
export(make_expectation)
167-
export(matches)
168164
export(mock_output_sequence)
169165
export(new_expectation)
170166
export(not)

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# testthat (development version)
22

3+
* `is_null()`/`matches()` deprecated in 2.0.0 (2017-12-19) and `is_true()`/`is_false()` deprecated in 2.1.0 (2019-04-23) have been removed (#2109).
34
* `local_edition()` now gives a useful error for bad values (#1547).
45
* testthat now requires R 4.1.
56
* `expect_s4_class()` now supports unquoting (@stibu81, #2064).

R/expect-self-test.R

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ expect_snapshot_reporter <- function(
120120
paths = test_path("reporters/tests.R")
121121
) {
122122
local_options(rlang_trace_format_srcrefs = FALSE)
123-
local_rng_version("3.3")
123+
withr::local_rng_version("3.3")
124124
set.seed(1014)
125125
# withr::local_seed(1014)
126126

@@ -133,12 +133,6 @@ expect_snapshot_reporter <- function(
133133
)
134134
}
135135

136-
# to work around https://github.com/r-lib/withr/issues/167
137-
local_rng_version <- function(version, .local_envir = parent.frame()) {
138-
withr::defer(RNGversion(as.character(getRversion())), envir = .local_envir)
139-
suppressWarnings(RNGversion(version))
140-
}
141-
142136
# Use specifically for testthat tests in order to override the
143137
# defaults found when starting the reporter
144138
local_output_override <- function(

R/expect-that.R

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -76,29 +76,3 @@ succeed <- function(message = "Success has been forced", info = NULL) {
7676

7777
expectation("success", message)
7878
}
79-
80-
#' Negate an expectation
81-
#'
82-
#' This negates an expectation, making it possible to express that you
83-
#' want the opposite of a standard expectation. This function is deprecated
84-
#' and will be removed in a future version.
85-
#'
86-
#' @param f an existing expectation function
87-
#' @keywords internal
88-
#' @export
89-
not <- function(f) {
90-
warning("`not()` is deprecated.", call. = FALSE)
91-
stopifnot(is.function(f))
92-
93-
negate <- function(expt) {
94-
expect(
95-
!expectation_success(expt),
96-
failure_message = paste0("NOT(", expt$message, ")"),
97-
srcref = expt$srcref
98-
)
99-
}
100-
101-
function(...) {
102-
negate(capture_expectation(f(...)))
103-
}
104-
}

R/old-school.R

Lines changed: 26 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,46 +14,12 @@
1414
#' @keywords internal
1515
NULL
1616

17-
#' @export
18-
#' @rdname oldskool
19-
is_null <- function() {
20-
warning(
21-
"`is_null()` is deprecated. Please use `expect_null()` instead.",
22-
call. = FALSE
23-
)
24-
function(x) expect_null(x)
25-
}
26-
2717
#' @export
2818
#' @rdname oldskool
2919
is_a <- function(class) {
3020
function(x) expect_is(x, class)
3121
}
3222

33-
#' @export
34-
#' @rdname oldskool
35-
is_true <- function() {
36-
function(x) {
37-
warning(
38-
"`is_true()` is deprecated. Please use `expect_true()` instead.",
39-
call. = FALSE
40-
)
41-
expect_true(x)
42-
}
43-
}
44-
45-
#' @export
46-
#' @rdname oldskool
47-
is_false <- function() {
48-
function(x) {
49-
warning(
50-
"`is_false()` is deprecated. Please use `expect_false()` instead.",
51-
call. = FALSE
52-
)
53-
expect_false(x)
54-
}
55-
}
56-
5723
#' @export
5824
#' @rdname oldskool
5925
has_names <- function(expected, ignore.order = FALSE, ignore.case = FALSE) {
@@ -127,17 +93,6 @@ throws_error <- function(regexp = NULL, ...) {
12793
function(x) expect_error(x, regexp, ...)
12894
}
12995

130-
#' @export
131-
#' @rdname oldskool
132-
matches <- function(regexp, all = TRUE, ...) {
133-
warning(
134-
"`matches()` is deprecated. Please use `expect_match()` instead.",
135-
call. = FALSE
136-
)
137-
function(x) expect_match(x, regexp, all = all, ...)
138-
}
139-
140-
14196
#' Does code take less than the expected amount of time to run?
14297
#'
14398
#' This is useful for performance regression testing.
@@ -160,3 +115,29 @@ takes_less_than <- function(amount) {
160115
)
161116
}
162117
}
118+
119+
#' Negate an expectation
120+
#'
121+
#' This negates an expectation, making it possible to express that you
122+
#' want the opposite of a standard expectation. This function is deprecated
123+
#' and will be removed in a future version.
124+
#'
125+
#' @param f an existing expectation function
126+
#' @keywords internal
127+
#' @export
128+
not <- function(f) {
129+
warning("`not()` is deprecated.", call. = FALSE)
130+
stopifnot(is.function(f))
131+
132+
negate <- function(expt) {
133+
expect(
134+
!expectation_success(expt),
135+
failure_message = paste0("NOT(", expt$message, ")"),
136+
srcref = expt$srcref
137+
)
138+
}
139+
140+
function(...) {
141+
negate(capture_expectation(f(...)))
142+
}
143+
}

man/not.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.

man/oldskool.Rd

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

tests/testthat/test-old-school.R

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,9 @@
1-
test_that("old school logical works", {
2-
local_edition(2L)
3-
4-
expect_warning(
5-
expect_success(expect_that(TRUE, is_true())),
6-
"deprecated"
7-
)
8-
9-
expect_warning(
10-
expect_success(expect_that(FALSE, is_false())),
11-
"deprecated"
12-
)
13-
})
14-
151
test_that("old school types still work", {
162
local_edition(2L)
173

184
expect_success(expect_that(1L, is_a("integer")))
195
})
206

21-
test_that("tidyverse conflicts throw warnings", {
22-
local_edition(2L)
23-
24-
expect_warning(
25-
expect_that(NULL, is_null()),
26-
"deprecated"
27-
)
28-
29-
expect_warning(
30-
expect_that("te*st", matches("e*", fixed = TRUE)),
31-
"deprecated"
32-
)
33-
expect_warning(
34-
expect_that("test", matches("TEST", ignore.case = TRUE)),
35-
"deprecated"
36-
)
37-
})
38-
397
test_that("old school names still work", {
408
local_edition(2L)
419

0 commit comments

Comments
 (0)