Add null coalescing operator.

This commit is contained in:
Stephen Chung
2022-06-10 11:22:33 +08:00
parent 0f1e51b1c9
commit 8999872d62
7 changed files with 87 additions and 15 deletions

View File

@@ -135,3 +135,13 @@ fn test_binary_ops() -> Result<(), Box<EvalAltResult>> {
Ok(())
}
#[test]
fn test_binary_ops_null_coalesce() -> Result<(), Box<EvalAltResult>> {
let engine = Engine::new();
assert_eq!(engine.eval::<INT>("let x = 42; x ?? 123")?, 42);
assert_eq!(engine.eval::<INT>("let x = (); x ?? 123")?, 123);
Ok(())
}