2024-03-08 17:24:11 +00:00
|
|
|
use dust_lang::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn loops_and_breaks() {
|
|
|
|
assert_eq!(
|
|
|
|
interpret(
|
|
|
|
"
|
|
|
|
i = 0;
|
|
|
|
loop {
|
|
|
|
if i == 3 {
|
|
|
|
break 'foobar'
|
|
|
|
} else {
|
|
|
|
i += 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"
|
|
|
|
),
|
|
|
|
Ok(Some(Value::string("foobar")))
|
|
|
|
)
|
|
|
|
}
|
2024-03-08 19:29:53 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn r#if() {
|
|
|
|
assert_eq!(
|
|
|
|
interpret("if true 'foobar'"),
|
|
|
|
Ok(Some(Value::string("foobar")))
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn if_else() {
|
|
|
|
assert_eq!(
|
|
|
|
interpret("if false 'foo' else 'bar'"),
|
|
|
|
Ok(Some(Value::string("bar")))
|
|
|
|
)
|
|
|
|
}
|