1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/checkEnvironment.R
\name{checkEnvironment}
\alias{checkEnvironment}
\alias{check_environment}
\alias{assertEnvironment}
\alias{assert_environment}
\alias{testEnvironment}
\alias{test_environment}
\alias{expect_environment}
\title{Check if an argument is an environment}
\usage{
checkEnvironment(x, contains = character(0L), null.ok = FALSE)
check_environment(x, contains = character(0L), null.ok = FALSE)
assertEnvironment(
x,
contains = character(0L),
null.ok = FALSE,
.var.name = vname(x),
add = NULL
)
assert_environment(
x,
contains = character(0L),
null.ok = FALSE,
.var.name = vname(x),
add = NULL
)
testEnvironment(x, contains = character(0L), null.ok = FALSE)
test_environment(x, contains = character(0L), null.ok = FALSE)
expect_environment(
x,
contains = character(0L),
null.ok = FALSE,
info = NULL,
label = vname(x)
)
}
\arguments{
\item{x}{[any]\cr
Object to check.}
\item{contains}{[\code{character}]\cr
Vector of object names expected in the environment.
Defaults to \code{character(0)}.}
\item{null.ok}{[\code{logical(1)}]\cr
If set to \code{TRUE}, \code{x} may also be \code{NULL}.
In this case only a type check of \code{x} is performed, all additional checks are disabled.}
\item{.var.name}{[\code{character(1)}]\cr
Name of the checked object to print in assertions. Defaults to
the heuristic implemented in \code{\link{vname}}.}
\item{add}{[\code{AssertCollection}]\cr
Collection to store assertion messages. See \code{\link{AssertCollection}}.}
\item{info}{[\code{character(1)}]\cr
Extra information to be included in the message for the testthat reporter.
See \code{\link[testthat]{expect_that}}.}
\item{label}{[\code{character(1)}]\cr
Name of the checked object to print in messages. Defaults to
the heuristic implemented in \code{\link{vname}}.}
}
\value{
Depending on the function prefix:
If the check is successful, the functions
\code{assertEnvironment}/\code{assert_environment} return
\code{x} invisibly, whereas
\code{checkEnvironment}/\code{check_environment} and
\code{testEnvironment}/\code{test_environment} return
\code{TRUE}.
If the check is not successful,
\code{assertEnvironment}/\code{assert_environment}
throws an error message,
\code{testEnvironment}/\code{test_environment}
returns \code{FALSE},
and \code{checkEnvironment}/\code{check_environment}
return a string with the error message.
The function \code{expect_environment} always returns an
\code{\link[testthat]{expectation}}.
}
\description{
Check if an argument is an environment
}
\examples{
ee = as.environment(list(a = 1))
testEnvironment(ee)
testEnvironment(ee, contains = "a")
}
\seealso{
Other basetypes:
\code{\link{checkArray}()},
\code{\link{checkAtomic}()},
\code{\link{checkAtomicVector}()},
\code{\link{checkCharacter}()},
\code{\link{checkComplex}()},
\code{\link{checkDataFrame}()},
\code{\link{checkDate}()},
\code{\link{checkDouble}()},
\code{\link{checkFactor}()},
\code{\link{checkFormula}()},
\code{\link{checkFunction}()},
\code{\link{checkInteger}()},
\code{\link{checkIntegerish}()},
\code{\link{checkList}()},
\code{\link{checkLogical}()},
\code{\link{checkMatrix}()},
\code{\link{checkNull}()},
\code{\link{checkNumeric}()},
\code{\link{checkPOSIXct}()},
\code{\link{checkRaw}()},
\code{\link{checkVector}()}
}
\concept{basetypes}
|