mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-11 05:34:11 +03:00
Add a test_infer for List.get
This commit is contained in:
parent
46f8f2313f
commit
5d07057e09
@ -2228,10 +2228,10 @@ mod test_infer {
|
||||
list
|
||||
|> List.set i atJ
|
||||
|> List.set j atI
|
||||
|
||||
|
||||
_ ->
|
||||
list
|
||||
|
||||
|
||||
partition : Int, Int, List Int -> [ Pair Int (List Int) ]
|
||||
partition = \low, high, initialList ->
|
||||
when List.get initialList high is
|
||||
@ -2244,19 +2244,19 @@ mod test_infer {
|
||||
go (i + 1) (j + 1) (swap (i + 1) j list)
|
||||
else
|
||||
go i (j + 1) list
|
||||
|
||||
|
||||
Err _ ->
|
||||
Pair i list
|
||||
else
|
||||
Pair i list
|
||||
|
||||
|
||||
when go (low - 1) low initialList is
|
||||
Pair newI newList ->
|
||||
Pair (newI + 1) (swap (newI + 1) high newList)
|
||||
|
||||
|
||||
Err _ ->
|
||||
Pair (low - 1) initialList
|
||||
|
||||
|
||||
partition
|
||||
"#
|
||||
),
|
||||
@ -2282,4 +2282,16 @@ mod test_infer {
|
||||
"List Int -> List Int",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn list_get() {
|
||||
infer_eq_without_problem(
|
||||
indoc!(
|
||||
r#"
|
||||
List.get [ 10, 9, 8, 7 ] 1
|
||||
"#
|
||||
),
|
||||
"Result Int [ IndexOutOfBounds ]*",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user