]> gitweb.factorcode.org Git - factor.git/commitdiff
tools.completion: undo private change, and add tests.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 13 Sep 2011 16:22:57 +0000 (09:22 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 13 Sep 2011 16:22:57 +0000 (09:22 -0700)
basis/tools/completion/completion-tests.factor [new file with mode: 0644]
basis/tools/completion/completion.factor

diff --git a/basis/tools/completion/completion-tests.factor b/basis/tools/completion/completion-tests.factor
new file mode 100644 (file)
index 0000000..316bc51
--- /dev/null
@@ -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
index ab675c82245294fb9d13903ba4775905598a87c0..e0a43927ba77d7b04829b29b922b22ac0259b4f6 100644 (file)
@@ -14,6 +14,8 @@ IN: tools.completion
     rot [ ch>lower ] [ ch>upper ] bi
     [ eq? ] bi-curry@ [ bi or ] 2curry find-from drop ;
 
+PRIVATE>
+
 :: (fuzzy) ( accum i full ch -- accum i full ? )
     ch i full smart-index-from [
         :> i i accum push
@@ -75,8 +77,6 @@ IN: tools.completion
 : completion, ( short candidate -- )
     completion dup first 0 > [ , ] [ drop ] if ;
 
-PRIVATE>
-
 : completions ( short candidates -- seq )
     [ ] [
         [ [ completion, ] with each ] { } make