2024-09-12 04:39:31 +00:00
|
|
|
use dust_lang::*;
|
|
|
|
|
2024-09-17 21:51:39 +00:00
|
|
|
#[test]
|
|
|
|
fn long_math() {
|
2024-09-19 22:07:11 +00:00
|
|
|
assert_eq!(
|
|
|
|
run("1 + 2 * 3 - 4 / 2"),
|
2024-09-22 16:57:58 +00:00
|
|
|
Ok(Some(Value::integer(5).into_reference()))
|
2024-09-19 22:07:11 +00:00
|
|
|
);
|
2024-09-17 21:51:39 +00:00
|
|
|
}
|
|
|
|
|
2024-09-12 04:39:31 +00:00
|
|
|
#[test]
|
|
|
|
fn add() {
|
|
|
|
assert_eq!(run("1 + 2"), Ok(Some(Value::integer(3))));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn subtract() {
|
|
|
|
assert_eq!(run("1 - 2"), Ok(Some(Value::integer(-1))));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn multiply() {
|
|
|
|
assert_eq!(run("2 * 3"), Ok(Some(Value::integer(6))));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn divide() {
|
|
|
|
assert_eq!(run("6 / 3"), Ok(Some(Value::integer(2))));
|
|
|
|
}
|