The R Project SVN R

Rev

Rev 80009 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 80009 Rev 80015
Line 30... Line 30...
30
#file.show(Rdsnippet)
30
#file.show(Rdsnippet)
31
stopifnot(exprs = {
31
stopifnot(exprs = {
32
    identical(capture.output(Rd2ex(parse_Rd(Rdsnippet), fragment = TRUE))[5L],
32
    identical(capture.output(Rd2ex(parse_Rd(Rdsnippet), fragment = TRUE))[5L],
33
              r"(foo <- function(arg = "\\dots", ...) NULL # \dots)")
33
              r"(foo <- function(arg = "\\dots", ...) NULL # \dots)")
34
}) # failed in R < 4.1.0
34
}) # failed in R < 4.1.0
-
 
35
 
-
 
36
## \usage: keep quoted "\\\\dots", but _do_ translate formal \dots arg
-
 
37
Rdsnippet <- tempfile()
-
 
38
writeLines(r"(\name{foo}\title{foo}\usage{
-
 
39
foo(arg = "\\\\dots", \dots)
-
 
40
})", Rdsnippet)
-
 
41
Rdobj <- parse_Rd(Rdsnippet)
-
 
42
check_dots_usage <- function(FUN) {
-
 
43
    out <- trimws(grep("foo(", capture.output(FUN(Rdobj)),
-
 
44
                       value = TRUE, fixed = TRUE))
-
 
45
    if (!identical(out, r"(foo(arg = "\\dots", ...))"))
-
 
46
        stop("unexpected output: ", out)
-
 
47
}
-
 
48
check_dots_usage(Rd2HTML)
-
 
49
check_dots_usage(Rd2txt)
-
 
50
check_dots_usage(Rd2latex)
-
 
51
## the last two failed in R < 4.1.0; output was foo(arg = "\...", ...)