tests/testthat/test-roxygen2-expect.R

test_that("@test tags produce \\testonly blocks", {
  roxy_text <- "
    #' Title
    #'
    #' Description.
    #'
    #' @param x,y parameters
    #'
    #' @examples
    #' 1 + 2
    #' @test 3
    #'
    #' @export
    f <- function(x, y) x + y
  "

  block <- roxygen2::parse_text(roxy_text)[[1]]
  expect_tag <- block$tags[[5]]

  expect_equal(expect_tag$tag, "test")
  expect_s3_class(expect_tag, "roxy_tag_examples")

  expect_true(any(grepl("\\\\testonly\\{", expect_tag$val)))
  expect_true(any(grepl("testex::testex\\(", expect_tag$val)))
  expect_true(any(grepl("identical\\(\\., 3\\)", expect_tag$val)))
})

Try the testex package in your browser

Any scripts or data that you put into this service are public.

testex documentation built on June 22, 2024, 11:14 a.m.