git.delta.rocks / jrsonnet / refs/commits / 6fbe7c61b4ca

difftreelog

source

tests/tests/std_native.rs554 Bsourcehistory
1use jrsonnet_evaluator::{State, function::builtin, trace::PathResolver};2use jrsonnet_stdlib::ContextInitializer;34#[builtin]5fn example_native(a: u32, b: u32) -> u32 {6	a + b7}89#[test]10fn std_native() {11	let mut state = State::builder();12	let std = ContextInitializer::new(PathResolver::Absolute);13	std.add_native("example", example_native {});14	state.context_initializer(std);15	let state = state.build();1617	assert!(18		state19			.evaluate_snippet("test", "std.native('example')(1, 3) == 4")20			.unwrap()21			.as_bool()22			.expect("boolean output")23	);24}