tools.completion: undo private change, and add tests.
parent
2cdff2746c
commit
36da386816
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
USING: assocs kernel tools.completion tools.completion.private
|
||||||
|
tools.test ;
|
||||||
|
|
||||||
|
IN: tools.completion
|
||||||
|
|
||||||
|
[ f ] [ "abc" "def" fuzzy ] unit-test
|
||||||
|
[ V{ 4 5 6 } ] [ "set-nth" "nth" fuzzy ] unit-test
|
||||||
|
|
||||||
|
[ V{ V{ 0 } V{ 4 5 6 } } ] [ V{ 0 4 5 6 } runs ] unit-test
|
||||||
|
|
||||||
|
[ { "nth" "?nth" "set-nth" } ] [
|
||||||
|
"nth" { "set-nth" "nth" "?nth" } dup zip completions keys
|
||||||
|
] unit-test
|
|
@ -14,6 +14,8 @@ IN: tools.completion
|
||||||
rot [ ch>lower ] [ ch>upper ] bi
|
rot [ ch>lower ] [ ch>upper ] bi
|
||||||
[ eq? ] bi-curry@ [ bi or ] 2curry find-from drop ;
|
[ eq? ] bi-curry@ [ bi or ] 2curry find-from drop ;
|
||||||
|
|
||||||
|
PRIVATE>
|
||||||
|
|
||||||
:: (fuzzy) ( accum i full ch -- accum i full ? )
|
:: (fuzzy) ( accum i full ch -- accum i full ? )
|
||||||
ch i full smart-index-from [
|
ch i full smart-index-from [
|
||||||
:> i i accum push
|
:> i i accum push
|
||||||
|
@ -75,8 +77,6 @@ IN: tools.completion
|
||||||
: completion, ( short candidate -- )
|
: completion, ( short candidate -- )
|
||||||
completion dup first 0 > [ , ] [ drop ] if ;
|
completion dup first 0 > [ , ] [ drop ] if ;
|
||||||
|
|
||||||
PRIVATE>
|
|
||||||
|
|
||||||
: completions ( short candidates -- seq )
|
: completions ( short candidates -- seq )
|
||||||
[ ] [
|
[ ] [
|
||||||
[ [ completion, ] with each ] { } make
|
[ [ completion, ] with each ] { } make
|
||||||
|
|
Loading…
Reference in New Issue