diff options
Diffstat (limited to 'test/unit/_get_cword.exp')
-rw-r--r-- | test/unit/_get_cword.exp | 94 |
1 files changed, 15 insertions, 79 deletions
diff --git a/test/unit/_get_cword.exp b/test/unit/_get_cword.exp index ce749cec..3a582811 100644 --- a/test/unit/_get_cword.exp +++ b/test/unit/_get_cword.exp @@ -97,27 +97,13 @@ sync_after_int set test {a 'b c| should return 'b c}; # | = cursor position -if { - [lindex $::BASH_VERSINFO 0] == 4 && - [lindex $::BASH_VERSINFO 1] == 0 && - [lindex $::BASH_VERSINFO 2] < 35 -} { - set cmd {COMP_WORDS=(a "'" b c); COMP_CWORD=3} -} else { - set cmd {COMP_WORDS=(a "'b c"); COMP_CWORD=1} -} +set cmd {COMP_WORDS=(a "'b c"); COMP_CWORD=1} append cmd {; COMP_LINE="a 'b c"; COMP_POINT=6; _get_cword} send "$cmd\r" expect -ex "$cmd\r\n" expect { -ex "'b c/@" { pass "$test" } - -ex "c/@" { - if { - [lindex $::BASH_VERSINFO 0] == 4 && - [lindex $::BASH_VERSINFO 1] == 0 && - [lindex $::BASH_VERSINFO 2] < 35 - } {xfail "$test"} {fail "$test"} - } + -ex "c/@" { fail "$test" } } @@ -125,41 +111,22 @@ sync_after_int set test {a "b c| should return "b c}; # | = cursor position -if { - [lindex $::BASH_VERSINFO 0] == 4 && - [lindex $::BASH_VERSINFO 1] == 0 && - [lindex $::BASH_VERSINFO 2] < 35 -} { - set cmd {COMP_WORDS=(a "\"" b c); COMP_CWORD=3} -} else { - set cmd {COMP_WORDS=(a "\"b c"); COMP_CWORD=1} -} +set cmd {COMP_WORDS=(a "\"b c"); COMP_CWORD=1} append cmd {; COMP_LINE="a \"b c"; COMP_POINT=6; _get_cword}; send "$cmd\r" expect -ex "$cmd\r\n" expect { -ex "\"b c/@" { pass "$test" } - -ex "c/@" { - if { - [lindex $::BASH_VERSINFO 0] == 4 && - [lindex $::BASH_VERSINFO 1] == 0 && - [lindex $::BASH_VERSINFO 2] < 35 - } {xfail "$test"} {fail "$test"} - } + -ex "c/@" { fail "$test" } } sync_after_int -set test {a b:c| with WORDBREAKS += : should return b:c (bash-3) or c (bash-4)}; # | = cursor position -if {[lindex $::BASH_VERSINFO 0] <= 3} { - set cmd {COMP_WORDS=(a "b:c"); COMP_CWORD=1} - set expected b:c -} else { - set cmd {add_comp_wordbreak_char :; COMP_WORDS=(a b : c); COMP_CWORD=3} - set expected c -} +set test {a b:c| with WORDBREAKS += : should return c}; # | = cursor position +set cmd {add_comp_wordbreak_char :; COMP_WORDS=(a b : c); COMP_CWORD=3} +set expected c append cmd {; COMP_LINE='a b:c'; COMP_POINT=5; _get_cword; echo} assert_bash_list $expected $cmd $test @@ -168,11 +135,7 @@ sync_after_int set test {a b:c| with WORDBREAKS -= : should return b:c}; # | = cursor position -if {[lindex $::BASH_VERSINFO 0] <= 3} { - set cmd {COMP_WORDS=(a "b:c"); COMP_CWORD=1} -} else { - set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3} -} +set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3} append cmd {; COMP_LINE='a b:c'; COMP_POINT=5; _get_cword :; echo} assert_bash_list b:c $cmd $test @@ -181,11 +144,7 @@ sync_after_int set test {a b c:| with WORDBREAKS -= : should return c:}; # | = cursor position -if {[lindex $::BASH_VERSINFO 0] <= 3} { - set cmd {COMP_WORDS=(a b c:); COMP_CWORD=2} -} else { - set cmd {COMP_WORDS=(a b c :); COMP_CWORD=3} -} +set cmd {COMP_WORDS=(a b c :); COMP_CWORD=3} append cmd {; COMP_LINE='a b c:'; COMP_POINT=6; _get_cword :; echo} assert_bash_list c: $cmd $test @@ -202,11 +161,7 @@ sync_after_int set test {a b::| with WORDBREAKS -= : should return b::}; # | = cursor position -if {[lindex $::BASH_VERSINFO 0] <= 3} { - set cmd {COMP_WORDS=(a "b::"); COMP_CWORD=1} -} else { - set cmd {COMP_WORDS=(a b ::); COMP_CWORD=2} -} +set cmd {COMP_WORDS=(a b ::); COMP_CWORD=2} append cmd {; COMP_LINE='a b::'; COMP_POINT=5; _get_cword :; echo} assert_bash_list b:: $cmd $test @@ -232,14 +187,9 @@ assert_bash_list c $cmd $test sync_after_int -set test {a b=c| should return b=c (bash-3) or c (bash-4)}; # | = cursor position -if {[lindex $::BASH_VERSINFO] <= 3} { - set cmd {COMP_WORDS=(a "b=c"); COMP_CWORD=1} - set expected b=c -} else { - set cmd {COMP_WORDS=(a b = c); COMP_CWORD=3} - set expected c -} +set test {a b=c| should return c}; # | = cursor position +set cmd {COMP_WORDS=(a b = c); COMP_CWORD=3} +set expected c append cmd {; COMP_LINE='a b=c'; COMP_POINT=5; _get_cword; echo} assert_bash_list $expected $cmd $test @@ -286,27 +236,13 @@ sync_after_int set test {a 'b&c| should return 'b&c}; # | = cursor position -if { - [lindex $::BASH_VERSINFO 0] == 4 && - [lindex $::BASH_VERSINFO 1] == 0 && - [lindex $::BASH_VERSINFO 2] < 35 -} { - set cmd {COMP_WORDS=(a "'" b "&" c); COMP_CWORD=4} -} else { - set cmd {COMP_WORDS=(a "'b&c"); COMP_CWORD=1} -} +set cmd {COMP_WORDS=(a "'b&c"); COMP_CWORD=1} append cmd {; COMP_LINE="a 'b&c"; COMP_POINT=6; _get_cword} send "$cmd\r" expect -ex "$cmd\r\n" expect { -ex "'b&c/@" { pass "$test" } - -ex "c/@" { - if { - [lindex $::BASH_VERSINFO 0] == 4 && - [lindex $::BASH_VERSINFO 1] == 0 && - [lindex $::BASH_VERSINFO 2] < 35 - } {xfail "$test"} {fail "$test"} - } + -ex "c/@" { fail "$test" } } |