~ubuntu-branches/ubuntu/trusty/bash-completion/trusty-updates

« back to all changes in this revision

Viewing changes to test/unit/_get_comp_words_by_ref.exp

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2012-07-23 16:07:59 UTC
  • mfrom: (5.1.12 sid)
  • Revision ID: package-import@ubuntu.com-20120723160759-lt9vn33dl3nak9l0
Tags: 1:2.0-1ubuntu1
* debian/maintscript, debian/postinst:
  - clean etc conffiles on upgrade since completion files are in /usr
    with the new version
* Resync with Debian, remaining diff
  * debian/patches/disable-avahi-browse.diff: Disable avahi-browse since
    it scales poorly in the current form: refresh patch
  * patches/101_bash_completion.oga_ogv.patch: Increase support for other
    OGG formats including .oga, .ogx, etc. (LP: #311525)
  * patches/103_colormake.patch: Add support for colormake to the make
    completion rules. (LP: #743208)
* Dropped changes:
  * Add conffile upgrade handling for a run of conffiles that were dropped
    since lucid: lucid upgrades are only supported to precise.
* Those fixes are in the new version
  * debian/patches/apt-get-changelog.patch:
  * Drop whitelists if they fail to produce any results:
  * patches/apt-get-download.patch: Add download as an apt-get
    sub-command (LP: #720541)
  * patches/102_manpager.patch: Override MANPAGER when generating perldoc
    completions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
sync_after_int
49
49
 
50
50
 
 
51
set test "|a";  # | = cursor position
 
52
set cmd {COMP_WORDS=(a); COMP_CWORD=0; COMP_LINE='a'; COMP_POINT=0; \
 
53
    unset cur prev; _get_comp_words_by_ref cur prev; echo "$cur $prev"}
 
54
assert_bash_list {" "} $cmd $test
 
55
 
 
56
 
 
57
sync_after_int
 
58
 
 
59
 
 
60
set test "|a \$";  # | = cursor position
 
61
set cmd {COMP_WORDS=(a); COMP_CWORD=0; COMP_LINE='a '; COMP_POINT=0; \
 
62
    unset cur prev; _get_comp_words_by_ref cur prev; echo "$cur $prev"}
 
63
assert_bash_list {" "} $cmd $test
 
64
 
 
65
 
 
66
sync_after_int
 
67
 
 
68
 
 
69
set test " | a \$";  # | = cursor position
 
70
set cmd {COMP_WORDS=(a); COMP_CWORD=0; COMP_LINE='  a '; COMP_POINT=1; \
 
71
    unset cur prev; _get_comp_words_by_ref cur prev; echo "$cur $prev"}
 
72
assert_bash_list {" "} $cmd $test
 
73
 
 
74
 
 
75
sync_after_int
 
76
 
 
77
 
51
78
set test "a b |";  # | = cursor position
52
79
set cmd {COMP_WORDS=(a b ''); COMP_CWORD=2; COMP_LINE='a b '; COMP_POINT=4; _get_comp_words_by_ref cur prev; echo "$cur $prev"}
53
80
assert_bash_list {" b"} $cmd $test
72
99
sync_after_int
73
100
 
74
101
 
 
102
set test "a | b";  # | = cursor position
 
103
set cmd {COMP_WORDS=(a b); COMP_CWORD=1; COMP_LINE='a  b'; COMP_POINT=2; _get_comp_words_by_ref cur prev; echo "$cur $prev"}
 
104
assert_bash_list {" a"} $cmd $test
 
105
 
 
106
 
 
107
sync_after_int
 
108
 
 
109
 
75
110
set test {a b\ c| should return b\ c};  # | = cursor position
76
111
set cmd {COMP_WORDS=(a 'b\ c'); COMP_CWORD=1; COMP_LINE='a b\ c'; COMP_POINT=6; _get_comp_words_by_ref cur prev; echo "$cur $prev"}
77
112
assert_bash_list {"b\\ c a"} $cmd $test
80
115
sync_after_int
81
116
 
82
117
 
 
118
set test {a\ b a\ b| should return a\ b};  # | = cursor position
 
119
set cmd {COMP_WORDS=('a\ b' 'a\ b'); COMP_CWORD=1; COMP_LINE='a\ b a\ b'; COMP_POINT=9; _get_comp_words_by_ref cur prev; echo "$cur $prev"}
 
120
assert_bash_list {"a\\ b a\\ b"} $cmd $test
 
121
 
 
122
 
 
123
sync_after_int
 
124
 
 
125
 
83
126
set test {a b\| c should return b\ };  # | = cursor position
84
127
set cmd {COMP_WORDS=(a 'b\ c'); COMP_CWORD=1; COMP_LINE='a b\ c'; COMP_POINT=4; _get_comp_words_by_ref cur prev; echo "$cur $prev"}
85
128
assert_bash_list {"b\\ a"} $cmd $test
97
140
 
98
141
 
99
142
set test {a 'b c|};  # | = cursor position
100
 
if {
101
 
    [lindex $::BASH_VERSINFO 0] == 4 && 
102
 
    [lindex $::BASH_VERSINFO 1] == 0 &&
103
 
    [lindex $::BASH_VERSINFO 2] < 35
104
 
} {
105
 
    set cmd {COMP_WORDS=(a "'" b c); COMP_CWORD=3}
106
 
} else {
107
 
    set cmd {COMP_WORDS=(a "'b c"); COMP_CWORD=1}
108
 
}
 
143
set cmd {COMP_WORDS=(a "'b c"); COMP_CWORD=1}
109
144
append cmd {; COMP_LINE="a 'b c"; COMP_POINT=6; _get_comp_words_by_ref cur prev; echo "$cur $prev"}
110
145
send "$cmd\r"
111
146
expect -ex "$cmd\r\n"
112
147
expect {
113
148
    -ex "'b c a\r\n/@" { pass "$test" }
114
 
    -ex "c b\r\n/@" { 
115
 
        if {
116
 
            [lindex $::BASH_VERSINFO 0] == 4 &&
117
 
            [lindex $::BASH_VERSINFO 1] == 0 &&
118
 
            [lindex $::BASH_VERSINFO 2] < 35
119
 
        } {xfail "$test"} {fail "$test"}
120
 
    }
 
149
    -ex "c b\r\n/@" { fail "$test" }
121
150
}
122
151
 
123
152
 
125
154
 
126
155
 
127
156
set test {a "b c|};  #"# | = cursor position
128
 
if {
129
 
    [lindex $::BASH_VERSINFO 0] == 4 && 
130
 
    [lindex $::BASH_VERSINFO 1] == 0 &&
131
 
    [lindex $::BASH_VERSINFO 2] < 35
132
 
} {
133
 
    set cmd {COMP_WORDS=(a "\"" b c); COMP_CWORD=3}
134
 
} else {
135
 
    set cmd {COMP_WORDS=(a "\"b c"); COMP_CWORD=1}
136
 
}
 
157
set cmd {COMP_WORDS=(a "\"b c"); COMP_CWORD=1}
137
158
append cmd {; COMP_LINE="a \"b c"; COMP_POINT=6}
138
159
assert_bash_exec $cmd
139
160
set cmd {_get_comp_words_by_ref cur prev; echo "$cur $prev"};
141
162
expect -ex "$cmd\r\n"
142
163
expect {
143
164
    -ex "\"b c a\r\n/@" { pass "$test" }
144
 
    -ex "c b\r\n/@" {
145
 
        if {
146
 
            [lindex $::BASH_VERSINFO 0] == 4 &&
147
 
            [lindex $::BASH_VERSINFO 1] == 0 &&
148
 
            [lindex $::BASH_VERSINFO 2] < 35
149
 
        } {xfail "$test"} {fail "$test"}
150
 
    }
 
165
    -ex "c b\r\n/@" { fail "$test" }
151
166
}
152
167
 
153
168
 
155
170
 
156
171
 
157
172
set test {a b:c| with WORDBREAKS += :};  # | = cursor position
158
 
if {[lindex $::BASH_VERSINFO 0] <= 3} {
159
 
    set cmd {COMP_WORDS=(a "b:c"); COMP_CWORD=1}
160
 
    set expected {"b:c a"}
161
 
} else {
162
 
    set cmd {add_comp_wordbreak_char :; COMP_WORDS=(a b : c); COMP_CWORD=3}
163
 
    set expected {"c :"}
164
 
}
 
173
set cmd {add_comp_wordbreak_char :; COMP_WORDS=(a b : c); COMP_CWORD=3}
 
174
set expected {"c :"}
165
175
append cmd {; COMP_LINE='a b:c'; COMP_POINT=5}
166
176
# NOTE: Split-send cmd to prevent backspaces (\008) in output
167
177
assert_bash_exec $cmd $test
173
183
 
174
184
 
175
185
set test {a b:c| with WORDBREAKS -= :};  # | = cursor position
176
 
if {[lindex $::BASH_VERSINFO 0] <= 3} {
177
 
    set cmd {COMP_WORDS=(a "b:c"); COMP_CWORD=1}
178
 
} else {
179
 
    set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3}
180
 
}
 
186
set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3}
181
187
append cmd {; COMP_LINE='a b:c'; COMP_POINT=5}
182
188
assert_bash_exec $cmd $test
183
189
set cmd {_get_comp_words_by_ref -n : cur prev; echo "$cur $prev"}
188
194
 
189
195
 
190
196
set test {a b c:| with WORDBREAKS -= :};  # | = cursor position
191
 
if {[lindex $::BASH_VERSINFO 0] <= 3} {
192
 
    set cmd {COMP_WORDS=(a b c:); COMP_CWORD=2}
193
 
} else {
194
 
    set cmd {COMP_WORDS=(a b c :); COMP_CWORD=3}
195
 
}
 
197
set cmd {COMP_WORDS=(a b c :); COMP_CWORD=3}
196
198
append cmd {; COMP_LINE='a b c:'; COMP_POINT=6}
197
199
assert_bash_exec $cmd $test
198
200
set cmd {_get_comp_words_by_ref -n : cur prev; echo "$cur $prev"}
203
205
 
204
206
 
205
207
set test {a b:c | with WORDBREAKS -= :};  # | = cursor position
206
 
if {[lindex $::BASH_VERSINFO 0] <= 3} {
207
 
    set cmd {COMP_WORDS=(a b:c ''); COMP_CWORD=2}
208
 
} else {
209
 
    set cmd {COMP_WORDS=(a b : c ''); COMP_CWORD=4}
210
 
}
 
208
set cmd {COMP_WORDS=(a b : c ''); COMP_CWORD=4}
211
209
append cmd {; COMP_LINE='a b:c '; COMP_POINT=6}
212
210
assert_bash_exec $cmd $test
213
211
set cmd {_get_comp_words_by_ref -n : cur prev; echo "$cur $prev"}
228
226
 
229
227
 
230
228
set test {a b::| with WORDBREAKS -= : should return b::};  # | = cursor position
231
 
if {[lindex $::BASH_VERSINFO 0] <= 3} {
232
 
    set cmd {COMP_WORDS=(a "b::"); COMP_CWORD=1}
233
 
} else {
234
 
    set cmd {COMP_WORDS=(a b ::); COMP_CWORD=2}
235
 
}
 
229
set cmd {COMP_WORDS=(a b ::); COMP_CWORD=2}
236
230
append cmd {; COMP_LINE='a b::'; COMP_POINT=5}
237
231
assert_bash_exec $cmd
238
232
set cmd {_get_comp_words_by_ref -n : cur prev; echo "$cur $prev"}
264
258
sync_after_int
265
259
 
266
260
 
267
 
set test {a b=c| should return b=c (bash-3) or c (bash-4)};  # | = cursor position
268
 
if {[lindex $::BASH_VERSINFO] <= 3} {
269
 
    set cmd {COMP_WORDS=(a "b=c"); COMP_CWORD=1}
270
 
    set expected b=c
271
 
} else {
272
 
    set cmd {COMP_WORDS=(a b = c); COMP_CWORD=3}
273
 
    set expected c
274
 
}
 
261
set test {a b=c| should return c};  # | = cursor position
 
262
set cmd {COMP_WORDS=(a b = c); COMP_CWORD=3}
 
263
set expected c
275
264
append cmd {; COMP_LINE='a b=c'; COMP_POINT=5}
276
265
assert_bash_exec $cmd
277
266
set cmd {_get_comp_words_by_ref cur prev; echo "$cur"}
325
314
 
326
315
 
327
316
set test {a 'b&c| should return 'b&c};  # | = cursor position
328
 
if {
329
 
    [lindex $::BASH_VERSINFO 0] == 4 && 
330
 
    [lindex $::BASH_VERSINFO 1] == 0 &&
331
 
    [lindex $::BASH_VERSINFO 2] < 35
332
 
} {
333
 
    set cmd {COMP_WORDS=(a "'" b "&" c); COMP_CWORD=4}
334
 
} else {
335
 
    set cmd {COMP_WORDS=(a "'b&c"); COMP_CWORD=1}
336
 
}
 
317
set cmd {COMP_WORDS=(a "'b&c"); COMP_CWORD=1}
337
318
append cmd {; COMP_LINE="a 'b&c"; COMP_POINT=6}
338
319
assert_bash_exec $cmd
339
320
set cmd {_get_comp_words_by_ref cur prev; printf %s "$cur"}
341
322
expect -ex "$cmd\r\n"
342
323
expect {
343
324
    -ex "'b&c/@" { pass "$test" }
344
 
    -ex "c/@" { 
345
 
        if {
346
 
            [lindex $::BASH_VERSINFO 0] == 4 &&
347
 
            [lindex $::BASH_VERSINFO 1] == 0 &&
348
 
            [lindex $::BASH_VERSINFO 2] < 35
349
 
        } {xfail "$test"} {fail "$test"}
350
 
    }
 
325
    -ex "c/@" { fail "$test" }
351
326
}
352
327
 
353
328
 
398
373
sync_after_int
399
374
 
400
375
 
 
376
set test {a b : c| with WORDBREAKS -= :};  # | = cursor position
 
377
set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3; COMP_LINE='a b : c'; COMP_POINT=7}
 
378
assert_bash_exec $cmd $test
 
379
set cmd {_get_comp_words_by_ref -n : words; echo "${words[@]}"}
 
380
assert_bash_list {"a b : c"} $cmd $test
 
381
 
 
382
 
 
383
sync_after_int
 
384
 
 
385
 
 
386
set test {a b: c| with WORDBREAKS -= :};  # | = cursor position
 
387
set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3}
 
388
append cmd {; COMP_LINE='a b: c'; COMP_POINT=6}
 
389
assert_bash_exec $cmd $test
 
390
set cmd {_get_comp_words_by_ref -n : words; echo "${words[@]}"}
 
391
assert_bash_list {"a b: c"} $cmd $test
 
392
 
 
393
 
 
394
sync_after_int
 
395
 
 
396
 
 
397
set test {a b :c| with WORDBREAKS -= :};  # | = cursor position
 
398
set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3}
 
399
append cmd {; COMP_LINE='a b :c'; COMP_POINT=6}
 
400
assert_bash_exec $cmd $test
 
401
set cmd {_get_comp_words_by_ref -n : words; echo "${words[@]}"}
 
402
assert_bash_list {"a b :c"} $cmd $test
 
403
 
 
404
 
 
405
sync_after_int
 
406
 
 
407
 
 
408
set test {a b\ :c| with WORDBREAKS -= :};  # | = cursor position
 
409
set cmd {COMP_WORDS=(a "b\\ " : c); COMP_CWORD=3}
 
410
append cmd {; COMP_LINE='a b\ :c'; COMP_POINT=7}
 
411
assert_bash_exec $cmd $test
 
412
set cmd {_get_comp_words_by_ref -n : words; echo "${words[@]}"}
 
413
assert_bash_list {a "b\\ :c"} $cmd $test
 
414
 
 
415
 
 
416
sync_after_int
 
417
 
 
418
 
401
419
teardown