about summary refs log tree commit diff
path: root/Test/53completion.ztst
blob: 2b6964fcb3fe405b4bcecd1914465d254031d7f9 (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
# Tests for completion system.

%prep
  zmodload -i zsh/zpty

  export ZTST_testdir ZTST_srcdir
  comptest () { $ZTST_testdir/../Src/zsh -f $ZTST_srcdir/comptest -z $ZTST_testdir/../Src/zsh -d $ZTST_testdir/compdump.tmp "$@" }

  mkdir comp.tmp
  cd comp.tmp

  mkdir dir1
  mkdir dir2
  touch file1
  touch file2

%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 -c '_users () { compadd user1 user2 }' $': ~\t\t\t\t\t'
0:tilde
>line: {: ~user}{}
>line: {: ~user}{}
>NO:{user1}
>NO:{user2}
>line: {: ~user1}{}
>line: {: ~user2}{}
>line: {: ~user1}{}

 code='compdef _tst tst; _tst () { _arguments ":desc1:(arg1)" }'
 comptest -c "$code" $'tst \t'
0:_arguments
>line: {tst arg1 }{}

 comptest -c "$code" $'tst a\t'
0:_arguments
>line: {tst arg1 }{}

 comptest -c "$code" $'tst ar\t'
0:_arguments
>line: {tst arg1 }{}

 comptest -c "$code" $'tst arg\t'
0:_arguments
>line: {tst arg1 }{}

 comptest -c "$code" $'tst arg1\t'
0:_arguments
>line: {tst arg1 }{}

 comptest -c "$code" $'tst r\t'
0:_arguments
>line: {tst r}{}

 comptest -c "$code" $'tst x\t'
0:_arguments
>line: {tst x}{}

 comptest -c "$code" $'tst a \t'
0:_arguments
>line: {tst a }{}
>MESSAGE:{no more arguments}

 comptest -c "$code" $'tst a b \t'
0:_arguments
>line: {tst a b }{}
>MESSAGE:{no more arguments}

 code='compdef _tst tst; _tst () { _arguments ":desc1:(a b)" }'
 comptest -c "$code" $'tst \t'
0:_arguments
>line: {tst }{}
>DESCRIPTION:{desc1}
>NO:{a}
>NO:{b}

 code='compdef _tst tst; _tst () { _arguments ":desc1:(arg1)" ":desc2:(arg2)" ":desc3:(arg3)" }'
 comptest -c "$code" $'tst \t'
0:_arguments
>line: {tst arg1 }{}

 comptest -c "$code" $'tst arg1 \t'
0:_arguments
>line: {tst arg1 arg2 }{}

 comptest -c "$code" $'tst arg1 arg2 \t'
0:_arguments
>line: {tst arg1 arg2 arg3 }{}

 comptest -c "$code" $'tst \C-D'
0:_arguments
>DESCRIPTION:{desc1}
>NO:{arg1}

 code='compdef _tst tst; _tst () { _arguments "-\+[opt]" }'
 comptest -c "$code" $'tst -\C-D'
0:_arguments
>DESCRIPTION:{option}
>NO:{-+ -- opt}

 code='compdef _tst tst; _tst () { _arguments "1:desc1:(arg1)" }'
 comptest -c "$code" $'tst \t'
0:_arguments
>line: {tst arg1 }{}

 code='compdef _tst tst; _tst () { _arguments "-x" ":arg:" }'
 comptest -c "$code" $'tst -\t'
0:_arguments
>line: {tst -x }{}

 code='compdef _tst tst; _tst () { _arguments "-x:arg:" }'
 comptest -c "$code" $'tst -x\t'
0:_arguments
>line: {tst -x }{}

 code='
   compdef _tst tst
   _tst () { _arguments "-a" "*::rest:_tst2" }
   _tst2 () { compadd - -b }
 '
 comptest -c "$code" $'tst arg -\t'
0:_arguments
>line: {tst arg -b }{}