add error test case

This commit is contained in:
Brendan Hansknecht 2022-02-27 00:45:51 -08:00
parent b802d681a3
commit d9e9c28889
2 changed files with 18 additions and 1 deletions

View file

@ -2326,7 +2326,7 @@ fn list_replace(symbol: Symbol, var_store: &mut VarStore) -> Def {
// Otherwise, return the list unmodified.
let body = If {
cond_var: bool_var,
branch_var: var_store.fresh(),
branch_var: ret_result_var,
branches: vec![(
// if-condition
no_region(

View file

@ -1780,6 +1780,23 @@ fn replace_unique_int_list() {
);
}
#[test]
#[cfg(any(feature = "gen-llvm"))]
fn replace_unique_int_list_out_of_bounds() {
assert_evals_to!(
indoc!(
r#"
result = List.replace [ 12, 9, 7, 1, 5 ] 5 33
when result is
Ok {value} -> value
Err OutOfBounds -> -1
"#
),
-1,
i64
);
}
#[test]
#[cfg(any(feature = "gen-llvm"))]
fn replace_unique_int_list_get_old_value() {