about summary refs log tree commit diff
path: root/Test/Y01completion.ztst
blob: fc18b19a4c9ca78e8f2880e1ff1806a2efff3423 (plain) (blame)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
# Tests for completion system.

%prep
  ZSH_TEST_LANG=$(ZTST_find_UTF8)
  if ( zmodload zsh/zpty 2>/dev/null ); then
    . $ZTST_srcdir/comptest
    mkdir comp.tmp
    cd comp.tmp
    comptestinit -z $ZTST_testdir/../Src/zsh &&
    {
      comptesteval 'compdef _tst tst'
      mkdir dir1 &&
      mkdir dir2 &&
      touch file1 &&
      touch file2
    }
  else
    ZTST_unimplemented="the zsh/zpty module is not available"
  fi

%test

  comptest $': \t\t\t\t\t\t\t'
0:directories and files
>line: {: }{}
>DESCRIPTION:{file}
>DI:{dir1}
>DI:{dir2}
>FI:{file1}
>FI:{file2}
>line: {: dir1/}{}
>line: {: dir2/}{}
>line: {: file1}{}
>line: {: file2}{}
>line: {: dir1/}{}
>line: {: dir2/}{}

  comptest $': d\t\t\t\t\t \t'
0:unambiguous prefix and autoremovable suffix
>line: {: dir}{}
>line: {: dir}{}
>DESCRIPTION:{file}
>DI:{dir1}
>DI:{dir2}
>line: {: dir1/}{}
>line: {: dir2/}{}
>line: {: dir1/}{}
>line: {: dir1 }{}
>DESCRIPTION:{file}
>DI:{dir1}
>DI:{dir2}
>FI:{file1}
>FI:{file2}

  comptest $': suf\ebd\t\t\t\t\t \t'
0:unambiguous prefix and autoremovable suffix with _prefix completer
>line: {: dir}{suf}
>line: {: dir}{suf}
>DESCRIPTION:{file}
>DI:{dir1}
>DI:{dir2}
>line: {: dir1/}{suf}
>line: {: dir2/}{suf}
>line: {: dir1/}{suf}
>line: {: dir1 }{suf}
>DESCRIPTION:{file}
>DI:{dir1}
>DI:{dir2}
>FI:{file1}
>FI:{file2}
F:regression test workers/51641

  comptesteval 'comptest-postfunc() { compstate[insert]=1 compstate[list]= }'
  comptest $': \t \t'
0:compstate[insert]=1 compstate[list]=
>line: {: dir1/}{}
>line: {: dir1 dir1/}{}

  comptest $': suf\eb\t \t'
0:compstate[insert]=1 compstate[list]= with _prefix completer
>line: {: dir1/}{suf}
>line: {: dir1 dir1/}{suf}
F:regression test workers/51641

  comptesteval 'comptest-postfunc() {}'
  comptest $': *\t\t\t\t\t\t'
0:_expand shows file types
>line: {: dir1/}{}
>DESCRIPTION:{expansions}
>DI:{dir1}
>DI:{dir2}
>FI:{file1}
>FI:{file2}
>DESCRIPTION:{all expansions}
>NO:{dir1 dir2 file1 file2}
>DESCRIPTION:{original}
>NO:{*}
>line: {: dir2/}{}
>line: {: file1 }{}
>line: {: file2 }{}
>line: {: dir1 dir2 file1 file2 }{}
>line: {: *}{}

  comptesteval $'zstyle \'*\' glob no'
  comptesteval $'typeset -g tst=(*)'
  comptest $': $tst\C-D'
0:_expand preserves array form
>DESCRIPTION:{expansions}
>NO:{dir1}
>NO:{dir2}
>NO:{file1}
>NO:{file2}

  comptesteval $'zstyle -d \'*\' glob'
  comptesteval '_users () { compadd user1 user2 }'
  comptest $': ~\t\t\t\t\t'
0:tilde
>line: {: ~user}{}
>line: {: ~user}{}
>NO:{user1}
>NO:{user2}
>line: {: ~user1}{}
>line: {: ~user2}{}
>line: {: ~user1}{}

  comptesteval 'zsh_directory_name() { compadd "$expl[@]" -- name/1 name2 }'
  comptest $': ~[\t\t\t\t'
