Skip to content

Commit

Permalink
Avoid use of _ in these tests
Browse files Browse the repository at this point in the history
Closes #260

Anticipates a possible future in which `_` is the placeholder for the native pipe.

These are better as snapshot tests anyway.
  • Loading branch information
jennybc committed Feb 23, 2022
1 parent 3da70df commit b614e22
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
@@ -1,5 +1,7 @@
# glue (development version)

* Modify a test for better forward compatibility with R.

# glue 1.6.1

* glue now registers its custom knitr engines in a way that is more robust to namespace-loading edge cases that can arise during package installation (#254).
Expand Down
23 changes: 23 additions & 0 deletions tests/testthat/_snaps/color.md
@@ -1,3 +1,26 @@
# glue_col() errors for invalid syntax or when color_fun can't be found

Code
glue_col("{%}")
Error <simpleError>
<text>:1:1: unexpected input
1: %
^

---

Code
glue_col("{foo %}")
Error <simpleError>
object 'foo' of mode 'function' was not found

---

Code
glue_col("{foo %}")
Error <simpleError>
object 'foo' of mode 'function' was not found

# glue_col() can exploit the `.literal` argument

Code
Expand Down
13 changes: 7 additions & 6 deletions tests/testthat/test-color.R
Expand Up @@ -43,14 +43,15 @@ test_that("glue_col() works on nested colors", {
})

test_that("glue_col() errors for invalid syntax or when color_fun can't be found", {
expect_error(glue_col("{_}"), "unexpected input")
expect_error(glue_col("{foo _}"), "object 'foo' of mode 'function' was not found")
expect_snapshot(error = TRUE, glue_col("{%}"))

foo <- 1
expect_error(glue_col("{foo _}"), "object 'foo' of mode 'function' was not found")
expect_snapshot(error = TRUE, glue_col("{foo %}"))

foo <- crayon::blue
expect_identical(glue_col("{foo _}"), as_glue(foo("_")))
foo <- 1
expect_snapshot(error = TRUE, glue_col("{foo %}"))

foo <- crayon::blue
expect_identical(glue_col("{foo %}"), as_glue(foo("%")))
})

test_that("glue_data_col() works", {
Expand Down

0 comments on commit b614e22

Please sign in to comment.