@@ -92,11 +92,9 @@ test_that("unspecified can be cast to shaped vectors", {
92
92
expect_identical(out , exp )
93
93
})
94
94
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" , {
96
96
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 )
100
98
})
101
99
102
100
test_that(" vec_cast() only attempts to fall back if `to` is a data frame (#1568)" , {
@@ -284,3 +282,20 @@ test_that("df-fallback for cast is not sensitive to attributes order", {
284
282
285
283
expect_identical(vec_cast(x , ptype ), x )
286
284
})
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
+ local_methods(
290
+ c.vctrs_foobaz = function (... ) quux(NextMethod())
291
+ )
292
+
293
+ df <- data_frame(x = 1 , y = foobaz(" foo" ))
294
+ gdf <- dplyr :: new_grouped_df(
295
+ df ,
296
+ data_frame(x = 1 , .rows = list (1L )),
297
+ class = " vctrs_foobar"
298
+ )
299
+
300
+ expect_error(vec_rbind(gdf , gdf ), NA )
301
+ })
0 commit comments