summaryrefslogtreecommitdiff
path: root/test/unit/_count_args.exp
blob: da61bdb6ffa9aa29435d715ccf0289b703a81d6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
proc setup {} {
    assert_bash_exec {unset COMP_CWORD COMP_LINE COMP_POINT COMP_WORDS}
    save_env
}; # setup()


proc teardown {} {
    assert_bash_exec {unset args COMP_CWORD COMP_LINE COMP_POINT COMP_WORDS}
    # Delete 'COMP_WORDBREAKS' occupying two lines
    assert_env_unmodified {
        /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=2; COMP_LINE='a b -c d'; COMP_POINT=6; _count_args; echo -n $args}
assert_bash_list 2 $cmd $test


sync_after_int


teardown