0:dynamic directory names after ~[
>line: {: ~[name}{}
>line: {: ~[name}{}
>DESCRIPTION:{dynamically named directory}
>NO:{name/1}
>NO:{name2}
>line: {: ~[name/1]}{}
>line: {: ~[name2]}{}

  comptest $': ~[]\C-b\t\t\t\t'
0:dynamic directory names inside ~[...]
>line: {: ~[name}{]}
>line: {: ~[name}{]}
>DESCRIPTION:{dynamically named directory}
>NO:{name/1}
>NO:{name2}
>line: {: ~[name/1}{]}
>line: {: ~[name2}{]}

  comptest $'echo ;:\C-b\C-b\t'
0:directories and files before separator
>line: {echo }{;:}
>DESCRIPTION:{file}
>DI:{dir1}
>DI:{dir2}
>FI:{file1}
>FI:{file2}

  # Temporarily modify format set in comptest
  comptesteval 'zstyle -s ":completion:*:descriptions" format oldfmt'
  comptesteval 'zstyle ":completion:*:descriptions" format \
    ${oldfmt/>*</>%5F123abc%f %B123abc%b<}'
  comptest $': \t'
  comptesteval 'zstyle ":completion:*:descriptions" format $oldfmt'
0:custom description with formatting sequences
>line: {: }{}
*>DESCRIPTION:{*123abc*123abc*~*F123*}
>DI:{dir1}
>DI:{dir2}
>FI:{file1}
>FI:{file2}
F:regression test workers/42164

# Depends on path assignment in comptestinit
  comptesteval "path=( $ZTST_srcdir:A )"
  comptest $'zt\t'
0:command
>line: {ztst.zsh }{}

  comptesteval "path=( $ZTST_srcdir:A )"
  comptest $':;zt\t'
0:command after separator
>line: {:;ztst.zsh }{}
F:regression test workers/32182

  comptest $'for f in 1; do < x\C-b\C-b\t'
0:redirection after "for ...; do"
>line: {for f in 1; do <}{ x}
>DESCRIPTION:{file}
>DI:{dir1}
>DI:{dir2}
>FI:{file1}
>FI:{file2}
F:regression test workers/31611

  {
    mkdir 'A(B)' 'A(B)/C'
    comptest $'cd "A(B)\t\t'
    comptesteval 'cd "A(B)/C"'
    comptest $'cd ../\t'
  } always {
    comptesteval 'cd -' # Reset CWD
    rmdir 'A(B)/C' 'A(B)'
  }
0:directory name is not a glob qualifier
>line: {cd "A(B)/}{}
>line: {cd "A(B)/C/}{}
>line: {cd ../C/}{}

  comptesteval '_tst() { compset -p 1; _message "${(qq)IPREFIX} ${(qq)PREFIX}" }'
  comptest $'tst .\t'
0:remove exact number of characters from a prefix
>line: {tst .}{}
>MESSAGE:{'.' ''}

  comptesteval '_tst() { compset -s 3; _message "${(qq)SUFFIX} ${(qq)ISUFFIX}" }'
  comptest $'tst 123\eb\t'
0:remove exact number of characters from a suffix
>line: {tst }{123}
>MESSAGE:{'' '123'}

  comptesteval '_tst() { compset -p 2; compset -p 3;compset -s 2;compset -s 3; _message "${(qq)PREFIX} ${(qq)SUFFIX}" }'
  comptest $'tst 12345678\e4\C-b\t'
0:try to remove excess characters from prefix and suffix
>line: {tst 1234}{5678}
>MESSAGE:{'34' '56'}

  if [[ -z $ZSH_TEST_LANG ]]; then
    ZTST_skip="no UTF-8 locale for multibyte completion test"
  else
    comptesteval '_tst() { compset -p 1; _message "${(qq)IPREFIX} ${(qq)PREFIX}" }'
    comptest $'tst €100\t'
  fi
0:remove multibyte character from a prefix
>line: {tst €100}{}
>MESSAGE:{'€' '100'}

  comptesteval "_tst() { compadd -U -s : -S / -I . word; compstate[to_end]= }"
  comptest $'tst .\C-b\t'
0:allow for suffixes when moving cursor to end of match (with ignored suffix)
>line: {tst word:/}{.}

  comptesteval "_tst() { compadd -s : -S / word; compstate[to_end]= }"
  comptest $'tst \t'
0:allow for suffixes when moving cursor to end of match (without ignored suffix)
>line: {tst word:/}{}

# Test for regression introduced by workers/41242, raised in workers/43842
  if [[ $OSTYPE = cygwin ]]; then
    ZTST_skip="\\ is equivalent to / in pathname on cygwin"
  else
  {
    mkdir sortnobslash
    touch sortnobslash/{'!foo','#foo','\foo','|foo','~foo',Afoo,bfoo}
    comptesteval 'old_LC_ALL=$LC_ALL; LC_ALL=C'
    comptest $': sortnobslash/\t'
  } always {
    comptesteval 'LC_ALL=$old_LC_ALL'
    rm -rf sortnobslash
  }
  fi
0:ignore backslashes when sorting completion matches
>line: {: sortnobslash/}{}
>DESCRIPTION:{file}
>FI:{\!foo}
>FI:{\#foo}
>FI:{Afoo}
>FI:{\\foo}
>FI:{bfoo}
>FI:{\|foo}
>FI:{\~foo}

  comptesteval "_tst() { compadd -onum,rev -J versions r1.10 r1.1 r1.2 r2.3 r2.34 }"
  comptest $'tst r\t'
0:reverse numeric sorting of matches
>line: {tst r}{}
>NO:{r2.34}
>NO:{r2.3}
>NO:{r1.10}
>NO:{r1.2}
>NO:{r1.1}

  comptesteval "_tst() { local expl; _wanted times expl time compadd -o match r1.10 r1.2 r2.3 r2.34 }"
  comptesteval "zstyle ':completion:*:tst:*' sort reverse numeric"
  comptest $'tst r\t'
0:reverse numeric sorting of matches via a style
>line: {tst r}{}
>DESCRIPTION:{time}
>NO:{r2.34}
>NO:{r2.3}
>NO:{r1.10}
>NO:{r1.2}

  comptesteval "_tst() { local disp=(a b c); compadd -o -J letters -d disp 3 2 1 }"
  comptest $'tst \t'
0:sort in match rather than display name order
>line: {tst }{}
>NO:{c}
>NO:{b}
>NO:{a}

  comptesteval "_tst() { local expl; _wanted times expl time compadd 3am 12pm 3pm 10pm }"
  comptesteval "zstyle ':completion:*:tst:*' sort false"
  comptest $'tst \t'
0:sorting disabled via the sort style
>line: {tst }{}
>DESCRIPTION:{time}
>NO:{3am}
>NO:{12pm}
>NO:{3pm}
>NO:{10pm}

  comptesteval "_tst() { _arguments ':desc:_sequence compadd - 1 2 3' }"
  comptesteval "zstyle ':completion:*:tst:*' ignored-patterns 2"
  comptest $'tst 1,\t'
  comptesteval "zstyle -d ':completion:*:tst:*' ignored-patterns"
0:-F does not break _sequence
>line: {tst 1,}{}
>DESCRIPTION:{desc}
>NO:{2}
>NO:{3}

 comptest $'a=() b=(\t'
0:multiple envarrays
>line: {a=() b=(}{}
>DESCRIPTION:{file}
>DI:{dir1}
>DI:{dir2}
>FI:{file1}
>FI:{file2}

  comptesteval "typeset -a bar=({$'\\0'..$'\\C-?'})"
  comptesteval 'typeset -A bat=( "$bar[@]" )'
  comptesteval 'typeset bay="$bar"'
  comptesteval 'zstyle ":completion:*:parameters" verbose yes'
  comptesteval 'zstyle ":completion:*" fake-parameters bar bat bay'
  comptest $': $ba\t'
0:verbose shows parameter values
>line: {: $ba}{}
>DESCRIPTION:{parameter}
>NO:{bar  -- ( '^@' '^A' '^B' '^C' '^D' '^E' '^F' '^G' '^H' '\t' '\n' '^K' '^L' '}
>NO:{bat  -- ( [' ']='!' ['"']='#' ['$']=% ['&']=\' ['(']=')' ['*']=+ [,]=- [.]=/}
>NO:{bay  -- '^@ ^A ^B ^C ^D ^E ^F ^G ^H \t \n ^K ^L ^M ^N ^O ^P ^Q ^R ^S ^T ^U ^}

  comptesteval "path=( $ZTST_srcdir:A )"
  comptesteval 'typeset -H paths=HIDDEN'
  comptest $': $path\t'
0:verbose doesn't show special or hidden parameter values
>line: {: $path}{}
>DESCRIPTION:{parameter}
>NO:{path}
>NO:{paths}

  comptesteval 'zstyle -d ":completion:*:parameters" verbose'
  comptest $': $ba\t'
0:parameter values not shown without verbose
>line: {: $ba}{}
>DESCRIPTION:{parameter}
>NO:{bar}
>NO:{bat}
>NO:{bay}

  comptesteval '_tst() { local disp=( {a..z} ); compadd -ld disp $disp[@]; comppostfuncs=( _pst ) }'
  comptesteval '_pst() { local disp=( "<INSERT>$compstate[insert]</INSERT>" ); compadd -Qld disp $disp }'
  comptesteval "zstyle ':completion:*' menu select=long-list"
  # This test is sensitive to sorting differences across platforms
  comptesteval 'export LC_ALL=C'
  comptest $'tst \C-d'
  comptesteval "export LC_ALL=${(q)ZSH_TEST_LANG}"
0: menu select=long-list starts menu selection for list widgets
>NO:{<INSERT>menu</INSERT>}
>NO:{a}
>NO:{b}
>NO:{c}
>NO:{d}
>NO:{e}
>NO:{f}
>NO:{g}
>NO:{h}
>NO:{i}
>NO:{j}
>NO:{k}
>NO:{l}
>NO:{m}
>NO:{n}
>NO:{o}
>NO:{p}
>NO:{q}
>NO:{r}
>NO:{s}
>NO:{t}
>NO:{u}
>NO:{v}
>NO:{w}
>NO:{x}
>NO:{y}
>NO:{z}


%clean

  zmodload -ui zsh/zpty