Skip to content

Commit 12efa67

Browse files
committed
Straggler replacements and fixed some tests for compat with ggplot 4
1 parent a5e9767 commit 12efa67

5 files changed

Lines changed: 23 additions & 13 deletions

File tree

tests/testthat/test-aesthetics.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ test_that("getting and setting the color scheme works", {
1414
expect_named(color_scheme_get(), scheme_level_names())
1515
for (clr in names(master_color_list)) {
1616
color_scheme_set(clr)
17-
expect_equal(color_scheme_get(), prepare_colors_for_test(clr, ignore_attr = TRUE),
18-
info = clr)
17+
expect_equal(color_scheme_get(), prepare_colors_for_test(clr),
18+
info = clr, ignore_attr = TRUE)
1919
expect_named(color_scheme_get(), scheme_level_names())
2020
}
2121

tests/testthat/test-convenience-functions.R

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,21 @@ test_that("facet_bg returns correct theme object", {
9696
test_that("legend_none returns correct theme object", {
9797
none <- legend_none()
9898
expect_s3_class(none, "theme")
99-
expect_equal(none, list(legend.position = "none"), ignore_attr = TRUE)
99+
expect_equal(none$legend.position, "none", ignore_attr = TRUE)
100100
expect_false(attr(none, "complete"))
101101
})
102102
test_that("legend_move returns correct theme object", {
103103
left <- legend_move("left")
104104
expect_s3_class(left, "theme")
105-
expect_equal(left, list(legend.position = "left"), ignore_attr = TRUE)
105+
expect_equal(left$legend.position, "left", ignore_attr = TRUE)
106106
expect_false(attr(left, "complete"))
107107

108108
pos <- legend_move(c(0.25, 0.5))
109109
expect_s3_class(pos, "theme")
110-
expect_equivalent(
110+
expect_equal(
111111
pos$legend.position.inside %||% pos$legend.position,
112-
c(0.25, 0.5)
112+
c(0.25, 0.5),
113+
ignore_attr = TRUE
113114
)
114115
expect_false(attr(pos, "complete"))
115116
})
@@ -130,9 +131,10 @@ test_that("xaxis_text returns correct theme object", {
130131
})
131132
test_that("yaxis_text returns correct theme object", {
132133
expect_identical(yaxis_text(FALSE), theme(axis.text.y = element_blank()))
133-
expect_equivalent(
134+
expect_equal(
134135
yaxis_text(face = "bold", angle = 30),
135-
theme(axis.text.y = element_text(face = "bold", angle = 30))
136+
theme(axis.text.y = element_text(face = "bold", angle = 30)),
137+
ignore_attr = TRUE
136138
)
137139
})
138140
test_that("facet_text returns correct theme object", {

tests/testthat/test-helpers-mcmc.R

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,11 @@ test_that("diagnostic_factor.rhat works", {
298298
high = 1.2, high = 1.7))
299299

300300
r <- diagnostic_factor(unname(rhats))
301-
expect_equal(r, as.factor(names(rhats)), ignore_attr = TRUE)
301+
expect_equal(
302+
r,
303+
factor(names(rhats), levels = c("low", "ok", "high")),
304+
ignore_attr = TRUE
305+
)
302306
expect_identical(levels(r), c("low", "ok", "high"))
303307
})
304308
test_that("diagnostic_factor.neff_ratio works", {
@@ -307,7 +311,11 @@ test_that("diagnostic_factor.neff_ratio works", {
307311
high = 0.51, high = 0.99, high = 1))
308312

309313
r <- diagnostic_factor(unname(ratios))
310-
expect_equal(r, as.factor(names(ratios)), ignore_attr = TRUE)
314+
expect_equal(
315+
r,
316+
factor(names(ratios), levels = c("low", "ok", "high")),
317+
ignore_attr = TRUE
318+
)
311319
expect_identical(levels(r), c("low", "ok", "high"))
312320
})
313321

tests/testthat/test-mcmc-intervals.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ test_that("mcmc_areas_data computes density", {
130130
densities <- lapply(raw_values, do_dens, 1, 1024)
131131

132132
for (name in names(by_parameter)) {
133-
expect_equivalent(by_parameter[[name]][["density"]],
134-
densities[[name]][["y"]])
133+
expect_equal(by_parameter[[name]][["density"]],
134+
densities[[name]][["y"]], ignore_attr = TRUE)
135135
}
136136
})
137137

tests/testthat/test-ppc-distributions.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ test_that("ppc_dens,pp_hist,ppc_freqpoly,ppc_boxplot return ggplot objects", {
3636
expect_gg(p <- ppc_hist(y, yrep[1:8, ], binwidth = 3))
3737
if (utils::packageVersion("ggplot2") >= "3.0.0") {
3838
facet_var <- vars(rep_label)
39-
expect_equal(p$facet$params$facets[[1]], facet_var[[1]])
39+
expect_equal(p$facet$params$facets[[1]], facet_var[[1]], ignore_function_env = TRUE, ignore_formula_env = TRUE)
4040
}
4141

4242
# ppd versions

0 commit comments

Comments
 (0)