1context("Stats")
2
3test_that("plot succeeds even if some computation fails", {
4  df <- data_frame(x = 1:2, y = 1)
5  p1 <- ggplot(df, aes(x, y)) + geom_point()
6
7  b1 <- ggplot_build(p1)
8  expect_equal(length(b1$data), 1)
9
10  p2 <- p1 + geom_smooth()
11  expect_warning(b2 <- ggplot_build(p2), "Computation failed")
12  expect_equal(length(b2$data), 2)
13})
14
15test_that("error message is thrown when aesthetics are missing", {
16  p <- ggplot(mtcars) + stat_sum()
17  expect_error(ggplot_build(p), "x and y$")
18})
19