git.delta.rocks / jrsonnet / refs/commits / e9f8bf6a88b9

difftreelog

source

tests/tests/std_native.rs548 Bsourcehistory
1use jrsonnet_evaluator::{function::builtin, trace::PathResolver, State};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::INST);14	state.context_initializer(std);15	let state = state.build();1617	assert!(state18		.evaluate_snippet("test", "std.native('example')(1, 3) == 4")19		.unwrap()20		.as_bool()21		.expect("boolean output"));22}