mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-02 03:12:20 +00:00
Add expect tests for Str.splitLast
This commit is contained in:
parent
d89253779a
commit
97f49bf940
1 changed files with 3 additions and 0 deletions
|
@ -351,6 +351,9 @@ expect Str.splitLast "foo" "o" == Ok { before: "fo", after: "" }
|
||||||
# splitLast with multi-byte needle
|
# splitLast with multi-byte needle
|
||||||
expect Str.splitLast "hullabaloo" "ab" == Ok { before: "hull", after: "aloo" }
|
expect Str.splitLast "hullabaloo" "ab" == Ok { before: "hull", after: "aloo" }
|
||||||
|
|
||||||
|
# splitLast when needle is haystack
|
||||||
|
expect Str.splitLast "foo" "foo" == Ok { before: "", after: "" }
|
||||||
|
|
||||||
lastMatch : Str, Str -> [Some Nat, None]
|
lastMatch : Str, Str -> [Some Nat, None]
|
||||||
lastMatch = \haystack, needle ->
|
lastMatch = \haystack, needle ->
|
||||||
haystackLength = Str.countUtf8Bytes haystack
|
haystackLength = Str.countUtf8Bytes haystack
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue