1 USING: tools.test unicode.breaks sequences math kernel splitting
2 unicode.categories io.pathnames io.encodings.utf8 io.files
3 strings quotations math.parser locals ;
4 IN: unicode.breaks.tests
6 [ "\u001112\u001161\u0011abA\u000300a\r\r\n" ]
7 [ "\r\n\raA\u000300\u001112\u001161\u0011ab" string-reverse ] unit-test
8 [ "dcba" ] [ "abcd" string-reverse ] unit-test
9 [ 3 ] [ "\u001112\u001161\u0011abA\u000300a"
10 dup last-grapheme head last-grapheme ] unit-test
12 : grapheme-break-test ( -- filename )
13 "vocab:unicode/breaks/GraphemeBreakTest.txt" ;
15 : word-break-test ( -- filename )
16 "vocab:unicode/breaks/WordBreakTest.txt" ;
18 : parse-test-file ( file-name -- tests )
20 [ "#" split1 drop ] map harvest [
22 [ "×" split [ [ blank? ] trim hex> ] map harvest >string ] map
26 :: test ( tests quot -- )
29 [ concat [ quot call [ "" like ] map ] curry ] bi unit-test
32 : grapheme-test ( tests quot -- )
35 [ concat [ >graphemes [ "" like ] map ] curry ] bi unit-test
38 grapheme-break-test parse-test-file [ >graphemes ] test
39 word-break-test parse-test-file [ >words ] test