add equality for strings

This commit is contained in:
Folkert 2021-01-02 18:50:29 +01:00
parent 3e1d6d0965
commit 2ac19fb6e3
7 changed files with 84 additions and 20 deletions

View file

@ -415,25 +415,24 @@ mod gen_list {
);
}
//
// "panicked at 'not yet implemented: Handle equals for builtin layouts Str == Str'"
//
// #[test]
// fn list_keep_if_str_is_hello() {
// assert_evals_to!(
// indoc!(
// r#"
// strIsHello : Str -> Bool
// strIsHello = \str ->
// str == "Hello"
//
// List.keepIf ["Hello", "Hello", "Goodbye"] strIsHello
// "#
// ),
// RocList::from_slice(&["Hello", "Hello"]),
// RocList<&'static str>
// );
// }
#[test]
#[ignore]
fn list_keep_if_str_is_hello() {
// keepIf causes a segfault with this function
assert_evals_to!(
indoc!(
r#"
strIsHello : Str -> Bool
strIsHello = \str ->
str == "Hello"
List.keepIf ["Hello", "Hello", "Goodbye"] strIsHello
"#
),
RocList::from_slice(&["Hello", "Hello"]),
RocList<&'static str>
);
}
#[test]
fn list_map_on_empty_list_with_int_layout() {

View file

@ -514,4 +514,16 @@ mod gen_str {
let min = format!("{}", i64::MIN);
assert_evals_to!(r#"Str.fromInt Num.minInt"#, &min, &'static str);
}
#[test]
fn str_equality() {
assert_evals_to!(r#""a" == "a""#, true, bool);
assert_evals_to!(
r#""loremipsumdolarsitamet" == "loremipsumdolarsitamet""#,
true,
bool
);
assert_evals_to!(r#""a" != "b""#, true, bool);
assert_evals_to!(r#""a" == "b""#, false, bool);
}
}