summaryrefslogtreecommitdiff
path: root/test/unit/_get_cword.exp
blob: 91bcb44e78c4eee89df733d51c9b5a88816e2b15 (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
proc setup {} {
    assert_bash_exec {unset COMP_CWORD COMP_LINE COMP_POINT COMP_WORDS}
    save_env
}


proc teardown {} {
    assert_bash_exec {unset COMP_CWORD COMP_LINE COMP_POINT COMP_WORDS}
    # Delete 'COMP_WORDBREAKS' occupying two lines
    assert_env_unmodified {
        /COMP_WORDBREAKS=/{N
        d
        }
        /_scp_path_esc=/d
    }
}


setup


# See also ./lib/completions/alias.exp.  Here `_get_cword' is actually tested
# by moving the cursor left into the current word.

set test "index shouldn't drop below 0"
set dir $::srcdir/fixtures/_get_cword
set cmd "scp"
send "$cmd ääää§ se\t\r\n"
expect {
    -re "index: substring expression < 0" { fail "$test" }
    -re /@ { pass "$test" }
    default { unresolved "$test" }
}
sync_after_int


teardown