1context("qplot")
2
3test_that("qplot works with variables in data frame and parent env", {
4  df <- data_frame(x = 1:10, a = 1:10)
5  y <- 1:10
6  b <- 1:10
7
8  expect_is(qplot(x, y, data = df), "ggplot")
9  expect_is(qplot(x, y, data = df, colour = a), "ggplot")
10  expect_is(qplot(x, y, data = df, colour = b), "ggplot")
11
12  bin <- 1
13  expect_is(qplot(x, data = df, binwidth = bin), "ggplot")
14})
15
16test_that("qplot works in non-standard environments", {
17  p <- local({
18    `-1-` <- 10
19    x <- 1:10
20    qplot(x, breaks = 0:`-1-`)
21  })
22  expect_is(p, "ggplot")
23})
24
25test_that("qplot() evaluates constants in the right place", {
26  p <- local({
27    foo <- "d"
28    qplot(1, 1, colour = I(paste0("re", foo)))
29  })
30  expect_identical(layer_data(p)$colour, I("red"))
31})
32
33test_that("qplot() evaluates layers in package environment", {
34  geom_line <- function(...) {
35    stop("!!!")
36  }
37
38  expect_error(p <- qplot(1, 1, geom = "line"), NA)
39})
40