@@ -50,10 +50,17 @@ test_that("ignores order", {
5050 expect_success(expect_mapequal(list (a = 1 , b = 2 ), list (b = 2 , a = 1 )))
5151})
5252
53+ test_that(" ignores order recursively" , {
54+ local_edition(3 )
55+ x <- list (outer_1 = 1 , outer_2 = list (inner_1 = 1 , inner_2 = 2 ))
56+ y <- list (outer_2 = list (inner_2 = 2 , inner_1 = 1 ), outer_1 = 1 )
57+ expect_success(expect_mapequal(x , y ))
58+ })
59+
5360test_that(" error if any names are duplicated" , {
54- expect_error (expect_mapequal(list (a = 1 , b = 2 , b = 3 ), list (b = 2 , a = 1 )))
55- expect_error (expect_mapequal(list (a = 1 , b = 2 ), list (b = 3 , b = 2 , a = 1 )))
56- expect_error (expect_mapequal(
61+ expect_failure (expect_mapequal(list (a = 1 , b = 2 , b = 3 ), list (b = 2 , a = 1 )))
62+ expect_failure (expect_mapequal(list (a = 1 , b = 2 ), list (b = 3 , b = 2 , a = 1 )))
63+ expect_failure (expect_mapequal(
5764 list (a = 1 , b = 2 , b = 3 ),
5865 list (b = 3 , b = 2 , a = 1 )
5966 ))
@@ -72,24 +79,9 @@ test_that("fails if values don't match", {
7279 expect_failure(expect_mapequal(list (a = 1 , b = 2 ), list (a = 1 , b = 3 )))
7380})
7481
75- test_that(" error for non-vectors" , {
76- expect_error(expect_mapequal(sum , sum ), " be vectors" )
77- expect_error(expect_mapequal(NULL , NULL ), " be vectors" )
78- })
79-
80- test_that(" error if any unnamed values" , {
81- expect_error(expect_mapequal(list (1 , b = 2 ), list (1 , b = 2 )))
82- expect_error(expect_mapequal(list (1 , b = 2 ), list (b = 2 , 1 )))
83- })
84-
85- test_that(" succeeds if comparing empty named and unnamed vectors" , {
86- x1 <- list ()
87- x2 <- setNames(list (), character ())
88-
89- expect_warning(expect_success(expect_mapequal(x1 , x1 )))
90- expect_warning(expect_success(expect_mapequal(x1 , x2 )))
91- expect_warning(expect_success(expect_mapequal(x2 , x1 )))
92- expect_warning(expect_success(expect_mapequal(x2 , x2 )))
82+ test_that(" fails if unnamed values in different location if any unnamed values" , {
83+ expect_success(expect_mapequal(list (1 , b = 2 , c = 3 ), list (1 , c = 3 , b = 2 )))
84+ expect_failure(expect_mapequal(list (1 , b = 2 , c = 3 ), list (b = 2 , 1 , c = 3 )))
9385})
9486
9587# contains ----------------------------------------------------------------
0 commit comments