Skip to content

Commit

Permalink
Check that snapshots always strip \r (#2004)
Browse files Browse the repository at this point in the history
Closes  #1958
  • Loading branch information
hadley authored Oct 29, 2024
1 parent eb8c17c commit bf09659
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/testthat/_snaps/snapshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@
Error in `f()`:
! 4

# line-endings fixed before comparison

Code
cat(x)
Output
a
b

# multiple outputs of same type are collapsed

Code
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-snapshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ test_that("empty lines are preserved", {
expect_snapshot(f(), error = TRUE)
})

test_that("line-endings fixed before comparison", {
x <- "a\n\rb"
expect_snapshot(cat(x))
})

test_that("multiple outputs of same type are collapsed", {
expect_snapshot({
x <- 1
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-verify-output.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,9 @@ test_that("verify_exec() doesn't leave tempfiles around", {

expect_equal(before, after)
})

test_that("verify_exec() strips CR", {
act <- verify_exec(quote(cat("\r\n")))
exp <- verify_exec(quote(cat("\n")))
expect_equal(act[-1], exp[-1])
})

0 comments on commit bf09659

Please sign in to comment.