fix: fix String.words for multiple spaces (#1205)

This commit is contained in:
Veit Heller 2021-04-23 09:35:34 +02:00 committed by GitHub
parent 2afe09a94e
commit 77020df042
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -144,7 +144,7 @@ list of those characters.")
(doc words "splits a string into words.") (doc words "splits a string into words.")
(defn words [s] (defn words [s]
(split-by s &[\tab \space \newline])) (Array.endo-filter &(fn [s] (not (empty? s))) (split-by s &[\tab \space \newline])))
(doc lines "splits a string into lines.") (doc lines "splits a string into lines.")
(defn lines [s] (defn lines [s]

View File

@ -184,7 +184,11 @@
(assert-equal test (assert-equal test
&[@"erik" @"sved" @"hej" @"foo"] &[@"erik" @"sved" @"hej" @"foo"]
&(words "erik sved\nhej\tfoo") &(words "erik sved\nhej\tfoo")
"words works correctly") "words works correctly I")
(assert-equal test
&[@"erik" @"sved" @"hej" @"foo"]
&(words "erik sved\n\nhej\tfoo")
"words works correctly II")
(assert-equal test (assert-equal test
&[@"erik" @"sved" @"hej" @"foo"] &[@"erik" @"sved" @"hej" @"foo"]
&(lines "erik\nsved\nhej\nfoo") &(lines "erik\nsved\nhej\nfoo")