@@ -7,15 +7,7 @@ test_that("epix_fill_through_version mirrors input when it is sufficiently up to
7
7
ea_trivial_fill_na1 <- epix_fill_through_version(ea_orig , some_earlier_observed_version , " na" )
8
8
ea_trivial_fill_na2 <- epix_fill_through_version(ea_orig , ea_orig $ versions_end , " na" )
9
9
ea_trivial_fill_locf <- epix_fill_through_version(ea_orig , some_earlier_observed_version , " locf" )
10
- # Below, we want R6 objects to be compared based on contents rather than
11
- # addresses. We appear to get this with `expect_identical` in `testthat`
12
- # edition 3, which is based on `waldo::compare` rather than `base::identical`;
13
- # `waldo::compare` in waldo >=0.3.1 appears (as of 0.4.0) to compare R6
14
- # objects by contents rather than address (in a way that is tested but maybe
15
- # not guaranteed via user docs). Use `testthat::local_edition` to ensure we
16
- # use testthat edition 3 here (use `testthat::` to prevent ambiguity with
17
- # `readr`).
18
- testthat :: local_edition(3 )
10
+
19
11
expect_identical(ea_orig , ea_trivial_fill_na1 )
20
12
expect_identical(ea_orig , ea_trivial_fill_na2 )
21
13
expect_identical(ea_orig , ea_trivial_fill_locf )
@@ -33,9 +25,6 @@ test_that("epix_fill_through_version can extend observed versions, gives expecte
33
25
ea_fill_na <- epix_fill_through_version(ea_orig , later_unobserved_version , " na" )
34
26
ea_fill_locf <- epix_fill_through_version(ea_orig , later_unobserved_version , " locf" )
35
27
36
- # We use testthat edition 3 features here, passing `ignore_attr` to
37
- # `waldo::compare`. Ensure we are using edition 3:
38
- testthat :: local_edition(3 )
39
28
withCallingHandlers(
40
29
{
41
30
expect_identical(ea_fill_na $ versions_end , later_unobserved_version )
@@ -69,23 +58,16 @@ test_that("epix_fill_through_version does not mutate x", {
69
58
# doesn't seem sufficient to trigger)
70
59
as_epi_archive(tibble :: tibble(geo_value = 1L , time_value = 1L , version = 1L , value = 10L ))
71
60
)) {
72
- # We want to perform a strict comparison of the contents of `ea_orig` before
73
- # and `ea_orig` after. `copy` + `expect_identical` based on waldo would
74
- # sort of work, but we might want something stricter. `as.list` +
75
- # `identical` plus a check of the DT seems to do the trick.
76
- ea_orig_before_as_list <- as.list(ea_orig )
61
+ ea_orig_before <- clone(ea_orig )
77
62
ea_orig_dt_before_copy <- data.table :: copy(ea_orig $ DT )
78
63
some_unobserved_version <- 8L
79
- #
64
+
80
65
ea_fill_na <- epix_fill_through_version(ea_orig , some_unobserved_version , " na" )
81
- ea_orig_after_as_list <- as.list(ea_orig )
82
- # use identical, not expect_identical, for the R6-as-list test; latter isn't as strict
83
- expect_true(identical(ea_orig_before_as_list , ea_orig_after_as_list ))
66
+ expect_identical(ea_orig_before , ea_orig )
84
67
expect_identical(ea_orig_dt_before_copy , ea_orig $ DT )
85
- #
68
+
86
69
ea_fill_locf <- epix_fill_through_version(ea_orig , some_unobserved_version , " locf" )
87
- ea_orig_after_as_list <- as.list(ea_orig )
88
- expect_true(identical(ea_orig_before_as_list , ea_orig_after_as_list ))
70
+ expect_identical(ea_orig_before , ea_orig )
89
71
expect_identical(ea_orig_dt_before_copy , ea_orig $ DT )
90
72
}
91
73
})
@@ -101,8 +83,7 @@ test_that("epix_fill_through_version return with expected visibility", {
101
83
102
84
test_that(" epix_fill_through_version returns same key & doesn't mutate old DT or its key" , {
103
85
ea <- as_epi_archive(tibble :: tibble(geo_value = 1L , time_value = 1L , version = 1L , value = 10L ))
104
- old_dt <- ea $ DT
105
- old_dt_copy <- data.table :: copy(old_dt )
86
+ old_dt_copy <- data.table :: copy(ea $ DT )
106
87
old_key <- data.table :: key(ea $ DT )
107
88
expect_identical(data.table :: key(epix_fill_through_version(ea , 5L , " na" )$ DT ), old_key )
108
89
expect_identical(data.table :: key(epix_fill_through_version(ea , 5L , " locf" )$ DT ), old_key )
0 commit comments