Skip to content

Commit 98c9387

Browse files
appease air
1 parent 3550b0a commit 98c9387

2 files changed

Lines changed: 36 additions & 9 deletions

File tree

‎R/inline.R‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,13 @@ make_cmd_transformer <- function(values, .call = NULL, .eval = TRUE) {
389389
}
390390
}
391391

392-
glue_cmd <- function(..., .envir, .call = sys.call(-1), .trim = TRUE, .eval = TRUE) {
392+
glue_cmd <- function(
393+
...,
394+
.envir,
395+
.call = sys.call(-1),
396+
.trim = TRUE,
397+
.eval = TRUE
398+
) {
393399
str <- paste0(unlist(list(...), use.names = FALSE), collapse = "")
394400
values <- new.env(parent = emptyenv())
395401
transformer <- make_cmd_transformer(values, .call = .call, .eval = .eval)

‎tests/testthat/test-inline-2.R‎

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,27 +228,35 @@ test_that("cli_extract_vars", {
228228

229229
# Deeply nested styles and hyperlink styles
230230
expect_identical(
231-
cli_extract_vars("{.pkg {.emph {pkg}}} and {.href [text {a}](https://x.com/{b})}"),
231+
cli_extract_vars(
232+
"{.pkg {.emph {pkg}}} and {.href [text {a}](https://x.com/{b})}"
233+
),
232234
c("pkg", "a", "b")
233235
)
234236

235237
# Pluralization directives and helpers
236238
expect_identical(
237-
cli_extract_vars("Found {n} file{?s} and {?no/one/some} {ndir} director{?y/ies}."),
239+
cli_extract_vars(
240+
"Found {n} file{?s} and {?no/one/some} {ndir} director{?y/ies}."
241+
),
238242
c("n", "ndir")
239243
)
240244
expect_identical(
241245
cli_extract_vars("Will remove {?no/the/the} {pkgs} package{?s}."),
242246
"pkgs"
243247
)
244248
expect_identical(
245-
cli_extract_vars("{nupd}/{ntotal} {qty(nupd)} file{?s} and {no(nfile)} dir{?s}"),
249+
cli_extract_vars(
250+
"{nupd}/{ntotal} {qty(nupd)} file{?s} and {no(nfile)} dir{?s}"
251+
),
246252
c("nupd", "ntotal", "qty", "no", "nfile")
247253
)
248254

249255
# Escaped braces, empty braces, and purrr dot exceptions
250256
expect_identical(
251-
cli_extract_vars("Escaped {{ignored}} and {.code {{also_ignored}}} and {} with {used}"),
257+
cli_extract_vars(
258+
"Escaped {{ignored}} and {.code {{also_ignored}}} and {} with {used}"
259+
),
252260
"used"
253261
)
254262
expect_identical(
@@ -258,11 +266,18 @@ test_that("cli_extract_vars", {
258266

259267
# Character vectors and named character vectors (bullets and dl/li)
260268
expect_identical(
261-
cli_extract_vars(c("Header {a}", "i" = "Info {.val {b}}", "x" = "Error {c}")),
269+
cli_extract_vars(c(
270+
"Header {a}",
271+
"i" = "Info {.val {b}}",
272+
"x" = "Error {c}"
273+
)),
262274
c("a", "b", "c")
263275
)
264276
expect_identical(
265-
cli_extract_vars(c("{.field {term1}}" = "Means {desc1}", "{term2}" = "{desc2}")),
277+
cli_extract_vars(c(
278+
"{.field {term1}}" = "Means {desc1}",
279+
"{term2}" = "{desc2}"
280+
)),
266281
c("term1", "term2", "desc1", "desc2")
267282
)
268283

@@ -273,11 +288,17 @@ test_that("cli_extract_vars", {
273288
expect_identical(cli_extract_vars("plain text {.arg x}"), character())
274289
expect_identical(cli_extract_vars(NA_character_), character())
275290
expect_identical(cli_extract_vars(c("hello {a}", NA_character_)), "a")
276-
expect_identical(cli_extract_vars("{stop(not_evaluated)}"), c("stop", "not_evaluated"))
291+
expect_identical(
292+
cli_extract_vars("{stop(not_evaluated)}"),
293+
c("stop", "not_evaluated")
294+
)
277295

278296
# Syntax and markup errors
279297
expect_error(cli_extract_vars("unclosed {a"), "Expecting '\\}'")
280298
expect_error(cli_extract_vars("bad {a + }"), "Could not parse cli")
281299
expect_error(cli_extract_vars("bad {.foobar}"), "Invalid cli literal")
282-
expect_error(cli_extract_vars("bad {?s}"), "Cannot pluralize without a quantity")
300+
expect_error(
301+
cli_extract_vars("bad {?s}"),
302+
"Cannot pluralize without a quantity"
303+
)
283304
})

0 commit comments

Comments
 (0)