Allow self-terminating custom syntax.
This commit is contained in:
@@ -136,6 +136,16 @@ fn test_custom_syntax() -> Result<(), Box<EvalAltResult>> {
|
||||
))
|
||||
);
|
||||
|
||||
// Check self-termination
|
||||
engine
|
||||
.register_custom_syntax(&["test1", "$block$"], true, |_, _| Ok(Dynamic::UNIT))?
|
||||
.register_custom_syntax(&["test2", "}"], true, |_, _| Ok(Dynamic::UNIT))?
|
||||
.register_custom_syntax(&["test3", ";"], true, |_, _| Ok(Dynamic::UNIT))?;
|
||||
|
||||
assert_eq!(engine.eval::<INT>("test1 { x = y + z; } 42")?, 42);
|
||||
assert_eq!(engine.eval::<INT>("test2 } 42")?, 42);
|
||||
assert_eq!(engine.eval::<INT>("test3; 42")?, 42);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user