use std::collections::HashMap;
use interpretthis::{Interpreter, InterpreterConfig, InterpreterDeps, Tools};
pub async fn assert_output(code: &str, expected: &str) {
let resp = run(code).await;
assert!(resp.error.is_none(), "code `{code}` errored: {:?}", resp.error);
assert_eq!(resp.stdout.trim_end(), expected, "unexpected output for code `{code}`");
}
pub async fn assert_error(code: &str) {
let resp = run(code).await;
assert!(
resp.error.is_some(),
"code `{code}` should have raised, but printed: {:?}",
resp.stdout
);
}
async fn run(code: &str) -> interpretthis::InterpreterResponse {
let interp =
Interpreter::new(InterpreterDeps { tools: Tools::new() }, InterpreterConfig::default());
interp.execute(code, &Tools::new(), HashMap::new()).await
}