blob: 7e89e7342af3efc77299a3e7cba46812b4fcf717 [file] [log] [blame]
Milly6eca04e2024-10-21 22:20:51 +02001" Script to generate src/testdir/opt_test.vim from src/optiondefs.h and
2" runtime/doc/options.txt
Bram Moolenaar2f5463d2017-02-25 20:40:46 +01003
Bram Moolenaar2f5463d2017-02-25 20:40:46 +01004set cpo=&vim
Bram Moolenaar5b3af142017-02-27 22:59:40 +01005
6" Only do this when build with the +eval feature.
7if 1
8
Millyd4ad4c92024-10-06 16:27:28 +02009try
10
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010011set nomore
12
Milly40c6bab2024-10-04 20:41:14 +020013const K_KENTER = -16715
14
Milly6eca04e2024-10-21 22:20:51 +020015" Get global-local options.
16" "key" is full-name of the option.
17" "value" is the local value to switch back to the global value.
18b options.txt
19call cursor(1, 1)
20let global_locals = {}
21while search("^'[^']*'.*\\n.*|global-local", 'W')
22 let fullname = getline('.')->matchstr("^'\\zs[^']*")
23 let global_locals[fullname] = ''
24endwhile
25call extend(global_locals, #{
26 \ scrolloff: -1,
27 \ sidescrolloff: -1,
28 \ undolevels: -12345,
29 \})
30
31" Get local-noglobal options.
32" "key" is full-name of the option.
33" "value" is no used.
34b options.txt
35call cursor(1, 1)
36let local_noglobals = {}
37while search("^'[^']*'.*\\n.*|local-noglobal", 'W')
38 let fullname = getline('.')->matchstr("^'\\zs[^']*")
39 let local_noglobals[fullname] = v:true
40endwhile
41
42" Options to skip `setglobal` tests.
43" "key" is full-name of the option.
44" "value" is the reason.
45let skip_setglobal_reasons = #{
46 \ iminsert: 'The global value is always overwritten by the local value',
47 \ imsearch: 'The global value is always overwritten by the local value',
48 \ breakindentopt: 'TODO: fix missing error handling for setglobal',
Milly6eca04e2024-10-21 22:20:51 +020049 \ conceallevel: 'TODO: fix missing error handling for setglobal',
50 \ foldcolumn: 'TODO: fix missing error handling for setglobal',
Milly6eca04e2024-10-21 22:20:51 +020051 \ numberwidth: 'TODO: fix missing error handling for setglobal',
52 \ scrolloff: 'TODO: fix missing error handling for setglobal',
53 \ shiftwidth: 'TODO: fix missing error handling for setglobal',
54 \ sidescrolloff: 'TODO: fix missing error handling for setglobal',
55 \ tabstop: 'TODO: fix missing error handling for setglobal',
Milly6eca04e2024-10-21 22:20:51 +020056 \ textwidth: 'TODO: fix missing error handling for setglobal',
57 \}
58
Bram Moolenaaree1dd1c2017-03-09 13:55:01 +010059" The terminal size is restored at the end.
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010060let script = [
Bram Moolenaar0c1e3742019-12-27 13:49:24 +010061 \ '" DO NOT EDIT: Generated with gen_opt_test.vim',
Milly6eca04e2024-10-21 22:20:51 +020062 \ '" Used by test_options_all.vim.',
Bram Moolenaar0c1e3742019-12-27 13:49:24 +010063 \ '',
Milly6eca04e2024-10-21 22:20:51 +020064 \ 'scriptencoding utf-8',
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010065 \ ]
66
Milly6eca04e2024-10-21 22:20:51 +020067b optiondefs.h
68const end = search('#define p_term', 'nw')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010069
Bram Moolenaar17471e82017-11-26 23:47:18 +010070" font name that works everywhere (hopefully)
71let fontname = has('win32') ? 'fixedsys' : 'fixed'
72
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010073" Two lists with values: values that work and values that fail.
74" When not listed, "othernum" or "otherstring" is used.
Millycc15bbc2024-10-18 19:58:04 +020075" When both lists are empty, skip tests for the option.
76" For boolean options, if non-empty a fixed test will be run, otherwise skipped.
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010077let test_values = {
Millycc15bbc2024-10-18 19:58:04 +020078 "\ boolean options
79 \ 'termguicolors': [
80 \ has('vtp') && !has('vcon') && !has('gui_running') ? [] : [1],
81 \ []],
82 \
83 "\ number options
Bram Moolenaara2a89732022-08-31 14:46:18 +010084 \ 'cmdheight': [[1, 2, 10], [-1, 0]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010085 \ 'cmdwinheight': [[1, 2, 10], [-1, 0]],
Millycc15bbc2024-10-18 19:58:04 +020086 \ 'columns': [[12, 80, 10000], [-1, 0, 10]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010087 \ 'conceallevel': [[0, 1, 2, 3], [-1, 4, 99]],
88 \ 'foldcolumn': [[0, 1, 4, 12], [-1, 13, 999]],
89 \ 'helpheight': [[0, 10, 100], [-1]],
Millycc15bbc2024-10-18 19:58:04 +020090 \ 'history': [[0, 1, 100, 10000], [-1, 10001]],
91 \ 'iminsert': [[0, 1, 2], [-1, 3, 999]],
92 \ 'imsearch': [[-1, 0, 1, 2], [-2, 3, 999]],
Bram Moolenaar5c6dbcb2017-08-30 22:00:20 +020093 \ 'imstyle': [[0, 1], [-1, 2, 999]],
Millycc15bbc2024-10-18 19:58:04 +020094 \ 'lines': [[2, 24, 1000], [-1, 0, 1]],
95 \ 'linespace': [[-1, 0, 2, 4, 999], ['']],
Bram Moolenaarf8a07122019-07-01 22:06:07 +020096 \ 'numberwidth': [[1, 4, 8, 10, 11, 20], [-1, 0, 21]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010097 \ 'regexpengine': [[0, 1, 2], [-1, 3, 999]],
98 \ 'report': [[0, 1, 2, 9999], [-1]],
Millycc15bbc2024-10-18 19:58:04 +020099 \ 'scroll': [[0, 1, 2, 20], [-1, 999]],
100 \ 'scrolljump': [[-100, -1, 0, 1, 2, 20], [-101, 999]],
101 \ 'scrolloff': [[0, 1, 8, 999], [-1]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100102 \ 'shiftwidth': [[0, 1, 8, 999], [-1]],
103 \ 'sidescroll': [[0, 1, 8, 999], [-1]],
104 \ 'sidescrolloff': [[0, 1, 8, 999], [-1]],
Millycc15bbc2024-10-18 19:58:04 +0200105 \ 'tabstop': [[1, 4, 8, 12, 9999], [-1, 0, 10000]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100106 \ 'textwidth': [[0, 1, 8, 99], [-1]],
107 \ 'timeoutlen': [[0, 8, 99999], [-1]],
108 \ 'titlelen': [[0, 1, 8, 9999], [-1]],
109 \ 'updatecount': [[0, 1, 8, 9999], [-1]],
110 \ 'updatetime': [[0, 1, 8, 9999], [-1]],
Millycc15bbc2024-10-18 19:58:04 +0200111 \ 'verbose': [[-1, 0, 1, 8, 9999], ['']],
Millya9c6f902024-10-06 16:47:02 +0200112 \ 'wildchar': [[-1, 0, 100, 'x', '^Y', '^@', '<Esc>', '<t_xx>', '<', '^'],
Millycc15bbc2024-10-18 19:58:04 +0200113 \ ['', 'xxx', '<xxx>', '<t_xxx>', '<Esc', '<t_xx', '<C-C>',
114 \ '<NL>', '<CR>', K_KENTER]],
Millya9c6f902024-10-06 16:47:02 +0200115 \ 'wildcharm': [[-1, 0, 100, 'x', '^Y', '^@', '<Esc>', '<', '^'],
Millycc15bbc2024-10-18 19:58:04 +0200116 \ ['', 'xxx', '<xxx>', '<t_xxx>', '<Esc', '<t_xx', '<C-C>',
117 \ '<NL>', '<CR>', K_KENTER]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100118 \ 'winheight': [[1, 10, 999], [-1, 0]],
119 \ 'winminheight': [[0, 1], [-1]],
120 \ 'winminwidth': [[0, 1, 10], [-1]],
121 \ 'winwidth': [[1, 10, 999], [-1, 0]],
122 \
Millycc15bbc2024-10-18 19:58:04 +0200123 "\ string options
124 \ 'ambiwidth': [['', 'single', 'double'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100125 \ 'background': [['', 'light', 'dark'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200126 \ 'backspace': [[0, 1, 2, 3, '', 'indent', 'eol', 'start', 'nostop',
127 \ 'eol,start', 'indent,eol,nostop'],
128 \ [-1, 4, 'xxx']],
129 \ 'backupcopy': [['yes', 'no', 'auto'], ['', 'xxx', 'yes,no']],
130 \ 'backupext': [['xxx'], [&patchmode, '*']],
131 \ 'belloff': [['', 'all', 'backspace', 'cursor', 'complete', 'copy',
132 \ 'ctrlg', 'error', 'esc', 'ex', 'hangul', 'insertmode', 'lang',
133 \ 'mess', 'showmatch', 'operator', 'register', 'shell', 'spell',
134 \ 'term', 'wildmode', 'copy,error,shell'],
135 \ ['xxx']],
136 \ 'breakindentopt': [['', 'min:3', 'shift:4', 'shift:-2', 'sbr', 'list:5',
137 \ 'list:-1', 'column:10', 'column:-5', 'min:1,sbr,shift:2'],
138 \ ['xxx', 'min', 'min:x', 'min:-1', 'shift:x', 'sbr:1', 'list:x',
139 \ 'column:x']],
140 \ 'browsedir': [['', 'last', 'buffer', 'current', './Xdir\ with\ space'],
141 \ ['xxx']],
142 \ 'bufhidden': [['', 'hide', 'unload', 'delete', 'wipe'],
143 \ ['xxx', 'hide,wipe']],
144 \ 'buftype': [['', 'nofile', 'nowrite', 'acwrite', 'quickfix', 'help',
145 \ 'terminal', 'prompt', 'popup'],
146 \ ['xxx', 'help,nofile']],
147 \ 'casemap': [['', 'internal', 'keepascii', 'internal,keepascii'],
148 \ ['xxx']],
Millya9c6f902024-10-06 16:47:02 +0200149 \ 'cedit': [['', '^Y', '^@', '<Esc>', '<t_xx>'],
Millycc15bbc2024-10-18 19:58:04 +0200150 \ ['xxx', 'f', '<xxx>', '<t_xxx>', '<Esc', '<t_xx']],
151 \ 'clipboard': [['', 'unnamed', 'unnamedplus', 'autoselect',
152 \ 'autoselectplus', 'autoselectml', 'html', 'exclude:vimdisplay',
153 \ 'autoselect,unnamed', 'unnamed,exclude:.*'],
154 \ ['xxx', 'exclude:\\ze*', 'exclude:\\%(']],
155 \ 'colorcolumn': [['', '8', '+2', '1,+1,+3'], ['xxx', '-a', '1,', '1;']],
156 \ 'comments': [['', 'b:#', 'b:#,:%'], ['xxx', '-']],
Riley Bruins0a083062024-06-03 20:40:45 +0200157 \ 'commentstring': [['', '/*\ %s\ */'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200158 \ 'complete': [['', '.', 'w', 'b', 'u', 'U', 'i', 'd', ']', 't',
159 \ 'k', 'kspell', 'k/tmp/dir\\\ with\\\ space/*',
160 \ 's', 's/tmp/dir\\\ with\\\ space/*',
161 \ 'w,b,k/tmp/dir\\\ with\\\ space/*,s'],
162 \ ['xxx']],
163 \ 'concealcursor': [['', 'n', 'v', 'i', 'c', 'nvic'], ['xxx']],
164 \ 'completeopt': [['', 'menu', 'menuone', 'longest', 'preview', 'popup',
165 \ 'popuphidden', 'noinsert', 'noselect', 'fuzzy', 'menu,longest'],
166 \ ['xxx', 'menu,,,longest,']],
167 \ 'completeitemalign': [['abbr,kind,menu', 'menu,abbr,kind'],
168 \ ['', 'xxx', 'abbr', 'abbr,menu', 'abbr,menu,kind,abbr',
169 \ 'abbr1234,kind,menu']],
170 \ 'completepopup': [['', 'height:13', 'width:20', 'highlight:That',
171 \ 'align:item', 'align:menu', 'border:on', 'border:off',
172 \ 'width:10,height:234,highlight:Mine'],
173 \ ['xxx', 'xxx:99', 'height:yes', 'width:no', 'align:xxx',
174 \ 'border:maybe', 'border:1', 'border:']],
Bram Moolenaard4404b42019-07-28 18:38:09 +0200175 \ 'completeslash': [['', 'slash', 'backslash'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100176 \ 'cryptmethod': [['', 'zip'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200177 \ 'cscopequickfix': [['', 's-', 'g-', 'd-', 'c-', 't-', 'e-', 'f-', 'i-',
178 \ 'a-', 's-,c+,e0'],
179 \ ['xxx', 's,g,d']],
180 \ 'cursorlineopt': [['both', 'line', 'number', 'screenline',
181 \ 'line,number'],
182 \ ['', 'xxx', 'line,screenline']],
183 \ 'debug': [['', 'msg', 'throw', 'beep'], ['xxx']],
184 \ 'diffopt': [['', 'filler', 'context:0', 'context:999', 'iblank',
185 \ 'icase', 'iwhite', 'iwhiteall', 'horizontal', 'vertical',
186 \ 'closeoff', 'hiddenoff', 'foldcolumn:0', 'foldcolumn:12',
187 \ 'followwrap', 'internal', 'indent-heuristic', 'algorithm:myers',
188 \ 'algorithm:minimal', 'algorithm:patience',
189 \ 'algorithm:histogram', 'icase,iwhite'],
190 \ ['xxx', 'foldcolumn:xxx', 'algorithm:xxx', 'algorithm:']],
191 \ 'display': [['', 'lastline', 'truncate', 'uhex', 'lastline,uhex'],
192 \ ['xxx']],
193 \ 'eadirection': [['', 'both', 'ver', 'hor'], ['xxx', 'ver,hor']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100194 \ 'encoding': [['latin1'], ['xxx', '']],
Millycc15bbc2024-10-18 19:58:04 +0200195 \ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter'],
196 \ ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100197 \ 'fileencoding': [['', 'latin1', 'xxx'], []],
Millycc15bbc2024-10-18 19:58:04 +0200198 \ 'fileformat': [['', 'dos', 'unix', 'mac'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100199 \ 'fileformats': [['', 'dos', 'dos,unix'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200200 \ 'fillchars': [['', 'stl:x', 'stlnc:x', 'vert:x', 'fold:x', 'foldopen:x',
201 \ 'foldclose:x', 'foldsep:x', 'diff:x', 'eob:x', 'lastline:x',
202 \ 'stl:\ ,vert:\|,fold:\\,diff:x'],
203 \ ['xxx', 'vert:']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100204 \ 'foldclose': [['', 'all'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200205 \ 'foldmethod': [['manual', 'indent', 'expr', 'marker', 'syntax', 'diff'],
206 \ ['', 'xxx', 'expr,diff']],
207 \ 'foldopen': [['', 'all', 'block', 'hor', 'insert', 'jump', 'mark',
208 \ 'percent', 'quickfix', 'search', 'tag', 'undo', 'hor,jump'],
209 \ ['xxx']],
210 \ 'foldmarker': [['((,))'], ['', 'xxx', '{{{,']],
211 \ 'formatoptions': [['', 't', 'c', 'r', 'o', '/', 'q', 'w', 'a', 'n', '2',
212 \ 'v', 'b', 'l', 'm', 'M', 'B', '1', ']', 'j', 'p', 'vt', 'v,t'],
213 \ ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100214 \ 'guicursor': [['', 'n:block-Cursor'], ['xxx']],
Bram Moolenaar17471e82017-11-26 23:47:18 +0100215 \ 'guifont': [['', fontname], []],
216 \ 'guifontwide': [['', fontname], []],
217 \ 'guifontset': [['', fontname], []],
Millycc15bbc2024-10-18 19:58:04 +0200218 \ 'guioptions': [['', '!', 'a', 'P', 'A', 'c', 'd', 'e', 'f', 'i', 'm',
219 \ 'M', 'g', 't', 'T', 'r', 'R', 'l', 'L', 'b', 'h', 'v', 'p', 'F',
220 \ 'k', '!abvR'],
221 \ ['xxx', 'a,b']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100222 \ 'helplang': [['', 'de', 'de,it'], ['xxx']],
223 \ 'highlight': [['', 'e:Error'], ['xxx']],
Bram Moolenaar86e57922017-04-23 18:44:26 +0200224 \ 'imactivatekey': [['', 'S-space'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100225 \ 'isfname': [['', '@', '@,48-52'], ['xxx', '@48']],
226 \ 'isident': [['', '@', '@,48-52'], ['xxx', '@48']],
227 \ 'iskeyword': [['', '@', '@,48-52'], ['xxx', '@48']],
228 \ 'isprint': [['', '@', '@,48-52'], ['xxx', '@48']],
Yegappan Lakshmanan87018252023-09-20 20:20:04 +0200229 \ 'jumpoptions': [['', 'stack'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200230 \ 'keymap': [['', 'accents'], ['/']],
231 \ 'keymodel': [['', 'startsel', 'stopsel', 'startsel,stopsel'], ['xxx']],
Bram Moolenaar63a2e362022-11-23 20:20:18 +0000232 \ 'keyprotocol': [['', 'xxx:none', 'yyy:mok2', 'zzz:kitty'],
Millycc15bbc2024-10-18 19:58:04 +0200233 \ ['xxx', ':none', 'xxx:', 'x:non', 'y:mok3', 'z:kittty']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100234 \ 'langmap': [['', 'xX', 'aA,bB'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200235 \ 'lispoptions': [['', 'expr:0', 'expr:1'], ['xxx', 'expr:x', 'expr:']],
236 \ 'listchars': [['', 'eol:x', 'tab:xy', 'tab:xyz', 'space:x',
237 \ 'multispace:xxxy', 'lead:x', 'leadmultispace:xxxy', 'trail:x',
238 \ 'extends:x', 'precedes:x', 'conceal:x', 'nbsp:x', 'eol:\\x24',
239 \ 'eol:\\u21b5', 'eol:\\U000021b5', 'eol:x,space:y'],
240 \ ['xxx', 'eol:']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100241 \ 'matchpairs': [['', '(:)', '(:),<:>'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200242 \ 'mkspellmem': [['10000,100,12'], ['', 'xxx', '10000,100']],
243 \ 'mouse': [['', 'n', 'v', 'i', 'c', 'h', 'a', 'r', 'nvi'],
244 \ ['xxx', 'n,v,i']],
245 \ 'mousemodel': [['', 'extend', 'popup', 'popup_setpos'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100246 \ 'mouseshape': [['', 'n:arrow'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200247 \ 'nrformats': [['', 'alpha', 'octal', 'hex', 'bin', 'unsigned', 'blank',
248 \ 'alpha,hex,bin'],
249 \ ['xxx']],
250 \ 'patchmode': [['', 'xxx', '.x'], [&backupext, '*']],
251 \ 'previewpopup': [['', 'height:13', 'width:20', 'highlight:That',
252 \ 'align:item', 'align:menu', 'border:on', 'border:off',
253 \ 'width:10,height:234,highlight:Mine'],
254 \ ['xxx', 'xxx:99', 'height:yes', 'width:no', 'align:xxx',
255 \ 'border:maybe', 'border:1', 'border:']],
256 \ 'printmbfont': [['', 'r:some', 'b:some', 'i:some', 'o:some', 'c:yes',
257 \ 'c:no', 'a:yes', 'a:no', 'b:Bold,c:yes'],
258 \ ['xxx', 'xxx,c:yes', 'xxx:', 'xxx:,c:yes']],
259 \ 'printoptions': [['', 'header:0', 'left:10pc,top:5pc'],
260 \ ['xxx', 'header:-1']],
261 \ 'scrollopt': [['', 'ver', 'hor', 'jump', 'ver,hor'], ['xxx']],
Bram Moolenaar0c1e3742019-12-27 13:49:24 +0100262 \ 'renderoptions': [[''], ['xxx']],
Yegappan Lakshmanan5da901b2023-02-27 12:47:47 +0000263 \ 'rightleftcmd': [['search'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200264 \ 'rulerformat': [['', 'xxx'], ['%-', '%(', '%15(%%']],
265 \ 'selection': [['old', 'inclusive', 'exclusive'], ['', 'xxx']],
266 \ 'selectmode': [['', 'mouse', 'key', 'cmd', 'key,cmd'], ['xxx']],
267 \ 'sessionoptions': [['', 'blank', 'curdir', 'sesdir',
268 \ 'help,options,slash'],
269 \ ['xxx', 'curdir,sesdir']],
270 \ 'showcmdloc': [['', 'last', 'statusline', 'tabline'], ['xxx']],
271 \ 'signcolumn': [['', 'auto', 'no', 'yes', 'number'], ['xxx', 'no,yes']],
Milly322ad0c2024-10-14 20:21:48 +0200272 \ 'spellfile': [['', 'file.en.add', 'xxx.en.add,yyy.gb.add,zzz.ja.add',
273 \ '/tmp/dir\ with\ space/en.utf-8.add',
274 \ '/tmp/dir\\,with\\,comma/en.utf-8.add'],
Millycc15bbc2024-10-18 19:58:04 +0200275 \ ['xxx', '/tmp/file', '/tmp/dir*with:invalid?char/file.en.add',
276 \ ',file.en.add', 'xxx,yyy.en.add', 'xxx.en.add,yyy,zzz.ja.add']],
Bram Moolenaar9a061cb2019-05-05 16:55:03 +0200277 \ 'spelllang': [['', 'xxx', 'sr@latin'], ['not&lang', "that\\\rthere"]],
Bram Moolenaar362b44b2020-06-10 21:47:00 +0200278 \ 'spelloptions': [['', 'camel'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200279 \ 'spellsuggest': [['', 'best', 'double', 'fast', '100', 'timeout:100',
280 \ 'timeout:-1', 'file:/tmp/file', 'expr:Func()', 'double,33'],
281 \ ['xxx', '-1', 'timeout:', 'best,double', 'double,fast']],
282 \ 'splitkeep': [['', 'cursor', 'screen', 'topline'], ['xxx']],
283 \ 'statusline': [['', 'xxx'], ['%$', '%{', '%{%', '%{%}', '%(', '%)']],
Yegappan Lakshmanan5da901b2023-02-27 12:47:47 +0000284 \ 'swapsync': [['', 'sync', 'fsync'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200285 \ 'switchbuf': [['', 'useopen', 'usetab', 'split', 'vsplit', 'newtab',
286 \ 'uselast', 'split,newtab'],
287 \ ['xxx']],
288 \ 'tabclose': [['', 'left', 'uselast', 'left,uselast'], ['xxx']],
289 \ 'tabline': [['', 'xxx'], ['%$', '%{', '%{%', '%{%}', '%(', '%)']],
290 \ 'tagcase': [['followic', 'followscs', 'ignore', 'match', 'smart'],
291 \ ['', 'xxx', 'smart,match']],
Bram Moolenaar17471e82017-11-26 23:47:18 +0100292 \ 'termencoding': [has('gui_gtk') ? [] : ['', 'utf-8'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200293 \ 'termwinkey': [['', 'f', '^Y', '^@', '<Esc>', '<t_xx>', "\u3042", '<',
294 \ '^'],
295 \ ['<xxx>', '<t_xxx>', '<Esc', '<t_xx']],
296 \ 'termwinsize': [['', '24x80', '0x80', '32x0', '0x0'],
297 \ ['xxx', '80', '8ax9', '24x80b']],
Bram Moolenaarc6ddce32019-02-08 12:47:03 +0100298 \ 'termwintype': [['', 'winpty', 'conpty'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200299 \ 'titlestring': [['', 'xxx', '%('], []],
300 \ 'toolbar': [['', 'icons', 'text', 'horiz', 'tooltips', 'icons,text'],
301 \ ['xxx']],
302 \ 'toolbariconsize': [['', 'tiny', 'small', 'medium', 'large', 'huge',
303 \ 'giant'],
304 \ ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100305 \ 'ttymouse': [['', 'xterm'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200306 \ 'varsofttabstop': [['8', '4,8,16,32'], ['xxx', '-1', '4,-1,20', '1,']],
307 \ 'vartabstop': [['8', '4,8,16,32'], ['xxx', '-1', '4,-1,20', '1,']],
308 \ 'verbosefile': [['', './Xfile'], []],
309 \ 'viewoptions': [['', 'cursor', 'folds', 'options', 'localoptions',
310 \ 'slash', 'unix', 'curdir', 'unix,slash'], ['xxx']],
311 \ 'viminfo': [['', '''50', '"30', "'100,<50,s10,h"], ['xxx', 'h']],
312 \ 'virtualedit': [['', 'block', 'insert', 'all', 'onemore', 'none',
313 \ 'NONE', 'all,block'],
314 \ ['xxx']],
315 \ 'whichwrap': [['', 'b', 's', 'h', 'l', '<', '>', '~', '[', ']', 'b,s',
316 \ 'bs'],
317 \ ['xxx']],
318 \ 'wildmode': [['', 'full', 'longest', 'list', 'lastused', 'list:full',
319 \ 'full,longest', 'full,full,full,full'],
320 \ ['xxx', 'a4', 'full,full,full,full,full']],
Yegappan Lakshmanan38b85cb2022-02-24 13:28:41 +0000321 \ 'wildoptions': [['', 'tagfile', 'pum', 'fuzzy'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200322 \ 'winaltkeys': [['no', 'yes', 'menu'], ['', 'xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100323 \
Millycc15bbc2024-10-18 19:58:04 +0200324 "\ skipped options
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100325 \ 'luadll': [[], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100326 \ 'perldll': [[], []],
327 \ 'pythondll': [[], []],
328 \ 'pythonthreedll': [[], []],
329 \ 'pyxversion': [[], []],
330 \ 'rubydll': [[], []],
331 \ 'tcldll': [[], []],
Millycc15bbc2024-10-18 19:58:04 +0200332 \ 'term': [[], []],
333 \ 'ttytype': [[], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100334 \
Millycc15bbc2024-10-18 19:58:04 +0200335 "\ default behaviours
Bram Moolenaara12e4032017-02-25 21:37:57 +0100336 \ 'othernum': [[-1, 0, 100], ['']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100337 \ 'otherstring': [['', 'xxx'], []],
338 \}
339
Milly6eca04e2024-10-21 22:20:51 +0200340" Two lists with values: values that pre- and post-processing in test.
341" Clear out t_WS: we don't want to resize the actual terminal.
342let test_prepost = {
343 \ 'browsedir': [["call mkdir('Xdir with space', 'D')"], []],
344 \ 'columns': [[
345 \ 'set t_WS=',
346 \ 'let save_columns = &columns'
347 \ ], [
348 \ 'let &columns = save_columns',
349 \ 'set t_WS&'
350 \ ]],
351 \ 'lines': [[
352 \ 'set t_WS=',
353 \ 'let save_lines = &lines'
354 \ ], [
355 \ 'let &lines = save_lines',
356 \ 'set t_WS&'
357 \ ]],
358 \ 'verbosefile': [[], ['call delete("Xfile")']],
359 \}
360
Millyb498c442024-10-17 21:05:31 +0200361const invalid_options = test_values->keys()
362 \->filter({-> v:val !~# '^other' && !exists($"&{v:val}")})
363if !empty(invalid_options)
364 throw $"Invalid option name in test_values: '{invalid_options->join("', '")}'"
365endif
366
Bram Moolenaar2f5463d2017-02-25 20:40:46 +01003671
Milly6eca04e2024-10-21 22:20:51 +0200368call search('struct vimoption options')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100369while 1
Milly6eca04e2024-10-21 22:20:51 +0200370 if search('{"', 'W') > end
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100371 break
372 endif
373 let line = getline('.')
Milly6eca04e2024-10-21 22:20:51 +0200374 let fullname = substitute(line, '.*{"\([^"]*\)".*', '\1', '')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100375 let shortname = substitute(line, '.*"\([^"]*\)".*', '\1', '')
376
Milly6eca04e2024-10-21 22:20:51 +0200377 let [valid_values, invalid_values] = test_values[
378 \ has_key(test_values, fullname) ? fullname
379 \ : line =~ 'P_NUM' ? 'othernum'
380 \ : 'otherstring']
381
382 if empty(valid_values) && empty(invalid_values)
383 continue
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100384 endif
Millycc15bbc2024-10-18 19:58:04 +0200385
Milly6eca04e2024-10-21 22:20:51 +0200386 call add(script, $"func Test_opt_set_{fullname}()")
387 call add(script, $"if exists('+{fullname}') && execute('set!') =~# '\\n..{fullname}\\([=\\n]\\|$\\)'")
388 call add(script, $"let l:saved = [&g:{fullname}, &l:{fullname}]")
389 call add(script, 'endif')
390
391 let [pre_processing, post_processing] = get(test_prepost, fullname, [[], []])
392 let script += pre_processing
393
394 if line =~ 'P_BOOL'
395 for opt in [fullname, shortname]
396 for cmd in ['set', 'setlocal', 'setglobal']
397 call add(script, $'{cmd} {opt}')
398 call add(script, $'{cmd} no{opt}')
399 call add(script, $'{cmd} inv{opt}')
400 call add(script, $'{cmd} {opt}!')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100401 endfor
Milly6eca04e2024-10-21 22:20:51 +0200402 endfor
403 else " P_NUM || P_STRING
404 " Normal tests
405 for opt in [fullname, shortname]
406 for cmd in ['set', 'setlocal', 'setglobal']
407 for val in valid_values
408 if local_noglobals->has_key(fullname) && cmd ==# 'setglobal'
409 " Skip `:setglobal {option}={val}` for local-noglobal option.
410 " It has no effect.
411 let pre = '" Skip local-noglobal: '
412 else
413 let pre = ''
414 endif
415 call add(script, $'{pre}{cmd} {opt}={val}')
416 endfor
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100417 endfor
Milly6eca04e2024-10-21 22:20:51 +0200418 " Testing to clear the local value and switch back to the global value.
419 if global_locals->has_key(fullname)
420 let swichback_val = global_locals[fullname]
421 call add(script, $'setlocal {opt}={swichback_val}')
422 endif
423 endfor
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100424
Milly6eca04e2024-10-21 22:20:51 +0200425 " Failure tests
426 " Setting an option can only fail when it's implemented.
427 call add(script, $"if exists('+{fullname}')")
428 for opt in [fullname, shortname]
429 for cmd in ['set', 'setlocal', 'setglobal']
430 for val in invalid_values
431 if val is# global_locals->get(fullname, {}) && cmd ==# 'setlocal'
432 " Skip setlocal switchback-value to global-local option. It will
433 " not result in failure.
434 let pre = '" Skip global-local: '
435 elseif local_noglobals->has_key(fullname) && cmd ==# 'setglobal'
436 " Skip setglobal to local-noglobal option. It will not result in
437 " failure.
438 let pre = '" Skip local-noglobal: '
439 elseif skip_setglobal_reasons->has_key(fullname) && cmd ==# 'setglobal'
440 " Skip setglobal to reasoned option. It will not result in failure.
441 let reason = skip_setglobal_reasons[fullname]
442 let pre = $'" Skip {reason}: '
443 else
444 let pre = ''
445 endif
446 let cmdline = $'{cmd} {opt}={val}'
447 call add(script, $"{pre}silent! call assert_fails({string(cmdline)})")
448 endfor
449 endfor
450 endfor
451 call add(script, "endif")
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100452 endif
Milly6eca04e2024-10-21 22:20:51 +0200453
454 " Cannot change 'termencoding' in GTK
455 if fullname != 'termencoding' || !has('gui_gtk')
456 call add(script, $'set {fullname}&')
457 call add(script, $'set {shortname}&')
458 call add(script, $"if exists('l:saved')")
459 call add(script, $"let [&g:{fullname}, &l:{fullname}] = l:saved")
460 call add(script, 'endif')
461 endif
462
463 let script += post_processing
464 call add(script, 'endfunc')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100465endwhile
466
Bram Moolenaare8512d72017-03-07 22:33:32 +0100467call writefile(script, 'opt_test.vim')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100468
Millyb498c442024-10-17 21:05:31 +0200469" Write error messages if error occurs.
Millyd4ad4c92024-10-06 16:27:28 +0200470catch
Millyb498c442024-10-17 21:05:31 +0200471 " Append errors to test.log
472 let error = $'Error: {v:exception} in {v:throwpoint}'
473 echoc error
474 split test.log
475 call append('$', error)
476 write
Millyd4ad4c92024-10-06 16:27:28 +0200477endtry
478
Bram Moolenaar5b3af142017-02-27 22:59:40 +0100479endif
480
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100481qa!
Milly6eca04e2024-10-21 22:20:51 +0200482
483" vim:sw=2:ts=8:noet:nolist:nosta: