Skip to content

Commit

Permalink
Add test case showing problem
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Jul 10, 2022
1 parent a2dce9a commit f5d8c0a
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/testthat/_snaps/rd-r6.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,38 @@
Warning:
[<text>:10] @description Cannot find matching R6 method

# class with no inherited methods

Code
cat(format(rd$get_section("rawRd")))
Output
\section{Super class}{
\code{\link[R_GlobalEnv:C1]{R_GlobalEnv::C1}} -> \code{C2}
}
\section{Methods}{
\subsection{Public methods}{
\itemize{
\item \href{#method-C2-meth1}{\code{C2$meth1()}}
}
}
\if{html}{\out{
<details open><summary>Inherited methods</summary>
<ul>
</ul>
</details>
}}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-C2-meth1"></a>}}
\if{latex}{\out{\hypertarget{method-C2-meth1}{}}}
\subsection{Method \code{meth1()}}{
method1
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{C2$meth1()}\if{html}{\out{</div>}}
}
}
}

# integration test

Code
Expand Down
25 changes: 25 additions & 0 deletions tests/testthat/test-rd-r6.R
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,31 @@ test_that("warning if no method comes after the docs", {
doc <- format(rd)
})

test_that("class with no inherited methods", {
text <- "
C1 <- R6::R6Class('C1', cloneable = FALSE)
#' @title Title
#' @description Description.
#' @details Details.
C2 <- R6::R6Class('C2',
inherit = C1,
cloneable = FALSE,
public = list(
#' @description method1
meth1 = function() 1
)
)"

eval(parse(text = text, keep.source = TRUE))
block <- parse_text(text, env = environment())[[1]]
rd <- RoxyTopic$new()

topic_add_r6_methods(rd, block, environment())
expect_snapshot(cat(format(rd$get_section("rawRd"))))
})


test_that("integration test", {

wd <- getwd()
Expand Down

0 comments on commit f5d8c0a

Please sign in to comment.