Skip to content

Commit d8ecebc

Browse files
authored
Merge branch 'main' into feature/desc_filter_improvement
2 parents 2b1a8ca + 00b3cc1 commit d8ecebc

File tree

127 files changed

+438
-258
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+438
-258
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ export(skip_on_os)
192192
export(skip_on_travis)
193193
export(skip_unless_r)
194194
export(snapshot_accept)
195+
export(snapshot_reject)
195196
export(snapshot_review)
196197
export(source_dir)
197198
export(source_file)

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# testthat (development version)
22

33
* Test filtering now works with `it()`, and the `desc` argument can take a character vector in order to recursively filter subtests (i.e. `it()` nested inside of `describe()`) (#2118).
4+
* New `snapshot_reject()` rejects all modified snapshots by deleting the `.new` variants (#1923).
45
* New `SlowReporter` makes it easier to find the slowest tests in your package. The easiest way to run it is with `devtools::test(reporter = "slow")` (#1466).
56
* Power `expect_mapequal()` with `waldo::compare(list_as_map = TRUE)` (#1521).
67
* On CRAN, `test_that()` now automatically skips if a package is not installed (#1585). Practically, this means that you no longer need to check that suggested packages are installed. (We don't do this in the tidyverse because we think it has limited payoff, but other styles advise differently.)
@@ -20,7 +21,7 @@
2021
* `vignette("custom-expectations)` has been overhauled to make it much clearer how to create high-quality expectations (#2113, #2132, #2072).
2122
* `expect_snapshot()` and friends will now fail when creating a new snapshot on CI. This is usually a signal that you've forgotten to run it locally before committing (#1461).
2223
* `expect_snapshot_value()` can now handle expressions that generate `-` (#1678) or zero length atomic vectors (#2042).
23-
* `expect_matches()` failures should be a little easier to read (#2135).
24+
* `expect_matches()` failures should be a little easier to read (#2135, #2181).
2425
* New `local_on_cran(TRUE)` allows you to simulate how your tests will run on CRAN (#2112).
2526
* `expect_no_*()` now executes the entire code block, rather than stopping at the first message or warning (#1991).
2627
* `expect_no_failures()` and `expect_no_successes()` are now deprecated as `expect_success()` now test for no failures and `expect_failure()` tests for no successes (#)

R/describe.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#'
2727
#' @param description description of the feature
2828
#' @param code test code containing the specs
29+
#' @keywords internal
2930
#' @export
3031
#' @examples
3132
#' describe("matrix()", {

R/expect-comparison.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' Does code return a number greater/less than the expected value?
1+
#' Do you expect a number bigger or smaller than this?
22
#'
33
#' @inheritParams expect_equal
44
#' @param object,expected A value to compare and its expected bound.
@@ -39,7 +39,10 @@ expect_compare_ <- function(
3939

4040
cmp <- op(act$val, exp$val)
4141
if (length(cmp) != 1 || !is.logical(cmp)) {
42-
abort("Result of comparison must be a single logical value")
42+
abort(
43+
"Result of comparison must be a single logical value",
44+
call = trace_env
45+
)
4346
}
4447
if (!isTRUE(cmp)) {
4548
digits <- max(

R/expect-condition.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' Does code throw an error, warning, message, or other condition?
1+
#' Do you expect an error, warning, message, or other condition?
22
#'
33
#' @description
44
#' `expect_error()`, `expect_warning()`, `expect_message()`, and

R/expect-constant.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' Does code return `TRUE` or `FALSE`?
1+
#' Do you expect `TRUE` or `FALSE`?
22
#'
33
#' @description
44
#' These are fall-back expectations that you can use when none of the other
@@ -42,7 +42,7 @@ expect_false <- function(object, info = NULL, label = NULL) {
4242
expect_waldo_equal_("equal", act, exp, info = info, ignore_attr = TRUE)
4343
}
4444

45-
#' Does code return `NULL`?
45+
#' Do you expect `NULL`?
4646
#'
4747
#' This is a special case because `NULL` is a singleton so it's possible
4848
#' check for it either with `expect_equal(x, NULL)` or `expect_type(x, "NULL")`.

R/expect-equality.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' Does code return the expected value?
1+
#' Do you expect this value?
22
#'
33
#' @description
44
#' These functions provide two levels of strictness when comparing a

R/expect-inheritance.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#' Does code return an object inheriting from the expected base type, S3 class,
2-
#' or S4 class?
1+
#' Do you expect an S3/S4/R6/S7 object that inherits from this class?
32
#'
43
#' @description
54
#' See <https://adv-r.hadley.nz/oo.html> for an overview of R's OO systems, and
@@ -207,7 +206,7 @@ expect_s7_class <- function(object, class) {
207206
pass(act$val)
208207
}
209208

210-
#' Does an object inherit from a given class?
209+
#' Do you expect to inherit from this class?
211210
#'
212211
#' @description
213212
#' `r lifecycle::badge("superseded")`

R/expect-invisible.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' Does code return a visible or invisible object?
1+
#' Do you expect the result to be (in)visible?
22
#'
33
#' Use this to test whether a function returns a visible or invisible
44
#' output. Typically you'll use this to check that functions called primarily

R/expect-known.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' Expectations: is the output or the value equal to a known good value?
1+
#' Do you expect the results/output to equal a known value?
22
#'
33
#' For complex printed output and objects, it is often challenging to describe
44
#' exactly what you expect to see. `expect_known_value()` and
@@ -113,7 +113,7 @@ compare_file <- function(path, lines, ..., update = TRUE, info = NULL) {
113113
pass(NULL)
114114
}
115115

116-
#' Expectations: is the output or the value equal to a known good value?
116+
#' Do you expect the output/result to equal a known good value?
117117
#'
118118
#' `expect_output_file()` behaves identically to [expect_known_output()].
119119
#'

0 commit comments

Comments
 (0)