unicode.collation: better tests that don't spam the console.

char-rename
John Benediktsson 2016-07-10 16:36:14 -07:00
parent 77bb2c4146
commit 55565ace6d
1 changed files with 8 additions and 13 deletions

View File

@ -1,16 +1,7 @@
USING: io io.files splitting grouping unicode USING: assocs grouping io.encodings.utf8 io.files kernel
sequences kernel io.encodings.utf8 math.parser math.order math.order math.parser sequences splitting tools.test unicode ;
tools.test assocs words ;
IN: unicode.collation.tests IN: unicode.collation.tests
: parse-test ( -- strings )
"vocab:unicode/collation/CollationTest_SHIFTED.txt"
utf8 file-lines 5 tail
[ ";" split1 drop " " split [ hex> ] "" map-as ] map ;
: test-two ( str1 str2 -- )
[ +lt+ ] -rot [ string<=> ] 2curry unit-test ;
: test-equality ( str1 str2 -- ? ? ? ? ) : test-equality ( str1 str2 -- ? ? ? ? )
{ primary= secondary= tertiary= quaternary= } { primary= secondary= tertiary= quaternary= }
[ execute( a b -- ? ) ] 2with map [ execute( a b -- ? ) ] 2with map
@ -25,5 +16,9 @@ IN: unicode.collation.tests
[ { "HELLO" "goodbye" "good bye" "hello" } sort-strings ] [ { "HELLO" "goodbye" "good bye" "hello" } sort-strings ]
unit-test unit-test
parse-test 2 <clumps> { { } } [
[ test-two ] assoc-each "vocab:unicode/collation/CollationTest_SHIFTED.txt"
utf8 file-lines 5 tail
[ ";" split1 drop " " split [ hex> ] "" map-as ] map
2 clump [ string<=> +lt+ eq? ] assoc-reject
] unit-test