add tests for List.dropAt

This commit is contained in:
Dan Knutson 2021-10-02 21:44:35 -05:00
parent 3baff93a97
commit 700ab20a8c
3 changed files with 29 additions and 8 deletions

View file

@ -833,8 +833,6 @@ pub fn listDrop(
}
}
// GIESCH add type inference test
// GIESCH add unit tests
// GIESCH do a uniqueness check, and reuse the same array if possible
// GIESCH figure out where to specify uniqueness of output, update builtins readme
pub fn listDropAt(
@ -848,7 +846,8 @@ pub fn listDropAt(
const size = list.len();
if (drop_index >= size) {
return RocList.empty();
// GIESCH should this still copy/reallocate if non-unique?
return list;
}
if (drop_index < size) {
@ -856,11 +855,6 @@ pub fn listDropAt(
dec(element);
}
// GIESCH is this necessary?
if (size < 2 and drop_index == 0) {
return RocList.empty();
}
const output = RocList.allocate(alignment, (size - 1), element_width);
const target_ptr = output.bytes orelse unreachable;