Add dropLast to tests and parser

This commit is contained in:
Chelsea Troy 2021-10-21 23:02:26 -05:00
parent 51de420ee7
commit 49a832d757
No known key found for this signature in database
GPG key ID: A631885A970636C2
7 changed files with 77 additions and 0 deletions

View file

@ -235,6 +235,38 @@ fn list_drop_at_mutable() {
);
}
#[test]
fn list_drop_last() {
assert_evals_to!(
"List.dropLast [1, 2, 3]",
RocList::from_slice(&[1, 2]),
RocList<i64>
);
assert_evals_to!("List.dropLast []", RocList::from_slice(&[]), RocList<i64>);
assert_evals_to!("List.dropLast [0]", RocList::from_slice(&[]), RocList<i64>);
}
#[test]
fn list_drop_last_mutable() {
assert_evals_to!(
indoc!(
r#"
list : List I64
list = [ if True then 4 else 4, 5, 6 ]
{ newList: List.dropLast list, original: list }
"#
),
(
// new_list
RocList::from_slice(&[4, 5]),
// original
RocList::from_slice(&[4, 5, 6]),
),
(RocList<i64>, RocList<i64>,)
);
}
#[test]
fn list_swap() {
assert_evals_to!("List.swap [] 0 1", RocList::from_slice(&[]), RocList<i64>);