xref: /vim-8.2.3635/src/testdir/gen_opt_test.vim (revision 8ea05de6)
1" Script to generate testdir/opt_test.vim from option.c
2
3set cpo=&vim
4
5" Only do this when build with the +eval feature.
6if 1
7
8set nomore
9
10" The terminal size is restored at the end.
11" Clear out t_WS, we don't want to resize the actual terminal.
12let script = [
13      \ '" DO NOT EDIT: Generated with gen_opt_test.vim',
14      \ '',
15      \ 'let save_columns = &columns',
16      \ 'let save_lines = &lines',
17      \ 'let save_term = &term',
18      \ 'set t_WS=',
19      \ ]
20
21/#define p_term
22let end = line('.')
23
24" font name that works everywhere (hopefully)
25let fontname = has('win32') ? 'fixedsys' : 'fixed'
26
27" Two lists with values: values that work and values that fail.
28" When not listed, "othernum" or "otherstring" is used.
29let test_values = {
30      \ 'cmdheight': [[1, 2, 10], [-1, 0]],
31      \ 'cmdwinheight': [[1, 2, 10], [-1, 0]],
32      \ 'columns': [[12, 80], [-1, 0, 10]],
33      \ 'conceallevel': [[0, 1, 2, 3], [-1, 4, 99]],
34      \ 'foldcolumn': [[0, 1, 4, 12], [-1, 13, 999]],
35      \ 'helpheight': [[0, 10, 100], [-1]],
36      \ 'history': [[0, 1, 100], [-1, 10001]],
37      \ 'iminsert': [[0, 1], [-1, 3, 999]],
38      \ 'imsearch': [[-1, 0, 1], [-2, 3, 999]],
39      \ 'imstyle': [[0, 1], [-1, 2, 999]],
40      \ 'lines': [[2, 24], [-1, 0, 1]],
41      \ 'linespace': [[0, 2, 4], ['']],
42      \ 'numberwidth': [[1, 4, 8, 10, 11, 20], [-1, 0, 21]],
43      \ 'regexpengine': [[0, 1, 2], [-1, 3, 999]],
44      \ 'report': [[0, 1, 2, 9999], [-1]],
45      \ 'scroll': [[0, 1, 2, 20], [-1]],
46      \ 'scrolljump': [[-50, -1, 0, 1, 2, 20], [999]],
47      \ 'scrolloff': [[0, 1, 2, 20], [-1]],
48      \ 'shiftwidth': [[0, 1, 8, 999], [-1]],
49      \ 'sidescroll': [[0, 1, 8, 999], [-1]],
50      \ 'sidescrolloff': [[0, 1, 8, 999], [-1]],
51      \ 'tabstop': [[1, 4, 8, 12], [-1, 0]],
52      \ 'textwidth': [[0, 1, 8, 99], [-1]],
53      \ 'timeoutlen': [[0, 8, 99999], [-1]],
54      \ 'titlelen': [[0, 1, 8, 9999], [-1]],
55      \ 'updatecount': [[0, 1, 8, 9999], [-1]],
56      \ 'updatetime': [[0, 1, 8, 9999], [-1]],
57      \ 'verbose': [[-1, 0, 1, 8, 9999], []],
58      \ 'wildcharm': [[-1, 0, 100], []],
59      \ 'winheight': [[1, 10, 999], [-1, 0]],
60      \ 'winminheight': [[0, 1], [-1]],
61      \ 'winminwidth': [[0, 1, 10], [-1]],
62      \ 'winwidth': [[1, 10, 999], [-1, 0]],
63      \
64      \ 'ambiwidth': [['', 'single'], ['xxx']],
65      \ 'background': [['', 'light', 'dark'], ['xxx']],
66      \ 'backspace': [[0, 2, 3, '', 'eol', 'eol,start', 'indent,eol,nostop'], ['4', 'xxx']],
67      \ 'backupcopy': [['yes', 'auto'], ['', 'xxx', 'yes,no']],
68      \ 'backupext': [['xxx'], ['']],
69      \ 'belloff': [['', 'all', 'copy,error'], ['xxx']],
70      \ 'breakindentopt': [['', 'min:3', 'sbr'], ['xxx', 'min', 'min:x']],
71      \ 'browsedir': [['', 'last', '/'], ['xxx']],
72      \ 'bufhidden': [['', 'hide', 'wipe'], ['xxx', 'hide,wipe']],
73      \ 'buftype': [['', 'help', 'nofile'], ['xxx', 'help,nofile']],
74      \ 'casemap': [['', 'internal'], ['xxx']],
75      \ 'cedit': [['', '\<Esc>'], ['xxx', 'f']],
76      \ 'clipboard': [['', 'unnamed', 'autoselect,unnamed', 'html', 'exclude:vimdisplay'], ['xxx', '\ze*', 'exclude:\\%(']],
77      \ 'colorcolumn': [['', '8', '+2'], ['xxx']],
78      \ 'comments': [['', 'b:#'], ['xxx']],
79      \ 'commentstring': [['', '/*%s*/'], ['xxx']],
80      \ 'complete': [['', 'w,b'], ['xxx']],
81      \ 'concealcursor': [['', 'n', 'nvic'], ['xxx']],
82      \ 'completeopt': [['', 'menu', 'menu,longest'], ['xxx', 'menu,,,longest,']],
83      \ 'completepopup': [['', 'height:13', 'highlight:That', 'width:10,height:234,highlight:Mine'], ['height:yes', 'width:no', 'xxx', 'xxx:99', 'border:maybe', 'border:1']],
84      \ 'completeslash': [['', 'slash', 'backslash'], ['xxx']],
85      \ 'cryptmethod': [['', 'zip'], ['xxx']],
86      \ 'cscopequickfix': [['', 's-', 's-,c+,e0'], ['xxx', 's,g,d']],
87      \ 'cursorlineopt': [['both', 'line', 'number', 'screenline', 'line,number'], ['', 'xxx', 'line,screenline']],
88      \ 'debug': [['', 'msg', 'msg', 'beep'], ['xxx']],
89      \ 'diffopt': [['', 'filler', 'icase,iwhite'], ['xxx', 'algorithm:xxx', 'algorithm:']],
90      \ 'display': [['', 'lastline', 'lastline,uhex'], ['xxx']],
91      \ 'eadirection': [['', 'both', 'ver'], ['xxx', 'ver,hor']],
92      \ 'encoding': [['latin1'], ['xxx', '']],
93      \ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter'], ['xxx']],
94      \ 'fileencoding': [['', 'latin1', 'xxx'], []],
95      \ 'fileformat': [['', 'dos', 'unix'], ['xxx']],
96      \ 'fileformats': [['', 'dos', 'dos,unix'], ['xxx']],
97      \ 'fillchars': [['', 'vert:x'], ['xxx']],
98      \ 'foldclose': [['', 'all'], ['xxx']],
99      \ 'foldmethod': [['manual', 'indent'], ['', 'xxx', 'expr,diff']],
100      \ 'foldopen': [['', 'all', 'hor,jump'], ['xxx']],
101      \ 'foldmarker': [['((,))'], ['', 'xxx']],
102      \ 'formatoptions': [['', 'vt', 'v,t'], ['xxx']],
103      \ 'guicursor': [['', 'n:block-Cursor'], ['xxx']],
104      \ 'guifont': [['', fontname], []],
105      \ 'guifontwide': [['', fontname], []],
106      \ 'guifontset': [['', fontname], []],
107      \ 'helplang': [['', 'de', 'de,it'], ['xxx']],
108      \ 'highlight': [['', 'e:Error'], ['xxx']],
109      \ 'imactivatekey': [['', 'S-space'], ['xxx']],
110      \ 'isfname': [['', '@', '@,48-52'], ['xxx', '@48']],
111      \ 'isident': [['', '@', '@,48-52'], ['xxx', '@48']],
112      \ 'iskeyword': [['', '@', '@,48-52'], ['xxx', '@48']],
113      \ 'isprint': [['', '@', '@,48-52'], ['xxx', '@48']],
114      \ 'keymap': [['', 'accents'], ['xxx']],
115      \ 'keymodel': [['', 'startsel', 'startsel,stopsel'], ['xxx']],
116      \ 'langmap': [['', 'xX', 'aA,bB'], ['xxx']],
117      \ 'listchars': [['', 'eol:x', 'eol:x,space:y'], ['xxx']],
118      \ 'matchpairs': [['', '(:)', '(:),<:>'], ['xxx']],
119      \ 'mkspellmem': [['10000,100,12'], ['', 'xxx']],
120      \ 'mouse': [['', 'a', 'nvi'], ['xxx', 'n,v,i']],
121      \ 'mousemodel': [['', 'popup'], ['xxx']],
122      \ 'mouseshape': [['', 'n:arrow'], ['xxx']],
123      \ 'nrformats': [['', 'alpha', 'alpha,hex,bin'], ['xxx']],
124      \ 'previewpopup': [['', 'height:13', 'width:10,height:234'], ['height:yes', 'xxx', 'xxx:99']],
125      \ 'printmbfont': [['', 'r:some', 'b:Bold,c:yes'], ['xxx']],
126      \ 'printoptions': [['', 'header:0', 'left:10pc,top:5pc'], ['xxx']],
127      \ 'scrollopt': [['', 'ver', 'ver,hor'], ['xxx']],
128      \ 'renderoptions': [[''], ['xxx']],
129      \ 'selection': [['old', 'inclusive'], ['', 'xxx']],
130      \ 'selectmode': [['', 'mouse', 'key,cmd'], ['xxx']],
131      \ 'sessionoptions': [['', 'blank', 'help,options,slash'], ['xxx']],
132      \ 'signcolumn': [['', 'auto', 'no'], ['xxx', 'no,yes']],
133      \ 'spellfile': [['', 'file.en.add', '/tmp/dir\ with\ space/en.utf-8.add'], ['xxx', '/tmp/file']],
134      \ 'spelllang': [['', 'xxx', 'sr@latin'], ['not&lang', "that\\\rthere"]],
135      \ 'spelloptions': [['', 'camel'], ['xxx']],
136      \ 'spellsuggest': [['', 'best', 'double,33'], ['xxx']],
137      \ 'switchbuf': [['', 'useopen', 'split,newtab'], ['xxx']],
138      \ 'tagcase': [['smart', 'match'], ['', 'xxx', 'smart,match']],
139      \ 'term': [[], []],
140      \ 'termguicolors': [[], []],
141      \ 'termencoding': [has('gui_gtk') ? [] : ['', 'utf-8'], ['xxx']],
142      \ 'termwinsize': [['', '24x80', '0x80', '32x0', '0x0'], ['xxx', '80', '8ax9', '24x80b']],
143      \ 'termwintype': [['', 'winpty', 'conpty'], ['xxx']],
144      \ 'toolbar': [['', 'icons', 'text'], ['xxx']],
145      \ 'toolbariconsize': [['', 'tiny', 'huge'], ['xxx']],
146      \ 'ttymouse': [['', 'xterm'], ['xxx']],
147      \ 'ttytype': [[], []],
148      \ 'varsofttabstop': [['8', '4,8,16,32'], ['xxx', '-1', '4,-1,20']],
149      \ 'vartabstop': [['8', '4,8,16,32'], ['xxx', '-1', '4,-1,20']],
150      \ 'viewoptions': [['', 'cursor', 'unix,slash'], ['xxx']],
151      \ 'viminfo': [['', '''50', '"30'], ['xxx']],
152      \ 'virtualedit': [['', 'all', 'all,block'], ['xxx']],
153      \ 'whichwrap': [['', 'b,s', 'bs'], ['xxx']],
154      \ 'wildmode': [['', 'full', 'list:full', 'full,longest'], ['xxx', 'a4', 'full,full,full,full,full']],
155      \ 'wildoptions': [['', 'tagfile'], ['xxx']],
156      \ 'winaltkeys': [['menu', 'no'], ['', 'xxx']],
157      \
158      \ 'luadll': [[], []],
159      \ 'perldll': [[], []],
160      \ 'pythondll': [[], []],
161      \ 'pythonthreedll': [[], []],
162      \ 'pyxversion': [[], []],
163      \ 'rubydll': [[], []],
164      \ 'tcldll': [[], []],
165      \
166      \ 'othernum': [[-1, 0, 100], ['']],
167      \ 'otherstring': [['', 'xxx'], []],
168      \}
169
1701
171/struct vimoption options
172while 1
173  /{"
174  if line('.') > end
175    break
176  endif
177  let line = getline('.')
178  let name = substitute(line, '.*{"\([^"]*\)".*', '\1', '')
179  let shortname = substitute(line, '.*"\([^"]*\)".*', '\1', '')
180
181  if has_key(test_values, name)
182    let a = test_values[name]
183  elseif line =~ 'P_NUM'
184    let a = test_values['othernum']
185  else
186    let a = test_values['otherstring']
187  endif
188  if len(a[0]) > 0 || len(a[1]) > 0
189    if line =~ 'P_BOOL'
190      call add(script, 'set ' . name)
191      call add(script, 'set ' . shortname)
192      call add(script, 'set no' . name)
193      call add(script, 'set no' . shortname)
194    else
195      for val in a[0]
196	call add(script, 'set ' . name . '=' . val)
197	call add(script, 'set ' . shortname . '=' . val)
198      endfor
199
200      " setting an option can only fail when it's implemented.
201      call add(script, "if exists('+" . name . "')")
202      for val in a[1]
203	call add(script, "silent! call assert_fails('set " . name . "=" . val . "')")
204	call add(script, "silent! call assert_fails('set " . shortname . "=" . val . "')")
205      endfor
206      call add(script, "endif")
207    endif
208
209    " cannot change 'termencoding' in GTK
210    if name != 'termencoding' || !has('gui_gtk')
211      call add(script, 'set ' . name . '&')
212      call add(script, 'set ' . shortname . '&')
213    endif
214    if name == 'verbosefile'
215      call add(script, 'call delete("xxx")')
216    endif
217
218    if name == 'more'
219      call add(script, 'set nomore')
220    elseif name == 'lines'
221      call add(script, 'let &lines = save_lines')
222    endif
223  endif
224endwhile
225
226call add(script, 'let &term = save_term')
227call add(script, 'let &columns = save_columns')
228call add(script, 'let &lines = save_lines')
229
230call writefile(script, 'opt_test.vim')
231
232endif
233
234qa!
235