@@ -92,11 +92,9 @@ test_that("unspecified can be cast to shaped vectors", {
9292 expect_identical(out , exp )
9393})
9494
95- test_that(" vec_cast() only falls back when casting to base type" , {
95+ test_that(" vec_cast() falls back to base class even when casting to non- base type" , {
9696 expect_equal(vec_cast(foobar(mtcars ), mtcars ), mtcars )
97- expect_snapshot({
98- (expect_error(vec_cast(mtcars , foobar(mtcars ))))
99- })
97+ expect_equal(vec_cast(mtcars , foobar(mtcars )), mtcars )
10098})
10199
102100test_that(" vec_cast() only attempts to fall back if `to` is a data frame (#1568)" , {
@@ -284,3 +282,24 @@ test_that("df-fallback for cast is not sensitive to attributes order", {
284282
285283 expect_identical(vec_cast(x , ptype ), x )
286284})
285+
286+ test_that(" bare-type fallback for df-cast works" , {
287+ # NOTE: Not sure why this was necessary. The cubble and yamlet
288+ # packages fail without this.
289+
290+ df <- data_frame(x = 1 , y = yamlet :: classified(" foo" ))
291+ gdf <- dplyr :: new_grouped_df(
292+ df ,
293+ data_frame(x = 1 , .rows = list (1L )),
294+ class = " vctrs_foobar"
295+ )
296+
297+ exp_df <- data_frame(x = c(1 , 1 ), y = yamlet :: classified(c(" foo" , " foo" )))
298+ exp_gdf <- dplyr :: new_grouped_df(
299+ exp_df ,
300+ data_frame(x = 1 , .rows = list (1 : 2 )),
301+ class = " vctrs_foobar"
302+ )
303+
304+ expect_error(vec_rbind(gdf , gdf ), NA )
305+ })
0 commit comments