Improve type display in error messages.

This commit is contained in:
Stephen Chung
2023-05-13 10:47:39 +08:00
parent b1fbfcbc07
commit db9980ce3a
6 changed files with 47 additions and 11 deletions

View File

@@ -10,6 +10,21 @@ fn test_mismatched_op() {
));
}
#[test]
fn test_mismatched_op_name() {
let engine = Engine::new();
assert!(matches!(
*engine.eval::<String>("true").expect_err("expects error"),
EvalAltResult::ErrorMismatchOutputType(need, actual, ..) if need == "string" && actual == "bool"
));
assert!(matches!(
*engine.eval::<&str>("true").expect_err("expects error"),
EvalAltResult::ErrorMismatchOutputType(need, actual, ..) if need == "&str" && actual == "bool"
));
}
#[test]
#[cfg(not(feature = "no_object"))]
fn test_mismatched_op_custom_type() -> Result<(), Box<EvalAltResult>> {