Skip to content

Commit 41bb354

Browse files
authored
Re-align tests and R files (#2137)
1 parent 2910813 commit 41bb354

19 files changed

+92
-95
lines changed
File renamed without changes.

β€ŽR/expect-equality.Rβ€Ž

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -201,42 +201,3 @@ expect_equivalent <- function(
201201
}
202202
pass(act$val)
203203
}
204-
205-
206-
#' Does code return a reference to the expected object?
207-
#'
208-
#' `expect_reference()` compares the underlying memory addresses of
209-
#' two symbols. It is for expert use only.
210-
#'
211-
#' @section 3rd edition:
212-
#' `r lifecycle::badge("deprecated")`
213-
#'
214-
#' `expect_reference()` is deprecated in the third edition. If you know what
215-
#' you're doing, and you really need this behaviour, just use `is_reference()`
216-
#' directly: `expect_true(rlang::is_reference(x, y))`.
217-
#'
218-
#' @inheritParams expect_equal
219-
#' @family expectations
220-
#' @keywords internal
221-
#' @export
222-
expect_reference <- function(
223-
object,
224-
expected,
225-
info = NULL,
226-
label = NULL,
227-
expected.label = NULL
228-
) {
229-
edition_deprecate(3, "expect_reference()")
230-
231-
act <- quasi_label(enquo(object), label, arg = "object")
232-
exp <- quasi_label(enquo(expected), expected.label, arg = "expected")
233-
234-
if (!is_reference(act$val, exp$val)) {
235-
msg <- sprintf("%s not a reference to %s.", act$lab, exp$lab)
236-
return(fail(msg, info = info))
237-
}
238-
pass(act$val)
239-
}
240-
241-
# expect_reference() needs dev version of rlang
242-
utils::globalVariables("is_reference")
File renamed without changes.

β€ŽR/expect-reference.Rβ€Ž

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#' Does code return a reference to the expected object?
2+
#'
3+
#' `expect_reference()` compares the underlying memory addresses of
4+
#' two symbols. It is for expert use only.
5+
#'
6+
#' @section 3rd edition:
7+
#' `r lifecycle::badge("deprecated")`
8+
#'
9+
#' `expect_reference()` is deprecated in the third edition. If you know what
10+
#' you're doing, and you really need this behaviour, just use `is_reference()`
11+
#' directly: `expect_true(rlang::is_reference(x, y))`.
12+
#'
13+
#' @inheritParams expect_equal
14+
#' @family expectations
15+
#' @keywords internal
16+
#' @export
17+
expect_reference <- function(
18+
object,
19+
expected,
20+
info = NULL,
21+
label = NULL,
22+
expected.label = NULL
23+
) {
24+
edition_deprecate(3, "expect_reference()")
25+
26+
act <- quasi_label(enquo(object), label, arg = "object")
27+
exp <- quasi_label(enquo(expected), expected.label, arg = "expected")
28+
29+
if (!is_reference(act$val, exp$val)) {
30+
msg <- sprintf("%s not a reference to %s.", act$lab, exp$lab)
31+
return(fail(msg, info = info))
32+
}
33+
pass(act$val)
34+
}
35+
36+
# expect_reference() needs dev version of rlang
37+
utils::globalVariables("is_reference")

β€Žman/expect_match.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/expect_reference.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/testthat_examples.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.

β€Žtests/testthat/test-browser.Rβ€Ž

Lines changed: 0 additions & 6 deletions
This file was deleted.
File renamed without changes.

β€Žtests/testthat/test-expect-constant.Rβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,8 @@ test_that("expect_null works", {
3030
expect_snapshot_failure(expect_null(1L))
3131
expect_snapshot_failure(expect_null(environment()))
3232
})
33+
34+
test_that("returns the input value", {
35+
res <- expect_true(TRUE)
36+
expect_equal(res, TRUE)
37+
})

0 commit comments

Comments
Β (0)