Implement assert and assert_equal
This commit is contained in:
parent
109091cf80
commit
f6b1cd530a
@ -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() })
|
||||
}
|
||||
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user