rune::macros

Function 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(())
})?;