Skip to content

Commit

Permalink
Update snapshots (#311)
Browse files Browse the repository at this point in the history
And suppress a message
  • Loading branch information
hadley authored Nov 22, 2023
1 parent 42d29d4 commit 887fb75
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 28 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Suggests:
magrittr,
rmarkdown,
RSQLite,
testthat (>= 3.0.0),
testthat (>= 3.2.0),
vctrs (>= 0.3.0),
waldo (>= 0.3.0),
withr
Expand Down
35 changes: 21 additions & 14 deletions tests/testthat/_snaps/color.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,57 @@

Code
glue_col("{%}")
Error <simpleError>
<text>:1:1: unexpected input
Condition
Error in `parse()`:
! <text>:1:1: unexpected input
1: %
^

---

Code
glue_col("{foo %}")
Error <simpleError>
object 'foo' of mode 'function' was not found
Condition
Error in `get()`:
! object 'foo' of mode 'function' was not found

---

Code
glue_col("{foo %}")
Error <simpleError>
object 'foo' of mode 'function' was not found
Condition
Error in `get()`:
! object 'foo' of mode 'function' was not found

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

Code
glue_col("Colorless {green idea's} sleep furiously")
Error <simpleError>
Unterminated quote (')
Condition
Error in `glue_data()`:
! Unterminated quote (')

---

Code
glue_col("Colorless {green idea\"s} sleep furiously")
Error <simpleError>
Unterminated quote (")
Condition
Error in `glue_data()`:
! Unterminated quote (")

---

Code
glue_col("Colorless {green idea`s} sleep furiously")
Error <simpleError>
Unterminated quote (`)
Condition
Error in `glue_data()`:
! Unterminated quote (`)

---

Code
glue_col("Hey a URL: {blue https://example.com/#section}")
Error <simpleError>
A '#' comment in a glue expression must terminate with a newline.
Condition
Error in `glue_data()`:
! A '#' comment in a glue expression must terminate with a newline.

30 changes: 18 additions & 12 deletions tests/testthat/_snaps/glue.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,44 @@

Code
as_glue("a") + 1
Error <simpleError>
RHS must be a character vector.
Condition
Error in `+.glue`:
! RHS must be a character vector.
Code
1 + as_glue("a")
Error <simpleError>
LHS must be a character vector.
Condition
Error in `+.glue`:
! LHS must be a character vector.

# `+` method errors for inputs of incompatible size

Code
as_glue(letters[1:2]) + letters[1:3]
Error <simpleError>
Variables must be length 1 or 3
Condition
Error:
! Variables must be length 1 or 3

# unterminated comment

Code
glue("pre {1 + 5 # comment} post")
Error <simpleError>
A '#' comment in a glue expression must terminate with a newline.
Condition
Error in `glue_data()`:
! A '#' comment in a glue expression must terminate with a newline.

---

Code
glue("pre {1 + 5 # comment")
Error <simpleError>
A '#' comment in a glue expression must terminate with a newline.
Condition
Error in `glue_data()`:
! A '#' comment in a glue expression must terminate with a newline.

# `.literal` treats quotes and `#` as regular characters

Code
glue("{'fo`o\"#}", .transformer = function(x, ...) x)
Error <simpleError>
Unterminated quote (')
Condition
Error in `glue_data()`:
! Unterminated quote (')

2 changes: 1 addition & 1 deletion tests/testthat/test-glue.R
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ test_that("throws informative error if interpolating a function", {
expect_error(glue("{cat}"), "is a function")

# some crayon functions are OK, make sure this still works
if (require("crayon")) {
if (require("crayon", quietly = TRUE)) {
expect_s3_class(glue("{red}red{reset}"), "glue")
}
})
Expand Down

0 comments on commit 887fb75

Please sign in to comment.