File: test-qplot.R

package info (click to toggle)
r-cran-ggplot2 4.0.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 11,084 kB
  • sloc: sh: 15; makefile: 5
file content (62 lines) | stat: -rw-r--r-- 1,425 bytes parent folder | download
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
58
59
60
61
62
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(
    p <- qplot(x, y, data = df)
  )
  expect_s7_class(p, class_ggplot)
  lifecycle::expect_deprecated(
    p <- qplot(x, y, data = df, colour = a)
  )
  expect_s7_class(p, class_ggplot)
  lifecycle::expect_deprecated(
    p <- qplot(x, y, data = df, colour = b)
  )
  expect_s7_class(p, class_ggplot)

  bin <- 1
  lifecycle::expect_deprecated(
    p <- qplot(x, data = df, binwidth = bin)
  )
  expect_s7_class(p, class_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_s7_class(p, class_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(get_layer_data(p)$colour, I("red"))
})

test_that("qplot() evaluates layers in package environment", {
  geom_line <- function(...) {
    stop("!!!")
  }

  lifecycle::expect_deprecated(
    expect_no_error(p <- qplot(1, 1, geom = "line"))
  )
})

test_that("qplot() only work with character geom", {
  lifecycle::expect_deprecated(
    expect_snapshot_error(qplot(geom = GeomLinerange))
  )
})