]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/unicode/breaks/breaks-tests.factor
use reject instead of [ ... not ] filter.
[factor.git] / basis / unicode / breaks / breaks-tests.factor
index 493c2db0c2c7fa2efcfde51dcb3d9b1652bcd18d..a3acaf3c4ff06b5e36eaa6d187747244a0b62af4 100644 (file)
@@ -9,6 +9,14 @@ IN: unicode.breaks.tests
 [ 3 ] [ "\u001112\u001161\u0011abA\u000300a"
         dup last-grapheme head last-grapheme ] unit-test
 
+[ 3 ] [ 2 "hello" first-grapheme-from ] unit-test
+[ 1 ] [ 2 "hello" last-grapheme-from ] unit-test
+
+[ 4 ] [ 2 "what am I saying" first-word-from ] unit-test
+[ 0 ] [ 2 "what am I saying" last-word-from ] unit-test
+[ 16 ] [ 11 "what am I saying" first-word-from ] unit-test
+[ 10 ] [ 11 "what am I saying" last-word-from ] unit-test
+
 : grapheme-break-test ( -- filename )
     "vocab:unicode/breaks/GraphemeBreakTest.txt" ;
 
@@ -19,7 +27,12 @@ IN: unicode.breaks.tests
     utf8 file-lines
     [ "#" split1 drop ] map harvest [
         "÷" split
-        [ "×" split [ [ blank? ] trim hex> ] map harvest >string ] map
+        [
+            "×" split
+            [ [ blank? ] trim hex> ] map
+            [ { f 0 } member? ] reject
+            >string
+        ] map
         harvest
     ] map ;
 
@@ -29,7 +42,7 @@ IN: unicode.breaks.tests
         [ concat [ quot call [ "" like ] map ] curry ] bi unit-test
     ] each ;
 
-: grapheme-test ( tests quot -- )
+: grapheme-test ( tests -- )
     [
         [ 1quotation ]
         [ concat [ >graphemes [ "" like ] map ] curry ] bi unit-test
@@ -38,4 +51,4 @@ IN: unicode.breaks.tests
 grapheme-break-test parse-test-file [ >graphemes ] test
 word-break-test parse-test-file [ >words ] test
 
-[ { t f t t f t } ] [ 6 [ "as df" word-break-at? ] map ] unit-test
+[ { t f t t f t } ] [ 6 iota [ "as df" word-break-at? ] map ] unit-test