EVOLUTION-MANAGER
Edit File: quasi_label.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Quasi-labelling</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for quasi_label {testthat}"><tr><td>quasi_label {testthat}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Quasi-labelling</h2> <h3>Description</h3> <p>The first argument to every <code>expect_</code> function can use unquoting to construct better labels. This makes it easy to create informative labels when expectations are used inside a function or a for loop. <code>quasi_label()</code> wraps up the details, returning the expression and label. </p> <h3>Usage</h3> <pre> quasi_label(quo, label = NULL, arg = "quo") </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>quo</code></td> <td> <p>A quosure created by <code>rlang::enquo()</code>.</p> </td></tr> <tr valign="top"><td><code>label</code></td> <td> <p>An optional label to override the default. This is only provided for internal usage. Modern expectations should not include a <code>label</code> parameter.</p> </td></tr> <tr valign="top"><td><code>arg</code></td> <td> <p>Argument name shown in error message if <code>quo</code> is missing.</p> </td></tr> </table> <h3>Value</h3> <p>A list containing two elements: </p> <table summary="R valueblock"> <tr valign="top"><td><code>val</code></td> <td> <p>The evaluate value of <code>quo</code></p> </td></tr> <tr valign="top"><td><code>lab</code></td> <td> <p>The quasiquoted label generated from <code>quo</code></p> </td></tr> </table> <h3>Limitations</h3> <p>Because all <code>expect_</code> function use unquoting to generate more informative labels, you can not use unquoting for other purposes. Instead, you'll need to perform all other unquoting outside of the expectation and only test the results. </p> <h3>Examples</h3> <pre> f <- function(i) if (i > 3) i * 9 else i * 10 i <- 10 # This sort of expression commonly occurs inside a for loop or function # And the failure isn't helpful because you can't see the value of i # that caused the problem: show_failure(expect_equal(f(i), i * 10)) # To overcome this issue, testthat allows you to unquote expressions using # !!. This causes the failure message to show the value rather than the # variable name show_failure(expect_equal(f(!!i), !!(i * 10))) </pre> <hr /><div style="text-align: center;">[Package <em>testthat</em> version 3.1.5 <a href="00Index.html">Index</a>]</div> </body></html>