File tree 2 files changed +24
-0
lines changed 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 38
38
# ' # This can be useful to return from a function.
39
39
# ' base + list(subset(mpg, fl == "p"), geom_smooth())
40
40
" +.gg" <- function (e1 , e2 ) {
41
+ if (missing(e2 )) {
42
+ stop(" Cannot use `+.gg()` with a single argument. " ,
43
+ " Did you accidentally put + on a new line?" ,
44
+ call. = FALSE )
45
+ }
46
+
41
47
# Get the name of what was passed in as e2, and pass along so that it
42
48
# can be displayed in error messages
43
49
e2name <- deparse(substitute(e2 ))
Original file line number Diff line number Diff line change
1
+ context(" error" )
2
+
3
+ test_that(" various misuses of +.gg (#2638)" , {
4
+ expect_error(
5
+ {
6
+ ggplot(mtcars , aes(hwy , displ ))
7
+ + geom_point()
8
+ },
9
+ " Cannot use `+.gg()` with a single argument. Did you accidentally put + on a new line?" ,
10
+ fixed = TRUE
11
+ )
12
+
13
+ expect_error(
14
+ geom_point() + geom_point(),
15
+ " Cannot add ggproto objects together. Did you forget to add this object to a ggplot object?" ,
16
+ fixed = TRUE
17
+ )
18
+ })
You can’t perform that action at this time.
0 commit comments