Allow if expressions.

This commit is contained in:
Stephen Chung
2020-03-27 23:47:23 +08:00
parent a541a4507f
commit ef6dd9414a
6 changed files with 115 additions and 59 deletions

View File

@@ -27,3 +27,21 @@ fn test_if() -> Result<(), EvalAltResult> {
Ok(())
}
#[test]
fn test_if_expr() -> Result<(), EvalAltResult> {
let mut engine = Engine::new();
assert_eq!(
engine.eval::<INT>(
r"
let x = 42;
let y = 1 + if x > 40 { 100 } else { 0 } / x;
y
"
)?,
3
);
Ok(())
}