Skip to content

Commit 33253f4

Browse files
committed
add test
1 parent b8f7924 commit 33253f4

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/testthat/test-ggproto.R

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,24 @@ test_that("construction checks input", {
1010
expect_snapshot_error(ggproto("Test", NULL, a <- function(self, a) a))
1111
expect_snapshot_error(ggproto("Test", mtcars, a = function(self, a) a))
1212
})
13+
14+
test_that("all ggproto methods start with `{` (#6459)", {
15+
16+
ggprotos <- Filter(
17+
function(x) inherits(x, "ggproto"),
18+
mget(ls("package:ggplot2"), asNamespace("ggplot2"), ifnotfound = list(NULL))
19+
)
20+
21+
method_nobrackets <- lapply(ggprotos, function(x) {
22+
Filter(
23+
function(m) inherits(x[[m]], "ggproto_method") && {
24+
b <- as.list(body(get(m, x)))
25+
length(b) == 0 || b[[1]] != quote(`{`)
26+
},
27+
ls(envir = x)
28+
)
29+
})
30+
31+
expect_length(Filter(length, method_nobrackets), 0)
32+
33+
})

0 commit comments

Comments
 (0)