Collation cleanup and test added
parent
a2ee33f282
commit
94776f6841
|
@ -24,6 +24,9 @@ IN: unicode.collation.tests
|
||||||
[ t t f f ] [ "hello" "HELLO" test-equality ] unit-test
|
[ t t f f ] [ "hello" "HELLO" test-equality ] unit-test
|
||||||
[ t t t f ] [ "hello" "h e l l o." test-equality ] unit-test
|
[ t t t f ] [ "hello" "h e l l o." test-equality ] unit-test
|
||||||
[ t t t t ] [ "hello" "\0hello\0" test-equality ] unit-test
|
[ t t t t ] [ "hello" "\0hello\0" test-equality ] unit-test
|
||||||
|
[ { "good bye" "goodbye" "hello" "HELLO" } ]
|
||||||
|
[ { "HELLO" "goodbye" "good bye" "hello" } sort-strings ]
|
||||||
|
unit-test
|
||||||
|
|
||||||
parse-test 2 <clumps>
|
parse-test 2 <clumps>
|
||||||
[ [ test-two ] assoc-each ] with-null-writer
|
[ [ test-two ] assoc-each ] with-null-writer
|
||||||
|
|
|
@ -154,18 +154,13 @@ PRIVATE>
|
||||||
0 insensitive= ;
|
0 insensitive= ;
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
: compare-collation ( {str1,key} {str2,key} -- <=> )
|
|
||||||
2dup [ second ] bi@ <=> dup +eq+ =
|
|
||||||
[ drop <=> ] [ 2nip ] if ;
|
|
||||||
|
|
||||||
: w/collation-key ( str -- {str,key} )
|
: w/collation-key ( str -- {str,key} )
|
||||||
dup collation-key 2array ;
|
[ collation-key ] keep 2array ;
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
: sort-strings ( strings -- sorted )
|
: sort-strings ( strings -- sorted )
|
||||||
[ w/collation-key ] map
|
[ w/collation-key ] map
|
||||||
[ compare-collation ] sort
|
natural-sort values ;
|
||||||
keys ;
|
|
||||||
|
|
||||||
: string<=> ( str1 str2 -- <=> )
|
: string<=> ( str1 str2 -- <=> )
|
||||||
[ w/collation-key ] bi@ compare-collation ;
|
[ w/collation-key ] compare ;
|
||||||
|
|
Loading…
Reference in New Issue