1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
test_that("qplot works with variables in data frame and parent env", {
df <- data_frame(x = 1:10, a = 1:10)
y <- 1:10
b <- 1:10
lifecycle::expect_deprecated(
expect_s3_class(qplot(x, y, data = df), "ggplot")
)
lifecycle::expect_deprecated(
expect_s3_class(qplot(x, y, data = df, colour = a), "ggplot")
)
lifecycle::expect_deprecated(
expect_s3_class(qplot(x, y, data = df, colour = b), "ggplot")
)
bin <- 1
lifecycle::expect_deprecated(
expect_s3_class(qplot(x, data = df, binwidth = bin), "ggplot")
)
})
test_that("qplot works in non-standard environments", {
lifecycle::expect_deprecated(
p <- local({
`-1-` <- 10
x <- 1:10
qplot(x, breaks = 0:`-1-`)
})
)
expect_s3_class(p, "ggplot")
})
test_that("qplot() evaluates constants in the right place", {
lifecycle::expect_deprecated(
p <- local({
foo <- "d"
qplot(1, 1, colour = I(paste0("re", foo)))
})
)
expect_identical(layer_data(p)$colour, I("red"))
})
test_that("qplot() evaluates layers in package environment", {
geom_line <- function(...) {
stop("!!!")
}
lifecycle::expect_deprecated(
expect_error(p <- qplot(1, 1, geom = "line"), NA)
)
})
test_that("qplot() only work with character geom", {
lifecycle::expect_deprecated(
expect_snapshot_error(qplot(geom = GeomLinerange))
)
})
|