2024-01-06 07:26:51 +00:00
|
|
|
use dust_lang::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn list_index() {
|
2024-02-18 10:36:51 +00:00
|
|
|
let test = interpret("x = [1 [2] 3] x:1:0");
|
2024-01-06 07:26:51 +00:00
|
|
|
|
2024-02-18 10:36:51 +00:00
|
|
|
assert_eq!(Ok(Value::Integer(2)), test);
|
2024-01-06 07:26:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn map_index() {
|
2024-02-18 10:36:51 +00:00
|
|
|
let test = interpret("x = {y = {z = 2}} x:y:z");
|
2024-01-06 07:26:51 +00:00
|
|
|
|
2024-02-18 10:36:51 +00:00
|
|
|
assert_eq!(Ok(Value::Integer(2)), test);
|
2024-01-06 07:26:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[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))
|
|
|
|
);
|
|
|
|
}
|