Skip to content

Commit 3a9a93c

Browse files
authored
Update standalone files + standardize snapshot tests (#1579)
* Use recent standalone files * Recent standalone don't accept integers * Use regular snapshot tests. Avoid nesting `expect_error()` * Standardize snapshot tests. and use `cnd_class = TRUE` if `expect_error()` was used. Put cnd_class on the first line to make it easy to remove it as needed. * tidyselect 1.2.1 * Add workaround for old R snapshot failure * avoid snapshot for this test since it changes slightly across R versions * remove cnd_class = TRUE * Separate snapshot tests for errors. * Update corresponding snapshots
1 parent fcedd52 commit 3a9a93c

Some content is hidden

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

51 files changed

+985
-679
lines changed

R/append.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ df_append <- function(x, y, after = NULL, remove = FALSE) {
3838
after <- match(after, x_names)
3939
}
4040

41-
check_number_whole(after, min = 0L, max = n, .internal = TRUE)
41+
# r-lib/rlang#1702
42+
check_number_whole(after, min = 0, max = as.numeric(n), .internal = TRUE)
4243

4344
if (remove) {
4445
lhs <- seq2(1L, after - 1L)

R/compat-lazyeval.R renamed to R/import-standalone-lazyeval.R

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1-
# nocov start - compat-lazyeval (last updated: rlang 0.3.0)
2-
1+
# Standalone file: do not edit by hand
2+
# Source: https://github.com/r-lib/rlang/blob/HEAD/R/standalone-lazyeval.R
3+
# Generated by: usethis::use_standalone("r-lib/rlang", "lazyeval")
4+
# ----------------------------------------------------------------------
5+
#
6+
# ---
7+
# repo: r-lib/rlang
8+
# file: standalone-lazyeval.R
9+
# last-updated: 2018-09-18
10+
# license: https://unlicense.org
11+
# imports: rlang
12+
# ---
13+
#
314
# This file serves as a reference for compatibility functions for lazyeval.
4-
# Please find the most recent version in rlang's repository.
5-
15+
#
16+
# nocov start
617

718
warn_underscored <- function() {
819
return(NULL)
@@ -48,7 +59,7 @@ compat_lazy <- function(lazy, env = caller_env(), warn = TRUE) {
4859
},
4960
list =
5061
if (inherits(lazy, "lazy")) {
51-
lazy <- new_quosure(lazy$expr, lazy$env)
62+
lazy = new_quosure(lazy$expr, lazy$env)
5263
}
5364
)
5465

R/compat-obj-type.R renamed to R/import-standalone-obj-type.R

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
1-
# nocov start --- r-lib/rlang compat-obj-type
1+
# Standalone file: do not edit by hand
2+
# Source: https://github.com/r-lib/rlang/blob/HEAD/R/standalone-obj-type.R
3+
# Generated by: usethis::use_standalone("r-lib/rlang", "obj-type")
4+
# ----------------------------------------------------------------------
25
#
3-
# Changelog
4-
# =========
6+
# ---
7+
# repo: r-lib/rlang
8+
# file: standalone-obj-type.R
9+
# last-updated: 2024-02-14
10+
# license: https://unlicense.org
11+
# imports: rlang (>= 1.1.0)
12+
# ---
13+
#
14+
# ## Changelog
15+
#
16+
# 2024-02-14:
17+
# - `obj_type_friendly()` now works for S7 objects.
18+
#
19+
# 2023-05-01:
20+
# - `obj_type_friendly()` now only displays the first class of S3 objects.
21+
#
22+
# 2023-03-30:
23+
# - `stop_input_type()` now handles `I()` input literally in `arg`.
524
#
625
# 2022-10-04:
726
# - `obj_type_friendly(value = TRUE)` now shows numeric scalars
@@ -36,7 +55,8 @@
3655
# - Added support for matrices and arrays (#141).
3756
# - Added documentation.
3857
# - Added changelog.
39-
58+
#
59+
# nocov start
4060

4161
#' Return English-friendly type
4262
#' @param x Any R object.
@@ -55,7 +75,7 @@ obj_type_friendly <- function(x, value = TRUE) {
5575
if (inherits(x, "quosure")) {
5676
type <- "quosure"
5777
} else {
58-
type <- paste(class(x), collapse = "/")
78+
type <- class(x)[[1L]]
5979
}
6080
return(sprintf("a <%s> object", type))
6181
}
@@ -251,19 +271,19 @@ vec_type_friendly <- function(x, length = FALSE) {
251271
#' Return OO type
252272
#' @param x Any R object.
253273
#' @return One of `"bare"` (for non-OO objects), `"S3"`, `"S4"`,
254-
#' `"R6"`, or `"R7"`.
274+
#' `"R6"`, or `"S7"`.
255275
#' @noRd
256276
obj_type_oo <- function(x) {
257277
if (!is.object(x)) {
258278
return("bare")
259279
}
260280

261-
class <- inherits(x, c("R6", "R7_object"), which = TRUE)
281+
class <- inherits(x, c("R6", "S7_object"), which = TRUE)
262282

263283
if (class[[1]]) {
264284
"R6"
265285
} else if (class[[2]]) {
266-
"R7"
286+
"S7"
267287
} else if (isS4(x)) {
268288
"S4"
269289
} else {
@@ -288,7 +308,7 @@ stop_input_type <- function(x,
288308
show_value = TRUE,
289309
arg = caller_arg(x),
290310
call = caller_env()) {
291-
# From compat-cli.R
311+
# From standalone-cli.R
292312
cli <- env_get_list(
293313
nms = c("format_arg", "format_code"),
294314
last = topenv(),
@@ -305,10 +325,15 @@ stop_input_type <- function(x,
305325
if (length(what)) {
306326
what <- oxford_comma(what)
307327
}
328+
if (inherits(arg, "AsIs")) {
329+
format_arg <- identity
330+
} else {
331+
format_arg <- cli$format_arg
332+
}
308333

309334
message <- sprintf(
310335
"%s must be %s, not %s.",
311-
cli$format_arg(arg),
336+
format_arg(arg),
312337
what,
313338
obj_type_friendly(x, value = show_value)
314339
)

0 commit comments

Comments
 (0)