Skip to content

Commit d184eb2

Browse files
authored
Add retransform test (#4846)
1 parent b9e1694 commit d184eb2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/testthat/test-layer.r

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,17 @@ test_that("inherit.aes works", {
8282
expect_identical(p1$layers[[1]]$computed_mapping, p2$layers[[1]]$computed_mapping)
8383
})
8484

85+
test_that("retransform works on computed aesthetics in `map_statistic`", {
86+
df <- data.frame(x = rep(c(1,2), c(9, 25)))
87+
p <- ggplot(df, aes(x)) + geom_bar() + scale_y_sqrt()
88+
expect_equal(layer_data(p)$y, c(3, 5))
89+
90+
# To double check: should be original values when `retransform = FALSE`
91+
parent <- p$layers[[1]]$stat
92+
p$layers[[1]]$stat <- ggproto(NULL, parent, retransform = FALSE)
93+
expect_equal(layer_data(p)$y, c(9, 25))
94+
})
95+
8596
# Data extraction ---------------------------------------------------------
8697

8798
test_that("layer_data returns a data.frame", {

0 commit comments

Comments
 (0)