Function rune::macros::test

source ·
pub fn test<F, O>(f: F) -> Result<O>
where F: FnOnce(&mut MacroContext<'_, '_, '_>) -> Result<O>,
Expand description

Construct an empty macro context which can be used for testing.

§Examples

use rune::ast;
use rune::macros;

macros::test(|cx| {
    let lit = cx.lit("hello world")?;
    assert!(matches!(lit, ast::Lit::Str(..)));
    Ok(())
})?;