@@ -18,34 +18,42 @@ test_that("can find a common type among tables with identical dimensions", {
1818 tab1 <- new_table()
1919 tab2 <- new_table(1 : 2 , dim = c(1L , 2L , 1L ))
2020
21- expect_identical(vec_ptype2(tab1 , tab1 ), zap_dimnames( new_table() ))
22- expect_identical(vec_ptype2(tab2 , tab2 ), zap_dimnames( new_table(dim = c(0L , 2L , 1L ) )))
21+ expect_identical(vec_ptype2(tab1 , tab1 ), new_table())
22+ expect_identical(vec_ptype2(tab2 , tab2 ), new_table(dim = c(0L , 2L , 1L )))
2323})
2424
2525test_that(" size is not considered in the ptype" , {
2626 x <- new_table(1 : 2 , dim = 2L )
2727 y <- new_table(1 : 3 , dim = 3L )
2828
29- expect_identical(vec_ptype2(x , y ), zap_dimnames( new_table() ))
29+ expect_identical(vec_ptype2(x , y ), new_table())
3030})
3131
3232test_that(" vec_ptype2() can broadcast table shapes" , {
3333 x <- new_table(dim = c(0L , 1L ))
3434 y <- new_table(dim = c(0L , 2L ))
3535
36- expect_identical(vec_ptype2(x , y ), zap_dimnames( new_table(dim = c(0L , 2L ) )))
36+ expect_identical(vec_ptype2(x , y ), new_table(dim = c(0L , 2L )))
3737
3838 x <- new_table(dim = c(0L , 1L , 3L ))
3939 y <- new_table(dim = c(0L , 2L , 1L ))
4040
41- expect_identical(vec_ptype2(x , y ), zap_dimnames(new_table(dim = c(0L , 2L , 3L ))))
41+ expect_identical(vec_ptype2(x , y ), new_table(dim = c(0L , 2L , 3L )))
42+ })
43+
44+ test_that(" vec_ptype2() never propagates dimnames" , {
45+ x <- new_table(dim = c(0L , 1L ), dimnames = list (character (), " x1" ))
46+ y <- new_table(dim = c(0L , 2L ), dimnames = list (character (), c(" y1" , " y2" )))
47+
48+ expect_null(dimnames(vec_ptype2(x , x )))
49+ expect_null(dimnames(vec_ptype2(x , y )))
4250})
4351
4452test_that(" implicit axes are broadcast" , {
4553 x <- new_table(dim = c(0L , 2L ))
4654 y <- new_table(dim = c(0L , 1L , 3L ))
4755
48- expect_identical(vec_ptype2(x , y ), zap_dimnames( new_table(dim = c(0L , 2L , 3L ) )))
56+ expect_identical(vec_ptype2(x , y ), new_table(dim = c(0L , 2L , 3L )))
4957})
5058
5159test_that(" errors on non-broadcastable dimensions" , {
@@ -80,7 +88,7 @@ test_that("common types have symmetry when mixed with unspecified input", {
8088test_that(" `table` delegates coercion" , {
8189 expect_identical(
8290 vec_ptype2(new_table(1 ), new_table(FALSE )),
83- zap_dimnames( new_table(double() ))
91+ new_table(double())
8492 )
8593 expect_error(
8694 vec_ptype2(new_table(1 ), new_table(" " )),
0 commit comments