mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
add error test case
This commit is contained in:
parent
b802d681a3
commit
d9e9c28889
2 changed files with 18 additions and 1 deletions
|
@ -2326,7 +2326,7 @@ fn list_replace(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
||||||
// Otherwise, return the list unmodified.
|
// Otherwise, return the list unmodified.
|
||||||
let body = If {
|
let body = If {
|
||||||
cond_var: bool_var,
|
cond_var: bool_var,
|
||||||
branch_var: var_store.fresh(),
|
branch_var: ret_result_var,
|
||||||
branches: vec![(
|
branches: vec![(
|
||||||
// if-condition
|
// if-condition
|
||||||
no_region(
|
no_region(
|
||||||
|
|
|
@ -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]
|
#[test]
|
||||||
#[cfg(any(feature = "gen-llvm"))]
|
#[cfg(any(feature = "gen-llvm"))]
|
||||||
fn replace_unique_int_list_get_old_value() {
|
fn replace_unique_int_list_get_old_value() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue