1
0
dust/tests/built_in_values.rs

32 lines
759 B
Rust
Raw Permalink Normal View History

2024-02-18 20:07:53 +00:00
use dust_lang::{error::RuntimeError, *};
2024-01-06 07:26:51 +00:00
#[test]
fn args() {
assert!(interpret("args").is_ok_and(|value| value.is_list()));
}
2024-02-15 08:57:13 +00:00
#[test]
fn assert_equal() {
assert_eq!(
interpret("assert_equal"),
Ok(Value::Function(Function::BuiltIn(
BuiltInFunction::AssertEqual
)))
);
assert_eq!(
interpret("assert_equal(false, false)"),
Ok(Value::Enum(EnumInstance::new(
2024-02-15 21:02:27 +00:00
Identifier::new("Result"),
Identifier::new("Ok"),
2024-02-15 15:33:25 +00:00
Some(Value::none()),
2024-02-15 08:57:13 +00:00
)))
);
assert_eq!(
interpret("assert_equal(true, false)"),
2024-02-18 20:07:53 +00:00
Err(Error::Runtime(RuntimeError::AssertEqualFailed {
left: true.into(),
right: false.into()
}))
2024-02-15 08:57:13 +00:00
);
}