Skip to content

Commit f41593d

Browse files
committed
Clean up test implementation
1 parent da40f58 commit f41593d

File tree

2 files changed

+13
-22
lines changed

2 files changed

+13
-22
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Suggests:
3434
mgcv,
3535
multcomp,
3636
nlme,
37-
testthat,
37+
testthat (>= 0.11.0),
3838
quantreg,
3939
knitr,
4040
svglite

tests/testthat/test-boxplot.r

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,19 @@ test_that("geom_boxplot range includes all outliers", {
1313
})
1414

1515
test_that("geom_boxplot for continuous x gives warning if more than one x (#992)", {
16-
dat <- expand.grid(x=1:2, y=c(-(1:20)^3, (1:20)^3) )
17-
expect_that(ggplot_build(ggplot(dat, aes(x,y)) + geom_boxplot()),
18-
gives_warning("Continuous x aesthetic"))
16+
dat <- expand.grid(x = 1:2, y = c(-(1:5) ^ 3, (1:5) ^ 3) )
1917

20-
expect_that(ggplot_build(ggplot(dat, aes(x=as.Date(x,origin=Sys.Date()),y)) + geom_boxplot()),
21-
gives_warning("Continuous x aesthetic"))
18+
bplot <- function(aes = NULL, extra = list()) {
19+
ggplot_build(ggplot(dat, aes) + geom_boxplot(aes) + extra)
20+
}
2221

23-
expect_that(ggplot_build(ggplot(dat, aes(x,y,group=x)) + geom_boxplot()),
24-
not(gives_warning("Continuous x aesthetic")))
22+
expect_warning(bplot(aes(x, y)), "Continuous x aesthetic")
23+
expect_warning(bplot(aes(x, y), facet_wrap(~x)), "Continuous x aesthetic")
24+
expect_warning(bplot(aes(Sys.Date() + x, y)), "Continuous x aesthetic")
2525

26-
expect_that(ggplot_build(ggplot(dat, aes(x=1,y)) + geom_boxplot()),
27-
not(gives_warning("Continuous x aesthetic")))
28-
29-
expect_that(ggplot_build(ggplot(dat, aes(x=factor(x),y)) + geom_boxplot()),
30-
not(gives_warning("Continuous x aesthetic")))
31-
32-
expect_that(ggplot_build(ggplot(dat, aes(x=(x == 1),y)) + geom_boxplot()),
33-
not(gives_warning("Continuous x aesthetic")))
34-
35-
expect_that(ggplot_build(ggplot(dat, aes(x=as.character(x),y)) + geom_boxplot()),
36-
not(gives_warning("Continuous x aesthetic")))
37-
38-
expect_that(ggplot_build(ggplot(dat, aes(x,y)) + geom_boxplot() + facet_wrap(~y)),
39-
gives_warning("Continuous x aesthetic"))
26+
expect_warning(bplot(aes(x, group = x, y)), NA)
27+
expect_warning(bplot(aes(1, y)), NA)
28+
expect_warning(bplot(aes(factor(x), y)), NA)
29+
expect_warning(bplot(aes(x == 1, y)), NA)
30+
expect_warning(bplot(aes(as.character(x), y)), NA)
4031
})

0 commit comments

Comments
 (0)