[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 733811a7b14f7a510f99977e41d97afa353603c6

Ville Skyttä ville.skytta at iki.fi
Thu Dec 10 22:40:17 UTC 2009


The following commit has been merged in the master branch:
commit b8ffa2dc48f55a411a5fcd5d92c85ca73da976de
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Fri Dec 11 00:14:02 2009 +0200

    Add some unit tests for _count_args.

diff --git a/test/unit/_count_args.exp b/test/unit/_count_args.exp
new file mode 100644
index 0000000..c96bdee
--- /dev/null
+++ b/test/unit/_count_args.exp
@@ -0,0 +1,70 @@
+proc setup {} {
+    save_env
+}; # setup()
+
+
+proc teardown {} {
+    assert_env_unmodified {
+        /args=/d
+        /COMP_CWORD=/d
+        /COMP_LINE=/d
+        /COMP_POINT=/d
+        /COMP_WORDS=/d
+        # Delete 'COMP_WORDBREAKS' occupying two lines
+        /COMP_WORDBREAKS=/{N
+        d}
+    }
+}; # teardown()
+
+
+setup
+
+
+set test "_count_args should run without errors"
+assert_bash_exec {_count_args > /dev/null} $test
+
+
+sync_after_int
+
+
+set test "a b| should set args to 1";  # | = cursor position
+set cmd {COMP_WORDS=(a b); COMP_CWORD=1; COMP_LINE='a b'; COMP_POINT=3; _count_args; echo -n $args}
+assert_bash_list 1 $cmd $test
+
+
+sync_after_int
+
+
+set test "a b|c should set args to 1";  # | = cursor position
+set cmd {COMP_WORDS=(a bc); COMP_CWORD=1; COMP_LINE='a bc'; COMP_POINT=3; _count_args; echo -n $args}
+assert_bash_list 1 $cmd $test
+
+
+sync_after_int
+
+
+set test "a b c| should set args to 2";  # | = cursor position
+set cmd {COMP_WORDS=(a b c); COMP_CWORD=2; COMP_LINE='a b c'; COMP_POINT=4; _count_args; echo -n $args}
+assert_bash_list 2 $cmd $test
+
+
+sync_after_int
+
+
+set test "a b| c should set args to 1";  # | = cursor position
+set cmd {COMP_WORDS=(a b c); COMP_CWORD=1; COMP_LINE='a b c'; COMP_POINT=3; _count_args; echo -n $args}
+assert_bash_list 1 $cmd $test
+
+
+sync_after_int
+
+
+set test "a b -c d| should set args to 2";  # | = cursor position
+set cmd {COMP_WORDS=(a b -c d); COMP_CWORD=3; COMP_LINE='a b -c d'; COMP_POINT=6; _count_args; echo -n $args}
+assert_bash_list 2 $cmd $test
+
+
+sync_after_int
+
+
+teardown

-- 
bash-completion



More information about the Bash-completion-commits mailing list