Skip to content

Commit ae0c564

Browse files
committed
Merge commit '509a26f3f5ab49d0ee5711b4038da3cf2556a458'
2 parents dbaf1cf + 509a26f commit ae0c564

31 files changed

+123
-135
lines changed

NEWS.md

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

3+
* `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).
4+
* `expect_snapshot_value()` can now handle expressions that generate `-` (#1678) or zero length atomic vectors (#2042).
35
* `expect_matches()` failures should be a little easier to read (#2135).
46
* New `local_on_cran(TRUE)` allows you to simulate how your tests will run on CRAN (#2112).
57
* `expect_no_*()` now executes the entire code block, rather than stopping at the first message or warning (#1991).

R/expect-comparison.R

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,35 +54,35 @@ expect_compare_ <- function(
5454
#' @export
5555
#' @rdname comparison-expectations
5656
expect_lt <- function(object, expected, label = NULL, expected.label = NULL) {
57-
act <- quasi_label(enquo(object), label, arg = "object")
58-
exp <- quasi_label(enquo(expected), expected.label, arg = "expected")
57+
act <- quasi_label(enquo(object), label)
58+
exp <- quasi_label(enquo(expected), expected.label)
5959

6060
expect_compare_("<", act, exp)
6161
}
6262

6363
#' @export
6464
#' @rdname comparison-expectations
6565
expect_lte <- function(object, expected, label = NULL, expected.label = NULL) {
66-
act <- quasi_label(enquo(object), label, arg = "object")
67-
exp <- quasi_label(enquo(expected), expected.label, arg = "expected")
66+
act <- quasi_label(enquo(object), label)
67+
exp <- quasi_label(enquo(expected), expected.label)
6868

6969
expect_compare_("<=", act, exp)
7070
}
7171

7272
#' @export
7373
#' @rdname comparison-expectations
7474
expect_gt <- function(object, expected, label = NULL, expected.label = NULL) {
75-
act <- quasi_label(enquo(object), label, arg = "object")
76-
exp <- quasi_label(enquo(expected), expected.label, arg = "expected")
75+
act <- quasi_label(enquo(object), label)
76+
exp <- quasi_label(enquo(expected), expected.label)
7777

7878
expect_compare_(">", act, exp)
7979
}
8080

8181
#' @export
8282
#' @rdname comparison-expectations
8383
expect_gte <- function(object, expected, label = NULL, expected.label = NULL) {
84-
act <- quasi_label(enquo(object), label, arg = "object")
85-
exp <- quasi_label(enquo(expected), expected.label, arg = "expected")
84+
act <- quasi_label(enquo(object), label)
85+
exp <- quasi_label(enquo(expected), expected.label)
8686

8787
expect_compare_(">=", act, exp)
8888
}

R/expect-constant.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ NULL
2929
#' @export
3030
#' @rdname logical-expectations
3131
expect_true <- function(object, info = NULL, label = NULL) {
32-
act <- quasi_label(enquo(object), label, arg = "object")
32+
act <- quasi_label(enquo(object), label)
3333
exp <- labelled_value(TRUE, "TRUE")
3434
expect_waldo_equal_("equal", act, exp, info = info, ignore_attr = TRUE)
3535
}
3636

3737
#' @export
3838
#' @rdname logical-expectations
3939
expect_false <- function(object, info = NULL, label = NULL) {
40-
act <- quasi_label(enquo(object), label, arg = "object")
40+
act <- quasi_label(enquo(object), label)
4141
exp <- labelled_value(FALSE, "FALSE")
4242
expect_waldo_equal_("equal", act, exp, info = info, ignore_attr = TRUE)
4343
}
@@ -57,7 +57,7 @@ expect_false <- function(object, info = NULL, label = NULL) {
5757
#' expect_null(x)
5858
#' show_failure(expect_null(y))
5959
expect_null <- function(object, info = NULL, label = NULL) {
60-
act <- quasi_label(enquo(object), label, arg = "object")
60+
act <- quasi_label(enquo(object), label)
6161
exp <- labelled_value(NULL, "FALSE")
6262
expect_waldo_equal_("equal", act, exp, info = info)
6363
}

R/expect-equality.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ expect_equal <- function(
6363
label = NULL,
6464
expected.label = NULL
6565
) {
66-
act <- quasi_label(enquo(object), label, arg = "object")
67-
exp <- quasi_label(enquo(expected), expected.label, arg = "expected")
66+
act <- quasi_label(enquo(object), label)
67+
exp <- quasi_label(enquo(expected), expected.label)
6868

6969
if (edition_get() >= 3) {
7070
expect_waldo_equal_("equal", act, exp, info, ..., tolerance = tolerance)
@@ -93,8 +93,8 @@ expect_identical <- function(
9393
expected.label = NULL,
9494
...
9595
) {
96-
act <- quasi_label(enquo(object), label, arg = "object")
97-
exp <- quasi_label(enquo(expected), expected.label, arg = "expected")
96+
act <- quasi_label(enquo(object), label)
97+
exp <- quasi_label(enquo(expected), expected.label)
9898

9999
if (edition_get() >= 3) {
100100
expect_waldo_equal_("identical", act, exp, info, ...)
@@ -180,8 +180,8 @@ expect_equivalent <- function(
180180
label = NULL,
181181
expected.label = NULL
182182
) {
183-
act <- quasi_label(enquo(object), label, arg = "object")
184-
exp <- quasi_label(enquo(expected), expected.label, arg = "expected")
183+
act <- quasi_label(enquo(object), label)
184+
exp <- quasi_label(enquo(expected), expected.label)
185185

186186
edition_deprecate(
187187
3,

R/expect-inheritance.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ NULL
4848
expect_type <- function(object, type) {
4949
stopifnot(is.character(type), length(type) == 1)
5050

51-
act <- quasi_label(enquo(object), arg = "object")
51+
act <- quasi_label(enquo(object))
5252
act_type <- typeof(act$val)
5353

5454
if (!identical(act_type, type)) {
@@ -69,7 +69,7 @@ expect_type <- function(object, type) {
6969
#' from `class`. If `TRUE`, checks that object has a class that's identical
7070
#' to `class`.
7171
expect_s3_class <- function(object, class, exact = FALSE) {
72-
act <- quasi_label(enquo(object), arg = "object")
72+
act <- quasi_label(enquo(object))
7373
act$class <- format_class(class(act$val))
7474
exp_lab <- format_class(class)
7575

@@ -112,7 +112,7 @@ expect_s7_class <- function(object, class) {
112112
stop_input_type(class, "an S7 class object")
113113
}
114114

115-
act <- quasi_label(enquo(object), arg = "object")
115+
act <- quasi_label(enquo(object))
116116

117117
if (!S7::S7_inherits(object)) {
118118
return(fail(sprintf("%s is not an S7 object", act$lab)))
@@ -136,7 +136,7 @@ expect_s7_class <- function(object, class) {
136136
#' @export
137137
#' @rdname inheritance-expectations
138138
expect_s4_class <- function(object, class) {
139-
act <- quasi_label(enquo(object), arg = "object")
139+
act <- quasi_label(enquo(object))
140140
act$class <- format_class(methods::is(act$val))
141141
exp_lab <- format_class(class)
142142

@@ -194,7 +194,7 @@ expect_is <- function(object, class, info = NULL, label = NULL) {
194194
"Use `expect_type()`, `expect_s3_class()`, or `expect_s4_class()` instead"
195195
)
196196

197-
act <- quasi_label(enquo(object), label, arg = "object")
197+
act <- quasi_label(enquo(object), label)
198198
act$class <- format_class(class(act$val))
199199
exp_lab <- format_class(class(class))
200200

R/expect-known.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ expect_known_value <- function(
164164
"Please use `expect_snapshot_value()` instead"
165165
)
166166

167-
act <- quasi_label(enquo(object), label, arg = "object")
167+
act <- quasi_label(enquo(object), label)
168168

169169
if (!file.exists(file)) {
170170
warning("Creating reference value", call. = FALSE)
@@ -214,7 +214,7 @@ expect_known_hash <- function(object, hash = NULL) {
214214
"Please use `expect_snapshot_value()` instead"
215215
)
216216

217-
act <- quasi_label(enquo(object), arg = "object")
217+
act <- quasi_label(enquo(object))
218218
act_hash <- digest::digest(act$val)
219219
if (!is.null(hash)) {
220220
act_hash <- substr(act_hash, 1, nchar(hash))

R/expect-length.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
expect_length <- function(object, n) {
1717
stopifnot(is.numeric(n), length(n) == 1)
1818

19-
act <- quasi_label(enquo(object), arg = "object")
19+
act <- quasi_label(enquo(object))
2020
act$n <- length(act$val)
2121

2222
if (act$n != n) {

R/expect-match.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ expect_match <- function(
3737
info = NULL,
3838
label = NULL
3939
) {
40-
act <- quasi_label(enquo(object), label, arg = "object")
40+
act <- quasi_label(enquo(object), label)
4141

4242
check_character(object)
4343
check_string(regexp)
@@ -76,7 +76,7 @@ expect_no_match <- function(
7676
label = NULL
7777
) {
7878
# Capture here to avoid environment-related messiness
79-
act <- quasi_label(enquo(object), label, arg = "object")
79+
act <- quasi_label(enquo(object), label)
8080
stopifnot(is.character(regexp), length(regexp) == 1)
8181
stopifnot(is.character(act$val))
8282

R/expect-named.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ expect_named <- function(
3232
info = NULL,
3333
label = NULL
3434
) {
35-
act <- quasi_label(enquo(object), label, arg = "object")
35+
act <- quasi_label(enquo(object), label)
3636
act$names <- names(act$val)
3737

3838
if (missing(expected)) {

R/expect-reference.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ expect_reference <- function(
2323
) {
2424
edition_deprecate(3, "expect_reference()")
2525

26-
act <- quasi_label(enquo(object), label, arg = "object")
27-
exp <- quasi_label(enquo(expected), expected.label, arg = "expected")
26+
act <- quasi_label(enquo(object), label)
27+
exp <- quasi_label(enquo(expected), expected.label)
2828

2929
if (!is_reference(act$val, exp$val)) {
3030
msg <- sprintf("%s not a reference to %s.", act$lab, exp$lab)

0 commit comments

Comments
 (0)