@@ -127,3 +127,34 @@ test_that("cut_*() checks its input and output", {
127127test_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