Skip to content

Commit de21133

Browse files
committed
add test
1 parent 6b113c9 commit de21133

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/testthat/test-stats.R

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,22 @@ test_that("erroneously dropped aesthetics are found and issue a warning", {
6969
c(TRUE, FALSE, FALSE)
7070
)
7171
})
72+
73+
test_that("stats can modify persistent attributes", {
74+
75+
StatTest <- ggproto(
76+
"StatTest", Stat,
77+
compute_layer = function(self, data, params, layout) {
78+
attr(data, "foo") <- "bar"
79+
data
80+
}
81+
)
82+
83+
p <- ggplot(mtcars, aes(disp, mpg)) +
84+
geom_point(stat = StatTest) +
85+
facet_wrap(~cyl)
86+
87+
ld <- layer_data(p)
88+
expect_equal(attr(ld, "foo"), "bar")
89+
90+
})

0 commit comments

Comments
 (0)