git.delta.rocks / jrsonnet / refs/commits / 83c939e4fa0b

difftreelog

source

tests/tests/as_native.rs440 Bsourcehistory
1use jrsonnet_evaluator::{error::Result, State};2use jrsonnet_stdlib::StateExt;34mod common;56#[test]7fn as_native() -> Result<()> {8	let s = State::default();9	s.with_stdlib();1011	let val = s.evaluate_snippet("snip".to_owned(), r#"function(a, b) a + b"#)?;12	let func = val.as_func().expect("this is function");1314	let native = func.into_native::<((u32, u32), u32)>();1516	ensure_eq!(native(1, 2)?, 3);17	ensure_eq!(native(3, 4)?, 7);1819	Ok(())20}