]> gitweb.factorcode.org Git - factor.git/blob - basis/unicode/breaks/breaks-tests.factor
unicode.breaks tests and bug fixes
[factor.git] / basis / unicode / breaks / breaks-tests.factor
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 ;
4 IN: unicode.breaks.tests
5
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
11
12 : grapheme-break-test ( -- filename )
13     "basis/unicode/breaks/GraphemeBreakTest.txt"
14     resource-path ;
15
16 : parse-test-file ( -- tests )
17     grapheme-break-test utf8 file-lines
18     [ "#" split1 drop ] map harvest [
19         "÷" split
20         [ "×" split [ [ blank? ] trim hex> ] map harvest >string ] map
21         harvest
22     ] map ;
23
24 : test-graphemes ( tests -- )
25     [
26         [ 1quotation ]
27         [ concat [ >graphemes [ "" like ] map ] curry ] bi unit-test
28     ] each ;
29
30 parse-test-file test-graphemes