Skip to content

Commit

Permalink
Concrete demo of what I'm seeing
Browse files Browse the repository at this point in the history
  • Loading branch information
jennybc committed Feb 16, 2024
1 parent 1b5e691 commit 4c6083e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/testthat/_snaps/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,31 @@
b
c

# Jenny's problem [plain]

Code
cli_code_wrapper("if (1) {true_val} else {false_val}")
Message
if (1) TRUE else 'FALSE'

# Jenny's problem [ansi]

Code
cli_code_wrapper("if (1) {true_val} else {false_val}")
Message
if (1) TRUE else 'FALSE'

# Jenny's problem [unicode]

Code
cli_code_wrapper("if (1) {true_val} else {false_val}")
Message
if (1) TRUE else 'FALSE'

# Jenny's problem [fancy]

Code
cli_code_wrapper("if (1) {true_val} else {false_val}")
Message
if (1) TRUE else 'FALSE'

11 changes: 11 additions & 0 deletions tests/testthat/test-code.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,14 @@ test_that_cli("issue #154", {
cli_code("a\nb\nc")
})
})

test_that_cli("Jenny's problem", {
cli_code_wrapper <- function(x, .envir = parent.frame()) {
x <- glue::glue(x, .envir = .envir)
cli_code(x, .envir = .envir) # <- passing .envir along is problematic
}

true_val <- "TRUE"
false_val <- "'FALSE'"
expect_snapshot(cli_code_wrapper("if (1) {true_val} else {false_val}"))
})

0 comments on commit 4c6083e

Please sign in to comment.