2009-12-11 00:14:02 +02:00
|
|
|
proc setup {} {
|
2009-12-12 12:36:38 +01:00
|
|
|
assert_bash_exec {unset COMP_CWORD COMP_LINE COMP_POINT COMP_WORDS}
|
2009-12-11 00:14:02 +02:00
|
|
|
save_env
|
2010-06-18 17:21:38 +02:00
|
|
|
}
|
2009-12-11 00:14:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
proc teardown {} {
|
2009-12-12 12:36:38 +01:00
|
|
|
assert_bash_exec {unset args COMP_CWORD COMP_LINE COMP_POINT COMP_WORDS}
|
2010-01-03 23:49:19 +02:00
|
|
|
# Delete 'COMP_WORDBREAKS' occupying two lines
|
2009-12-11 00:14:02 +02:00
|
|
|
assert_env_unmodified {
|
|
|
|
/COMP_WORDBREAKS=/{N
|
2010-01-03 23:49:19 +02:00
|
|
|
d
|
|
|
|
}
|
2009-12-11 00:14:02 +02:00
|
|
|
}
|
2010-06-18 17:21:38 +02:00
|
|
|
}
|
2009-12-11 00:14:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
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
|
2010-11-16 23:06:13 +01:00
|
|
|
set cmd {COMP_WORDS=(a b); COMP_CWORD=1; COMP_LINE='a b'; COMP_POINT=3; _count_args; echo $args}
|
2009-12-11 00:14:02 +02:00
|
|
|
assert_bash_list 1 $cmd $test
|
|
|
|
|
|
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
|
|
|
2010-11-16 23:21:05 +01:00
|
|
|
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 $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 $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 $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=2; COMP_LINE='a b -c d'; COMP_POINT=6; _count_args; echo $args}
|
|
|
|
assert_bash_list 2 $cmd $test
|
|
|
|
|
|
|
|
|
|
|
|
sync_after_int
|
2009-12-11 00:14:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
teardown
|