Skip to content

Commit 0dd3429

Browse files
committed
Use correct paste0() argument
And add an explicit test for the behaviour
1 parent 3cb0cdc commit 0dd3429

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

R/expect-constant.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ expect_waldo_constant_ <- function(
8686
msg <- c(
8787
sprintf("Expected %s to be %s.", act$lab, exp$lab),
8888
"Differences:",
89-
paste0(comp, collpase = "\n")
89+
paste0(comp, "\n")
9090
)
9191
fail(msg, info = info, trace_env = trace_env)
9292
} else {

R/expect-equality.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ expect_waldo_equal_ <- function(
151151
msg <- c(
152152
sprintf(msg, act$lab, exp$lab),
153153
"Differences:",
154-
paste0(comp, collpase = "\n")
154+
paste0(comp, "\n")
155155
)
156156
fail(msg, info = info, trace_env = trace_env)
157157
}

tests/testthat/_snaps/expect-equality.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,26 @@
4040
Differences:
4141
Types not compatible: double is not character
4242

43+
# correctly spaces lines
44+
45+
Code
46+
expect_equal(list(a = 1), list(a = "b", b = 10))
47+
Condition
48+
Error:
49+
! Expected `list(a = 1)` to be equal to `list(a = "b", b = 10)`.
50+
Differences:
51+
`actual` is length 1
52+
`expected` is length 2
53+
54+
`names(actual)`: "a"
55+
`names(expected)`: "a" "b"
56+
57+
`actual$a` is a double vector (1)
58+
`expected$a` is a character vector ('b')
59+
60+
`actual$b` is absent
61+
`expected$b` is a double vector (10)
62+
4363
# provide useful feedback on failure (2e)
4464

4565
Code

tests/testthat/test-expect-equality.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ test_that("provide useful feedback on failure (3e)", {
7272
expect_snapshot_failure(expect_equal(x, "a"))
7373
})
7474

75+
test_that("correctly spaces lines", {
76+
expect_snapshot_failure(expect_equal(list(a = 1), list(a = "b", b = 10)))
77+
})
78+
7579
test_that("provide useful feedback on failure (2e)", {
7680
local_edition(2)
7781
withr::local_options(testthat.edition_ignore = TRUE)
@@ -93,6 +97,7 @@ test_that("% is not treated as sprintf format specifier (#445)", {
9397
expect_success(expect_equal("%", "%"))
9498
})
9599

100+
96101
# 2nd edition ---------------------------------------------------
97102

98103
test_that("useful message if objects equal but not identical", {

0 commit comments

Comments
 (0)