haku: add len
and index
functions for reading lists
This commit is contained in:
parent
dd955b0649
commit
e2f9538156
3 changed files with 63 additions and 8 deletions
|
@ -292,3 +292,20 @@ fn with_dotter_identity() {
|
|||
"#;
|
||||
assert_eq!(eval(code).unwrap(), Value::Ref(RefId::from_u32(2)))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn system_len() {
|
||||
expect_number("len []", 0.0, 0.0001);
|
||||
expect_number("len [1, 2]", 2.0, 0.0001);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn system_index() {
|
||||
expect_number("index [1] 0", 1.0, 0.0001);
|
||||
expect_number("index [1, 2] 0", 1.0, 0.0001);
|
||||
expect_number("index [1, 2] 1", 2.0, 0.0001);
|
||||
expect_number("index [1] 0.5", 1.0, 0.0001);
|
||||
expect_number("index [1, 2] 0.5", 1.0, 0.0001);
|
||||
assert!(eval("index [1] (-1)").is_err());
|
||||
assert!(eval("index [1] 1").is_err());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue