mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Add List.findLast gen tests
This commit is contained in:
parent
c3cfc0d396
commit
bdfcabd803
1 changed files with 41 additions and 5 deletions
|
@ -2846,7 +2846,7 @@ fn list_find() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.findFirst ["a", "bc", "def"] (\s -> Str.countGraphemes s > 1) is
|
||||
when List.findFirst ["a", "bc", "def", "g"] (\s -> Str.countGraphemes s > 1) is
|
||||
Ok v -> v
|
||||
Err _ -> "not found"
|
||||
"#
|
||||
|
@ -2854,6 +2854,18 @@ fn list_find() {
|
|||
RocStr::from("bc"),
|
||||
RocStr
|
||||
);
|
||||
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.findLast ["a", "bc", "def", "g"] (\s -> Str.countGraphemes s > 1) is
|
||||
Ok v -> v
|
||||
Err _ -> "not found"
|
||||
"#
|
||||
),
|
||||
RocStr::from("def"),
|
||||
RocStr
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -2862,7 +2874,19 @@ fn list_find_not_found() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.findFirst ["a", "bc", "def"] (\s -> Str.countGraphemes s > 5) is
|
||||
when List.findFirst ["a", "bc", "def", "g"] (\s -> Str.countGraphemes s > 5) is
|
||||
Ok v -> v
|
||||
Err _ -> "not found"
|
||||
"#
|
||||
),
|
||||
RocStr::from("not found"),
|
||||
RocStr
|
||||
);
|
||||
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.findLast ["a", "bc", "def", "g"] (\s -> Str.countGraphemes s > 5) is
|
||||
Ok v -> v
|
||||
Err _ -> "not found"
|
||||
"#
|
||||
|
@ -2886,6 +2910,18 @@ fn list_find_empty_typed_list() {
|
|||
RocStr::from("not found"),
|
||||
RocStr
|
||||
);
|
||||
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.findLast [] (\s -> Str.countGraphemes s > 5) is
|
||||
Ok v -> v
|
||||
Err _ -> "not found"
|
||||
"#
|
||||
),
|
||||
RocStr::from("not found"),
|
||||
RocStr
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -2918,7 +2954,7 @@ fn list_find_index() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.findFirstIndex ["a", "bc", "def"] (\s -> Str.countGraphemes s > 1) is
|
||||
when List.findFirstIndex ["a", "bc", "def", "g"] (\s -> Str.countGraphemes s > 1) is
|
||||
Ok v -> v
|
||||
Err _ -> 999
|
||||
"#
|
||||
|
@ -2930,7 +2966,7 @@ fn list_find_index() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.findLastIndex ["a", "bc", "def"] (\s -> Str.countGraphemes s > 1) is
|
||||
when List.findLastIndex ["a", "bc", "def", "g"] (\s -> Str.countGraphemes s > 1) is
|
||||
Ok v -> v
|
||||
Err _ -> 999
|
||||
"#
|
||||
|
@ -2946,7 +2982,7 @@ fn list_find_index_not_found() {
|
|||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
when List.findFirstIndex ["a", "bc", "def"] (\s -> Str.countGraphemes s > 5) is
|
||||
when List.findFirstIndex ["a", "bc", "def", "g"] (\s -> Str.countGraphemes s > 5) is
|
||||
Ok v -> v
|
||||
Err _ -> 999
|
||||
"#
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue