Add a test_infer for List.get

This commit is contained in:
Richard Feldman 2020-02-29 20:07:19 -05:00
parent 46f8f2313f
commit 5d07057e09

View File

@ -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 ]*",
);
}
}