Add List.startsWith and endsWith gen tests

This commit is contained in:
Richard Feldman 2022-07-22 10:53:04 -04:00 committed by Folkert
parent bdfcabd803
commit 7cf5732001
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -3032,6 +3032,162 @@ fn list_find_index_empty_typed_list() {
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn list_ends_with_empty() {
assert_evals_to!(
indoc!(
r#"
List.endsWith [] []
"#
),
true,
bool
);
assert_evals_to!(
indoc!(
r#"
List.endsWith ["a"] []
"#
),
true,
bool
);
assert_evals_to!(
indoc!(
r#"
List.endsWith [] ["a"]
"#
),
false,
bool
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn list_ends_with_nonempty() {
assert_evals_to!(
indoc!(
r#"
List.endsWith ["a", "bc", "def"] ["def"]
"#
),
true,
bool
);
assert_evals_to!(
indoc!(
r#"
List.endsWith ["a", "bc", "def"] ["bc", "def"]
"#
),
true,
bool
);
assert_evals_to!(
indoc!(
r#"
List.endsWith ["a", "bc", "def"] ["a"]
"#
),
false,
bool
);
assert_evals_to!(
indoc!(
r#"
List.endsWith ["a", "bc", "def"] [""]
"#
),
false,
bool
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn list_starts_with_empty() {
assert_evals_to!(
indoc!(
r#"
List.startsWith [] []
"#
),
true,
bool
);
assert_evals_to!(
indoc!(
r#"
List.startsWith ["a"] []
"#
),
true,
bool
);
assert_evals_to!(
indoc!(
r#"
List.startsWith [] ["a"]
"#
),
false,
bool
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn list_starts_with_nonempty() {
assert_evals_to!(
indoc!(
r#"
List.startsWith ["a", "bc", "def"] ["a"]
"#
),
true,
bool
);
assert_evals_to!(
indoc!(
r#"
List.startsWith ["a", "bc", "def"] ["a", "bc"]
"#
),
true,
bool
);
assert_evals_to!(
indoc!(
r#"
List.startsWith ["a", "bc", "def"] ["def"]
"#
),
false,
bool
);
assert_evals_to!(
indoc!(
r#"
List.startsWith ["a", "bc", "def"] [""]
"#
),
false,
bool
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn monomorphized_lists() {