diff --git a/NAMESPACE b/NAMESPACE index 949b8da..e8b2fd4 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,6 @@ # Generated by roxygen2: do not edit by hand +export(.testPrepExtendedComment) export(addMapping) export(cacheCleanup) export(cacheCopy) diff --git a/R/prepExtendedComment.R b/R/prepExtendedComment.R index 7357760..a0f111c 100644 --- a/R/prepExtendedComment.R +++ b/R/prepExtendedComment.R @@ -25,7 +25,7 @@ prepExtendedComment <- function(x, type = "#undefined", warn = TRUE, n = 1) { # if readSource is called as madrat::readSource functionName will # be in this unintuitive order c("::", "madrat", "readSource") - if (length(functionCall) == 3 && functionCall[[1]] %in% c("::", ":::")) { + if (length(functionCall) == 3 && functionCall[[1]] == "::") { f <- get(functionCall[[3]], envir = loadNamespace(functionCall[[2]]), mode = "function", sys.frame(-n - 1)) } else { f <- get(functionCall, mode = "function", sys.frame(-n - 1)) @@ -60,7 +60,11 @@ prepExtendedComment <- function(x, type = "#undefined", warn = TRUE, n = 1) { return(extendedComment) } -# this exists only for testing purposes -testPrepExtendedComment <- function() { +#' .testPrepExtendedComment +#' +#' This function exists only for testing purposes. +#' +#' @export +.testPrepExtendedComment <- function() { return(prepExtendedComment(list(unit = "m", description = "example", package = "blub"))) } diff --git a/man/dot-testPrepExtendedComment.Rd b/man/dot-testPrepExtendedComment.Rd new file mode 100644 index 0000000..e42a12f --- /dev/null +++ b/man/dot-testPrepExtendedComment.Rd @@ -0,0 +1,11 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/prepExtendedComment.R +\name{.testPrepExtendedComment} +\alias{.testPrepExtendedComment} +\title{.testPrepExtendedComment} +\usage{ +.testPrepExtendedComment() +} +\description{ +This function exists only for testing purposes. +} diff --git a/tests/testthat/test-prepExtendedComment.R b/tests/testthat/test-prepExtendedComment.R index 761e260..e378dc6 100644 --- a/tests/testthat/test-prepExtendedComment.R +++ b/tests/testthat/test-prepExtendedComment.R @@ -1,6 +1,6 @@ test_that("prepExtendedComment works in functions called via package::fun", { # need to run in separate R session to make sure madrat is not attached / loaded via load_all - expect_identical(callr::r(function() madrat:::testPrepExtendedComment()[1:2]), + expect_identical(callr::r(function() madrat::.testPrepExtendedComment()[1:2]), c(" description: example", " unit: m")) })