Skip to content

Commit bf09659

Browse files
authored
Check that snapshots always strip \r (#2004)
Closes #1958
1 parent eb8c17c commit bf09659

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

tests/testthat/_snaps/snapshot.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@
4444
Error in `f()`:
4545
! 4
4646

47+
# line-endings fixed before comparison
48+
49+
Code
50+
cat(x)
51+
Output
52+
a
53+
b
54+
4755
# multiple outputs of same type are collapsed
4856

4957
Code

tests/testthat/test-snapshot.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ test_that("empty lines are preserved", {
3030
expect_snapshot(f(), error = TRUE)
3131
})
3232

33+
test_that("line-endings fixed before comparison", {
34+
x <- "a\n\rb"
35+
expect_snapshot(cat(x))
36+
})
37+
3338
test_that("multiple outputs of same type are collapsed", {
3439
expect_snapshot({
3540
x <- 1

tests/testthat/test-verify-output.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,9 @@ test_that("verify_exec() doesn't leave tempfiles around", {
9191

9292
expect_equal(before, after)
9393
})
94+
95+
test_that("verify_exec() strips CR", {
96+
act <- verify_exec(quote(cat("\r\n")))
97+
exp <- verify_exec(quote(cat("\n")))
98+
expect_equal(act[-1], exp[-1])
99+
})

0 commit comments

Comments
 (0)