mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 23:04:49 +00:00
add equality for strings
This commit is contained in:
parent
3e1d6d0965
commit
2ac19fb6e3
7 changed files with 84 additions and 20 deletions
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue