1
0
dust/tests/index.rs

42 lines
739 B
Rust
Raw Permalink Normal View History

2024-01-06 07:26:51 +00:00
use dust_lang::*;
#[test]
fn list_index() {
let test = interpret("x = [1 [2] 3] x:1:0").unwrap();
assert_eq!(Value::Integer(2), test);
}
#[test]
fn map_index() {
let test = interpret("x = {y = {z = 2}} x:y:z").unwrap();
assert_eq!(Value::Integer(2), test);
}
#[test]
fn index_function_calls() {
assert_eq!(
interpret(
"
x = [1 2 3]
y = () <int> { 2 }
x:(y())
",
),
Ok(Value::Integer(3))
);
assert_eq!(
interpret(
"
x = {
y = () <int> { 2 }
}
x:y()
",
),
Ok(Value::Integer(2))
);
}