@@ -4,6 +4,10 @@ test_that("length compared correctly", {
44 expect_success(expect_shape(1 : 10 , length = 10 ))
55 expect_success(expect_shape(letters [1 : 5 ], length = 5 ))
66 expect_success(expect_shape(integer(), length = 0 ))
7+
8+ x <- list (1 : 10 , letters )
9+ out <- expect_shape(x , length = 2 )
10+ expect_identical(out , x )
711})
812
913test_that(" dim compared correctly" , {
@@ -17,6 +21,10 @@ test_that("dim compared correctly", {
1721 expect_success(expect_shape(array (integer()), dim = 0L ))
1822 dd <- c(0L , 0L , 0L , 5L , 0L , 0L , 0L )
1923 expect_success(expect_shape(array (dim = dd ), dim = dd ))
24+
25+ x <- cbind(1 : 2 , 3 : 4 )
26+ out <- expect_shape(x , dim = c(2L , 2L ))
27+ expect_identical(out , x )
2028})
2129
2230test_that(" nrow compared correctly" , {
@@ -27,6 +35,10 @@ test_that("nrow compared correctly", {
2735 expect_success(expect_shape(array (integer()), nrow = 0L ))
2836 dd <- c(0L , 0L , 0L , 5L , 0L , 0L , 0L )
2937 expect_success(expect_shape(array (dim = dd ), nrow = 0L ))
38+
39+ x <- cbind(1 : 2 , 3 : 4 )
40+ out <- expect_shape(x , dim = c(2L , 2L ))
41+ expect_identical(out , x )
3042})
3143
3244test_that(" ncol compared correctly" , {
@@ -37,6 +49,10 @@ test_that("ncol compared correctly", {
3749 expect_snapshot_failure(expect_shape(array (integer()), ncol = 0L ))
3850 dd <- c(0L , 0L , 0L , 5L , 0L , 0L , 0L )
3951 expect_success(expect_shape(array (dim = dd ), ncol = 0L ))
52+
53+ x <- cbind(1 : 2 , 3 : 4 )
54+ out <- expect_shape(x , dim = c(2L , 2L ))
55+ expect_identical(out , x )
4056})
4157
4258test_that(" uses S3 dim method" , {
@@ -69,12 +85,6 @@ test_that("uses S4 dim method", {
6985 expect_success(expect_shape(A(x = 1 : 9 , y = 3 ), dim = 8 : 10 ))
7086})
7187
72- test_that(" returns input" , {
73- x <- list (1 : 10 , letters )
74- out <- expect_shape(x , length = 2 )
75- expect_identical(out , x )
76- })
77-
7888test_that(" at least one argument is required" , {
7989 err_msg <- " Exactly one of `length`, `nrow`, `ncol`, or `dim` must be provided."
8090 expect_snapshot(expect_shape(1 : 10 ), error = TRUE ) # no args
0 commit comments