Implement assert and assert_equal
This commit is contained in:
parent
109091cf80
commit
f6b1cd530a
@ -9,7 +9,10 @@ impl Macro for Assert {
|
|||||||
identifier: "assert",
|
identifier: "assert",
|
||||||
description: "Panic if a boolean is false.",
|
description: "Panic if a boolean is false.",
|
||||||
group: "test",
|
group: "test",
|
||||||
inputs: vec![],
|
inputs: vec![
|
||||||
|
ValueType::Boolean,
|
||||||
|
ValueType::Function
|
||||||
|
],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +36,7 @@ impl Macro for AssertEqual {
|
|||||||
identifier: "assert_equal",
|
identifier: "assert_equal",
|
||||||
description: "Panic if two values do not match.",
|
description: "Panic if two values do not match.",
|
||||||
group: "test",
|
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] {
|
if arguments[0] == arguments[1] {
|
||||||
Ok(Value::Empty)
|
Ok(Value::Empty)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Err(Error::AssertEqualFailed { expected: arguments[0].clone(), actual: arguments[1].clone() })
|
Err(Error::AssertEqualFailed { expected: arguments[0].clone(), actual: arguments[1].clone() })
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,8 @@ fn assert() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn assert_equal() {
|
fn assert_equal() {
|
||||||
eval("assert_eq(true, true)").unwrap();
|
eval("assert_equal(true, true)").unwrap();
|
||||||
eval("assert_eq(true, false)").unwrap_err();
|
eval("assert_equal(true, false)").unwrap_err();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
Reference in New Issue
Block a user