hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 4dcb5171fbb4c3cdcf5a3fc44c4943a7344afb59
parent 378594c4e94c8d1a67a5c60629c1ed1598a83f72
Author: Bor Grošelj Simić <bor.groseljsimic@telemach.net>
Date:   Tue, 16 Feb 2021 01:36:07 +0100

strings::tokenize: add a test for when delimiter is whole string

Diffstat:
Mstrings/tokenize.ha | 14++++++++++++++
1 file changed, 14 insertions(+), 0 deletions(-)

diff --git a/strings/tokenize.ha b/strings/tokenize.ha @@ -47,6 +47,20 @@ export fn remaining_tokens(s: *tokenizer) str = { }; assert(remaining_tokens(&tok) == "is drew"); + + tok = tokenize("foo", "foo"); + match (next_token(&tok)) { + s: str => assert(s == ""), + void => abort(), + }; + match (next_token(&tok)) { + s: str => assert(s == ""), + void => abort(), + }; + match (next_token(&tok)) { + s: str => abort(), + void => void, + }; }; // Splits a string into tokens delimited by 'delim', returning a slice of up to