Implement assert and assert_equal

This commit is contained in:
Jeff 2023-08-22 12:43:13 -04:00
parent 109091cf80
commit f6b1cd530a
2 changed files with 7 additions and 5 deletions

View File

@ -9,7 +9,10 @@ impl Macro for Assert {
identifier: "assert",
description: "Panic if a boolean is false.",
group: "test",
inputs: vec![],
inputs: vec![
ValueType::Boolean,
ValueType::Function
],
}
}
@ -33,7 +36,7 @@ impl Macro for AssertEqual {
identifier: "assert_equal",
description: "Panic if two values do not match.",
group: "test",
inputs: vec![],
inputs: vec![ValueType::List(vec![ValueType::Any, ValueType::Any])],
}
}
@ -42,7 +45,6 @@ impl Macro for AssertEqual {
if arguments[0] == arguments[1] {
Ok(Value::Empty)
} else {
Err(Error::AssertEqualFailed { expected: arguments[0].clone(), actual: arguments[1].clone() })
}

View File

@ -8,8 +8,8 @@ fn assert() {
#[test]
fn assert_equal() {
eval("assert_eq(true, true)").unwrap();
eval("assert_eq(true, false)").unwrap_err();
eval("assert_equal(true, true)").unwrap();
eval("assert_equal(true, false)").unwrap_err();
}
#[test]