use std::collections::HashMap;
use interpretthis::{Interpreter, InterpreterConfig, InterpreterDeps, Tools};
async fn error_text(code: &str) -> String {
let interp =
Interpreter::new(InterpreterDeps { tools: Tools::new() }, InterpreterConfig::default());
let resp = interp.execute(code, &Tools::new(), HashMap::new()).await;
let err = resp
.error
.unwrap_or_else(|| panic!("code should have raised an unsupported-feature error:\n{code}"));
format!("{err:?}")
}
async fn assert_has_anchor(code: &str) {
let text = error_text(code).await;
assert!(
text.contains("CONFORMANCE.md#"),
"unsupported-feature error is missing a CONFORMANCE anchor:\n code: {code}\n error: {text}"
);
}
#[tokio::test]
async fn relative_import_error_has_conformance_anchor() {
assert_has_anchor("from . import x\n").await;
}
#[tokio::test]
async fn star_import_error_has_conformance_anchor() {
assert_has_anchor("from math import *\n").await;
}