Skip to content

Commit 79c6eea

Browse files
committed
Add test
1 parent 9997221 commit 79c6eea

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/testthat/test-utilities.r

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,34 @@ test_that("cut_*() checks its input and output", {
127127
test_that("interleave() checks the vector lengths", {
128128
expect_snapshot_error(interleave(1:4, numeric()))
129129
})
130+
131+
test_that("vec_rbind0 can combined ordered factors", {
132+
133+
withr::local_options(lifecycle_verbosity = "warning")
134+
135+
# Ideally code below throws just 1 warning (the <ordered> and <ordered> one)
136+
# However, it was technically challenging to reduce the numbers of warnings
137+
# See #5139 for more details
138+
139+
expect_warning(
140+
expect_warning(
141+
expect_warning(
142+
{
143+
test <- vec_rbind0(
144+
data_frame0(a = factor(c("A", "B"), ordered = TRUE)),
145+
data_frame0(a = factor(c("B", "C"), ordered = TRUE))
146+
)
147+
},
148+
"<ordered> and <ordered>", class = "lifecycle_warning_deprecated"
149+
),
150+
"<ordered> and <factor>", class = "lifecycle_warning_deprecated"
151+
),
152+
"<ordered> and <factor>", class = "lifecycle_warning_deprecated"
153+
)
154+
155+
# Should be <factor> not <ordered/factor>, hence the 'exact'
156+
expect_s3_class(test$a, "factor", exact = TRUE)
157+
# Test levels are combined sensibly
158+
expect_equal(levels(test$a), c("A", "B", "C"))
159+
160+
})

0 commit comments

Comments
 (0)