forked from r-lib/testthat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcapture_condition.Rd
57 lines (48 loc) · 1.41 KB
/
capture_condition.Rd
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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/capture-condition.R
\name{capture_condition}
\alias{capture_condition}
\alias{capture_error}
\alias{capture_expectation}
\alias{capture_message}
\alias{capture_warning}
\alias{capture_messages}
\alias{capture_warnings}
\title{Capture conditions, including messeages, warnings, expectations, and errors.}
\usage{
capture_condition(code)
capture_error(code)
capture_expectation(code)
capture_message(code)
capture_warning(code)
capture_messages(code)
capture_warnings(code)
}
\arguments{
\item{code}{Code to evaluate}
}
\value{
Singular functions (\code{capture_condition}, \code{capture_expectation} etc)
return a condition object. \code{capture_messages()} and \code{capture_warnings}
return a character vector of message text.
}
\description{
These functions allow you to capture the side-effects of a function call
including printed output, messages and warnings. They are used to evaluate
code for \code{\link[=expect_output]{expect_output()}}, \code{\link[=expect_message]{expect_message()}},
\code{\link[=expect_warning]{expect_warning()}}, and \code{\link[=expect_silent]{expect_silent()}}.
}
\examples{
f <- function() {
message("First")
warning("Second")
message("Third")
}
capture_message(f())
capture_messages(f())
capture_warning(f())
capture_warnings(f())
# Condition will capture anything
capture_condition(f())
}
\keyword{internal}