Skip to content

Commit 763cb94

Browse files
authored
fix tests after change in testthat::expect_equal (#371)
Looks like `testthat::expect_equal` have changed. It doesn't recognize list sorted in a different way as equal. It also notices the difference between `named list(0)` and `list(0)` Above is just the assumption, the fact is that some tests doesn't work anymore.
1 parent e88539f commit 763cb94

File tree

7 files changed

+43
-122
lines changed

7 files changed

+43
-122
lines changed

DESCRIPTION

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ Collate:
7777
'teal_data-get_code.R'
7878
'teal_data-names.R'
7979
'teal_data-show.R'
80-
'testhat-helpers.R'
8180
'topological_sort.R'
8281
'verify.R'
8382
'zzz.R'

R/testhat-helpers.R

Lines changed: 0 additions & 55 deletions
This file was deleted.

man/all.equal.join_keys.Rd

Lines changed: 0 additions & 35 deletions
This file was deleted.

tests/testthat/helper-all.equal.R

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/testthat/test-join_keys-c.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,8 @@ testthat::test_that("c.join_keys merges existing parents are overwritten", {
178178
join_key("d3", "d4", "cd", directed = FALSE),
179179
join_key("d2", "d3", "cb", directed = FALSE)
180180
)
181-
parents(expected) <- list(d2 = "d1", d3 = "d2", d4 = "d3")
182-
183-
testthat::expect_equal(c(jk1, jk2), expected)
181+
parents(expected) <- list(d2 = "d1", d4 = "d3", d3 = "d2")
182+
testthat::expect_identical(c(jk1, jk2), expected)
184183
})
185184

186185
testthat::test_that("c.join_keys throws error when merge produces acyclical graph", {

tests/testthat/test-join_keys-extract.R

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ testthat::test_that("join_keys[i] returns join_keys object for given dataset inc
6060
)
6161

6262
expected <- join_keys(
63-
join_key("d1", "d1", "a"),
6463
join_key("d2", "d2", "b"),
64+
join_key("d1", "d1", "a"),
6565
join_key("d1", "d2", "ab")
6666
)
6767

68-
testthat::expect_equal(my_keys["d2"], expected)
68+
testthat::expect_identical(my_keys["d2"], expected)
6969
})
7070

7171
testthat::test_that("join_keys[i] returns join_keys object for given dataset and doesn't include its children", {
@@ -78,12 +78,12 @@ testthat::test_that("join_keys[i] returns join_keys object for given dataset and
7878
)
7979

8080
expected <- join_keys(
81-
join_key("d1", "d1", "a"),
8281
join_key("d2", "d2", "b"),
82+
join_key("d1", "d1", "a"),
8383
join_key("d1", "d2", "ab")
8484
)
8585

86-
testthat::expect_equal(my_keys["d2"], expected)
86+
testthat::expect_identical(my_keys["d2"], expected)
8787
})
8888

8989
testthat::test_that("join_keys[i] returns empty join_keys for inexisting dataset", {
@@ -268,11 +268,15 @@ testthat::test_that("join_keys[i,j]<- removes keys with NULL", {
268268
)
269269
my_keys["d2", "d1"] <- NULL
270270

271-
testthat::expect_equal(
271+
testthat::expect_identical(
272272
my_keys,
273-
join_keys(
274-
join_key("d1", "d1", "A"),
275-
join_key("d2", "d2", "B")
273+
structure(
274+
list(
275+
d1 = list(d1 = c(A = "A")),
276+
d2 = list(d2 = c(B = "B"))
277+
),
278+
parents = setNames(list(), character(0)), # named list
279+
class = c("join_keys", "list")
276280
)
277281
)
278282
})
@@ -330,17 +334,18 @@ testthat::test_that("[[<-.join_keys adds symmetrical change without parents to t
330334
jk <- join_keys()
331335
jk[["d1"]][["d2"]] <- c("A" = "B", "C" = "C")
332336

333-
testthat::expect_equal(
337+
testthat::expect_identical(
334338
jk,
335339
structure(
336340
list(
337341
d1 = list(
338-
d2 = c(c("A" = "B", "C" = "C"))
342+
d2 = c("A" = "B", "C" = "C")
339343
),
340344
d2 = list(
341345
d1 = c("B" = "A", "C" = "C")
342346
)
343347
),
348+
parents = list(),
344349
class = c("join_keys", "list")
345350
)
346351
)

tests/testthat/test-join_keys.R

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ testthat::test_that("join_keys is a collection of join_key, ie named list with n
6565
)
6666
)
6767

68-
# Relaxed comparison (not ordered and without need of empty attributes)
69-
testthat::expect_equal(
68+
testthat::expect_identical(
7069
jk,
7170
structure(
7271
list(
73-
d2 = list(d2 = c(test = "test")),
74-
d1 = list(d1 = c(test = "test"))
72+
d1 = list(d1 = c(test = "test")),
73+
d2 = list(d2 = c(test = "test"))
7574
),
75+
parents = list(),
7676
class = c("join_keys", "list")
7777
)
7878
)
@@ -100,21 +100,33 @@ testthat::test_that("join_keys.join_keys returns itself", {
100100

101101
testthat::test_that("join_keys constructor adds symmetric keys on given (unnamed) foreign key", {
102102
my_keys <- join_keys(join_key("d1", "d2", "a"))
103-
expected_keys <- join_keys(join_key("d2", "d1", "a", directed = FALSE))
104-
parents(expected_keys) <- list(d2 = "d1")
105-
106-
testthat::expect_equal(my_keys, expected_keys)
103+
testthat::expect_identical(
104+
my_keys,
105+
structure(
106+
list(
107+
d1 = list(d2 = c(a = "a")),
108+
d2 = list(d1 = c(a = "a"))
109+
),
110+
parents = list(d2 = "d1"),
111+
class = c("join_keys", "list")
112+
)
113+
)
107114
})
108115

109116
testthat::test_that("join_keys constructor adds symmetric keys on given (named) foreign key", {
110-
expected_keys <- join_keys(join_key("d2", "d1", c(b = "a"), directed = FALSE))
111-
parents(expected_keys) <- list(d2 = "d1")
117+
my_keys <- join_keys(join_key("d2", "d1", c(b = "a"), directed = FALSE))
118+
parents(my_keys) <- list(d2 = "d1")
112119

113120
testthat::expect_equal(
114-
join_keys(
115-
join_key("d1", "d2", c(a = "b"))
116-
),
117-
expected_keys
121+
my_keys,
122+
structure(
123+
list(
124+
d2 = list(d1 = c(b = "a")),
125+
d1 = list(d2 = c(a = "b"))
126+
),
127+
parents = list(d2 = "d1"),
128+
class = c("join_keys", "list")
129+
)
118130
)
119131
})
120132

0 commit comments

Comments
 (0)