Add is_def_XXX tests.

This commit is contained in:
Stephen Chung
2020-10-03 21:59:19 +08:00
parent 1e13e6be5f
commit 9664ae42a7
2 changed files with 52 additions and 0 deletions

View File

@@ -21,3 +21,29 @@ fn test_constant() -> Result<(), Box<EvalAltResult>> {
Ok(())
}
#[test]
fn test_var_is_def() -> Result<(), Box<EvalAltResult>> {
let engine = Engine::new();
assert!(engine.eval::<bool>(
r#"
let x = 42;
is_def_var("x")
"#
)?);
assert!(!engine.eval::<bool>(
r#"
let x = 42;
is_def_var("y")
"#
)?);
assert!(engine.eval::<bool>(
r#"
const x = 42;
is_def_var("x")
"#
)?);
Ok(())
}