mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Add Str.walkUtf8
This commit is contained in:
parent
f7e96ecf82
commit
c3c1b8d083
3 changed files with 56 additions and 0 deletions
|
@ -1822,6 +1822,33 @@ fn str_split_overlapping_substring_2() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_walk_utf8() {
|
||||
#[cfg(not(feature = "gen-llvm-wasm"))]
|
||||
assert_evals_to!(
|
||||
// Reverse the bytes
|
||||
indoc!(
|
||||
r#"
|
||||
Str.walkUtf8 "abcd" [] (\list, byte -> List.prepend list byte)
|
||||
"#
|
||||
),
|
||||
RocList::from_slice(&[b'd', b'c', b'b', b'a']),
|
||||
RocList<u8>
|
||||
);
|
||||
|
||||
#[cfg(feature = "gen-llvm-wasm")]
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
Str.walkUtf8WithIndex "abcd" [] (\list, byte, index -> List.append list (Pair index byte))
|
||||
"#
|
||||
),
|
||||
RocList::from_slice(&[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'd')]),
|
||||
RocList<(u32, char)>
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-dev"))]
|
||||
fn str_walk_utf8_with_index() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue