]> gitweb.factorcode.org Git - factor.git/commitdiff
splitting: Support SBUF" " with split-lines. Fixes #575. Thanks @mrjbq7
authorDoug Coleman <doug.coleman@gmail.com>
Sat, 23 Mar 2013 21:00:29 +0000 (14:00 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Sat, 23 Mar 2013 21:00:29 +0000 (14:00 -0700)
for the patch.

core/splitting/splitting-tests.factor
core/splitting/splitting.factor

index 5cda813c7ba09867f4466af1673f40fb4c6c3b84..7cb0df9ba08d41704e74824a5b78b11123eaa8a6 100644 (file)
@@ -58,6 +58,18 @@ unit-test
 [ { "hello" "hi" } ] [ "hello\rhi" string-lines ] unit-test
 [ { "hello" "hi" } ] [ "hello\r\nhi" string-lines ] unit-test
 
+[ { SBUF" " } ] [ SBUF" " string-lines ] unit-test
+[ { SBUF" " SBUF"  " } ] [ SBUF" \n" string-lines ] unit-test
+[ { SBUF" " SBUF" " } ] [ SBUF" \r" string-lines ] unit-test
+[ { SBUF" " SBUF" " } ] [ SBUF" \r\n" string-lines ] unit-test
+[ { SBUF" hello" } ] [ SBUF" hello" string-lines ] unit-test
+[ { SBUF" hello" SBUF" " } ] [ SBUF" hello\n" string-lines ] unit-test
+[ { SBUF" hello" SBUF" " } ] [ SBUF" hello\r" string-lines ] unit-test
+[ { SBUF" hello" SBUF" " } ] [ SBUF" hello\r\n" string-lines ] unit-test
+[ { SBUF" hello" SBUF" hi" } ] [ SBUF" hello\nhi" string-lines ] unit-test
+[ { SBUF" hello" SBUF" hi" } ] [ SBUF" hello\rhi" string-lines ] unit-test
+[ { SBUF" hello" SBUF" hi" } ] [ SBUF" hello\r\nhi" string-lines ] unit-test
+
 [ { "hey" "world" "what's" "happening" } ]
 [ "heyAworldBwhat'sChappening" [ LETTER? ] split-when ] unit-test
 
index d2348b9e6bd05a06cd3fb1240108bb9619dd40b7..16944c3120aebd697481a1bb9cbefdbd20d0ec90 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2005, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays kernel make math sequences strings ;
+USING: arrays kernel make math sequences strings sbufs ;
 IN: splitting
 
 <PRIVATE
@@ -120,3 +120,6 @@ M: string string-lines
     ] [
         1array
     ] if ;
+
+M: sbuf string-lines
+    [ "" like string-lines ] keep [ like ] curry map ;
\ No newline at end of file