testthat (version 1.0.2)

evaluate_promise: Evaluate a promise, capturing all types of output.

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 expect_output, expect_message, expect_warning, and expect_silent.

Usage

evaluate_promise(code, print = FALSE)

capture_messages(code)

capture_warnings(code)

capture_output(code, print = FALSE)

Arguments

code
Code to evaluate. This should be an unevaluated expression.
print
If TRUE and the result of evaluating code is visible this will print the result, ensuring that the output of printing the object is included in the overall output

Value

  • A list containing
  • resultThe result of the function
  • outputA string containing all the output from the function
  • warningsA character vector containing the text from each warning
  • messagesA character vector containing the text from each message

Examples

Run this code
evaluate_promise({
  print("1")
  message("2")
  warning("3")
  4
})

Run the code above in your browser using DataLab