Use matches! in examples.

This commit is contained in:
Stephen Chung
2020-03-14 23:40:30 +08:00
parent b9e4040635
commit 6e076c409d
6 changed files with 98 additions and 84 deletions

View File

@@ -6,12 +6,9 @@ fn test_decrement() -> Result<(), EvalAltResult> {
assert_eq!(engine.eval::<INT>("let x = 10; x -= 7; x")?, 3);
let r = engine.eval::<String>("let s = \"test\"; s -= \"ing\"; s");
match r {
Err(EvalAltResult::ErrorFunctionNotFound(err, _)) if err == "- (string, string)" => (),
_ => panic!(),
}
assert!(matches!(engine
.eval::<String>(r#"let s = "test"; s -= "ing"; s"#)
.expect_err("expects error"), EvalAltResult::ErrorFunctionNotFound(err, _) if err == "- (string, string)"));
Ok(())
}