diff --git a/src/built_in_functions/assert.rs b/src/built_in_functions/assert.rs new file mode 100644 index 0000000..77ee769 --- /dev/null +++ b/src/built_in_functions/assert.rs @@ -0,0 +1,19 @@ +use crate::{BuiltInFunction, Error, Result, Value}; + +pub struct Assert; + +impl BuiltInFunction for Assert { + fn name(&self) -> &'static str { + "assert" + } + + fn run(&self, arguments: &[Value]) -> Result { + for argument in arguments { + if !argument.as_boolean()? { + return Err(Error::AssertFailed); + } + } + + Ok(Value::Empty) + } +}