1- library(bayesplot )
21library(ggplot2 )
3- context(" Convenience functions (for ggplot objects)" )
4-
52
63# abline_01, vline_ and hline_ ------------------------------------------
74test_that(" abline_01 returns the correct object" , {
85 a <- abline_01(color = " green" , linetype = 2 )
96 b <- geom_abline(intercept = 0 , slope = 1 , color = " green" , linetype = 2 , na.rm = TRUE )
107 a $ constructor <- b $ constructor <- NULL
11- expect_equal(a , b , check.environment = FALSE )
8+ expect_equal(a , b , ignore_function_env = TRUE )
129})
1310test_that(" vline_* and hline_* return correct objects" , {
1411 a <- vline_0(color = " red" )
1512 b <- geom_vline(xintercept = 0 , color = " red" , na.rm = TRUE )
1613 a $ constructor <- b $ constructor <- NULL
17- expect_equal(a , b , check.environment = FALSE )
14+ expect_equal(a , b , ignore_function_env = TRUE )
1815
1916 a <- hline_0(linewidth = 2 , linetype = 3 )
2017 b <- geom_hline(yintercept = 0 , linewidth = 2 , linetype = 3 , na.rm = TRUE )
2118 a $ constructor <- b $ constructor <- NULL
22- expect_equal(a , b , check.environment = FALSE )
19+ expect_equal(a , b , ignore_function_env = TRUE )
2320
2421 a <- vline_at(c(3 ,4 ), na.rm = FALSE )
2522 b <- geom_vline(xintercept = c(3 ,4 ))
2623 a $ constructor <- b $ constructor <- NULL
27- expect_equal(a , b , check.environment = FALSE )
24+ expect_equal(a , b , ignore_function_env = TRUE )
2825
2926 a <- hline_at(c(3 ,4 ), na.rm = FALSE )
3027 b <- geom_hline(yintercept = c(3 ,4 ))
3128 a $ constructor <- b $ constructor <- NULL
32- expect_equal(a , b , check.environment = FALSE )
29+ expect_equal(a , b , ignore_function_env = TRUE )
3330})
3431test_that(" vline_at with 'fun' works" , {
3532 x <- example_mcmc_draws(chains = 1 )
3633 a <- vline_at(x , colMeans )
3734 b <- geom_vline(xintercept = colMeans(x ), na.rm = TRUE )
3835 a $ constructor <- b $ constructor <- NULL
39- expect_equal(a , b , check.environment = FALSE )
36+ expect_equal(a , b , ignore_function_env = TRUE )
4037})
4138test_that(" calc_v (internal function) works" , {
4239 a <- 1 : 4
@@ -99,20 +96,21 @@ test_that("facet_bg returns correct theme object", {
9996test_that(" legend_none returns correct theme object" , {
10097 none <- legend_none()
10198 expect_s3_class(none , " theme" )
102- expect_equivalent (none , list ( legend.position = " none" ) )
99+ expect_equal (none $ legend.position , " none" , ignore_attr = TRUE )
103100 expect_false(attr(none , " complete" ))
104101})
105102test_that(" legend_move returns correct theme object" , {
106103 left <- legend_move(" left" )
107104 expect_s3_class(left , " theme" )
108- expect_equivalent (left , list ( legend.position = " left" ) )
105+ expect_equal (left $ legend.position , " left" , ignore_attr = TRUE )
109106 expect_false(attr(left , " complete" ))
110107
111108 pos <- legend_move(c(0.25 , 0.5 ))
112109 expect_s3_class(pos , " theme" )
113- expect_equivalent (
110+ expect_equal (
114111 pos $ legend.position.inside %|| % pos $ legend.position ,
115- c(0.25 , 0.5 )
112+ c(0.25 , 0.5 ),
113+ ignore_attr = TRUE
116114 )
117115 expect_false(attr(pos , " complete" ))
118116})
@@ -133,9 +131,10 @@ test_that("xaxis_text returns correct theme object", {
133131})
134132test_that(" yaxis_text returns correct theme object" , {
135133 expect_identical(yaxis_text(FALSE ), theme(axis.text.y = element_blank()))
136- expect_equivalent (
134+ expect_equal (
137135 yaxis_text(face = " bold" , angle = 30 ),
138- 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
139138 )
140139})
141140test_that(" facet_text returns correct theme object" , {
@@ -185,7 +184,7 @@ test_that("overlay_function returns the correct object", {
185184 a <- overlay_function(fun = " dnorm" )
186185 b <- stat_function(fun = " dnorm" , inherit.aes = FALSE )
187186 a $ constructor <- b $ constructor <- NULL
188- expect_equal(a , b , check.environment = FALSE )
187+ expect_equal(a , b , ignore_function_env = TRUE )
189188})
190189
191190
0 commit comments