// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. use std::rc::Rc; use wander::{ interpreter::eval, interpreter::Expression, preludes::common, HostFunction, HostFunctionBinding, HostValue, WanderError, WanderValue, }; struct SayHello {} impl HostFunction for SayHello { fn run( &self, _arguments: &[WanderValue], _bindings: &wander::environment::Environment, ) -> Result, WanderError> { Ok(WanderValue::HostValue(HostValue { value: "hello!".to_owned(), })) } fn binding(&self) -> HostFunctionBinding { HostFunctionBinding { name: "hello".to_owned(), parameters: vec![], result: None, doc_string: "Say hello!".to_owned(), } } } //#[test] fn eval_host_value() { let mut bindings = common::(); bindings.bind_host_function(Rc::new(SayHello {})); let input = Expression::Nothing; let res = eval(&input, &mut bindings); let expected = Ok(WanderValue::HostValue(HostValue { value: "hello!".to_owned(), })); assert_eq!(res, expected); }