blob: e8556025258a51ea8efa8f5c75043c464bf0b429 [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',
49 \ colorcolumn: 'TODO: fix missing error handling for setglobal',
50 \ conceallevel: 'TODO: fix missing error handling for setglobal',
51 \ foldcolumn: 'TODO: fix missing error handling for setglobal',
52 \ foldmethod: 'TODO: fix `setglobal fdm=` not given an error',
53 \ iskeyword: 'TODO: fix missing error handling for setglobal',
54 \ numberwidth: 'TODO: fix missing error handling for setglobal',
55 \ scrolloff: 'TODO: fix missing error handling for setglobal',
56 \ shiftwidth: 'TODO: fix missing error handling for setglobal',
57 \ sidescrolloff: 'TODO: fix missing error handling for setglobal',
58 \ tabstop: 'TODO: fix missing error handling for setglobal',
59 \ termwinkey: 'TODO: fix missing error handling for setglobal',
60 \ termwinsize: 'TODO: fix missing error handling for setglobal',
61 \ textwidth: 'TODO: fix missing error handling for setglobal',
62 \}
63
Bram Moolenaaree1dd1c2017-03-09 13:55:01 +010064" The terminal size is restored at the end.
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010065let script = [
Bram Moolenaar0c1e3742019-12-27 13:49:24 +010066 \ '" DO NOT EDIT: Generated with gen_opt_test.vim',
Milly6eca04e2024-10-21 22:20:51 +020067 \ '" Used by test_options_all.vim.',
Bram Moolenaar0c1e3742019-12-27 13:49:24 +010068 \ '',
Milly6eca04e2024-10-21 22:20:51 +020069 \ 'scriptencoding utf-8',
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010070 \ ]
71
Milly6eca04e2024-10-21 22:20:51 +020072b optiondefs.h
73const end = search('#define p_term', 'nw')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010074
Bram Moolenaar17471e82017-11-26 23:47:18 +010075" font name that works everywhere (hopefully)
76let fontname = has('win32') ? 'fixedsys' : 'fixed'
77
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010078" Two lists with values: values that work and values that fail.
79" When not listed, "othernum" or "otherstring" is used.
Millycc15bbc2024-10-18 19:58:04 +020080" When both lists are empty, skip tests for the option.
81" For boolean options, if non-empty a fixed test will be run, otherwise skipped.
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010082let test_values = {
Millycc15bbc2024-10-18 19:58:04 +020083 "\ boolean options
84 \ 'termguicolors': [
85 \ has('vtp') && !has('vcon') && !has('gui_running') ? [] : [1],
86 \ []],
87 \
88 "\ number options
Bram Moolenaara2a89732022-08-31 14:46:18 +010089 \ 'cmdheight': [[1, 2, 10], [-1, 0]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010090 \ 'cmdwinheight': [[1, 2, 10], [-1, 0]],
Millycc15bbc2024-10-18 19:58:04 +020091 \ 'columns': [[12, 80, 10000], [-1, 0, 10]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010092 \ 'conceallevel': [[0, 1, 2, 3], [-1, 4, 99]],
93 \ 'foldcolumn': [[0, 1, 4, 12], [-1, 13, 999]],
94 \ 'helpheight': [[0, 10, 100], [-1]],
Millycc15bbc2024-10-18 19:58:04 +020095 \ 'history': [[0, 1, 100, 10000], [-1, 10001]],
96 \ 'iminsert': [[0, 1, 2], [-1, 3, 999]],
97 \ 'imsearch': [[-1, 0, 1, 2], [-2, 3, 999]],
Bram Moolenaar5c6dbcb2017-08-30 22:00:20 +020098 \ 'imstyle': [[0, 1], [-1, 2, 999]],
Millycc15bbc2024-10-18 19:58:04 +020099 \ 'lines': [[2, 24, 1000], [-1, 0, 1]],
100 \ 'linespace': [[-1, 0, 2, 4, 999], ['']],
Bram Moolenaarf8a07122019-07-01 22:06:07 +0200101 \ 'numberwidth': [[1, 4, 8, 10, 11, 20], [-1, 0, 21]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100102 \ 'regexpengine': [[0, 1, 2], [-1, 3, 999]],
103 \ 'report': [[0, 1, 2, 9999], [-1]],
Millycc15bbc2024-10-18 19:58:04 +0200104 \ 'scroll': [[0, 1, 2, 20], [-1, 999]],
105 \ 'scrolljump': [[-100, -1, 0, 1, 2, 20], [-101, 999]],
106 \ 'scrolloff': [[0, 1, 8, 999], [-1]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100107 \ 'shiftwidth': [[0, 1, 8, 999], [-1]],
108 \ 'sidescroll': [[0, 1, 8, 999], [-1]],
109 \ 'sidescrolloff': [[0, 1, 8, 999], [-1]],
Millycc15bbc2024-10-18 19:58:04 +0200110 \ 'tabstop': [[1, 4, 8, 12, 9999], [-1, 0, 10000]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100111 \ 'textwidth': [[0, 1, 8, 99], [-1]],
112 \ 'timeoutlen': [[0, 8, 99999], [-1]],
113 \ 'titlelen': [[0, 1, 8, 9999], [-1]],
114 \ 'updatecount': [[0, 1, 8, 9999], [-1]],
115 \ 'updatetime': [[0, 1, 8, 9999], [-1]],
Millycc15bbc2024-10-18 19:58:04 +0200116 \ 'verbose': [[-1, 0, 1, 8, 9999], ['']],
Millya9c6f902024-10-06 16:47:02 +0200117 \ 'wildchar': [[-1, 0, 100, 'x', '^Y', '^@', '<Esc>', '<t_xx>', '<', '^'],
Millycc15bbc2024-10-18 19:58:04 +0200118 \ ['', 'xxx', '<xxx>', '<t_xxx>', '<Esc', '<t_xx', '<C-C>',
119 \ '<NL>', '<CR>', K_KENTER]],
Millya9c6f902024-10-06 16:47:02 +0200120 \ 'wildcharm': [[-1, 0, 100, 'x', '^Y', '^@', '<Esc>', '<', '^'],
Millycc15bbc2024-10-18 19:58:04 +0200121 \ ['', 'xxx', '<xxx>', '<t_xxx>', '<Esc', '<t_xx', '<C-C>',
122 \ '<NL>', '<CR>', K_KENTER]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100123 \ 'winheight': [[1, 10, 999], [-1, 0]],
124 \ 'winminheight': [[0, 1], [-1]],
125 \ 'winminwidth': [[0, 1, 10], [-1]],
126 \ 'winwidth': [[1, 10, 999], [-1, 0]],
127 \
Millycc15bbc2024-10-18 19:58:04 +0200128 "\ string options
129 \ 'ambiwidth': [['', 'single', 'double'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100130 \ 'background': [['', 'light', 'dark'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200131 \ 'backspace': [[0, 1, 2, 3, '', 'indent', 'eol', 'start', 'nostop',
132 \ 'eol,start', 'indent,eol,nostop'],
133 \ [-1, 4, 'xxx']],
134 \ 'backupcopy': [['yes', 'no', 'auto'], ['', 'xxx', 'yes,no']],
135 \ 'backupext': [['xxx'], [&patchmode, '*']],
136 \ 'belloff': [['', 'all', 'backspace', 'cursor', 'complete', 'copy',
137 \ 'ctrlg', 'error', 'esc', 'ex', 'hangul', 'insertmode', 'lang',
138 \ 'mess', 'showmatch', 'operator', 'register', 'shell', 'spell',
139 \ 'term', 'wildmode', 'copy,error,shell'],
140 \ ['xxx']],
141 \ 'breakindentopt': [['', 'min:3', 'shift:4', 'shift:-2', 'sbr', 'list:5',
142 \ 'list:-1', 'column:10', 'column:-5', 'min:1,sbr,shift:2'],
143 \ ['xxx', 'min', 'min:x', 'min:-1', 'shift:x', 'sbr:1', 'list:x',
144 \ 'column:x']],
145 \ 'browsedir': [['', 'last', 'buffer', 'current', './Xdir\ with\ space'],
146 \ ['xxx']],
147 \ 'bufhidden': [['', 'hide', 'unload', 'delete', 'wipe'],
148 \ ['xxx', 'hide,wipe']],
149 \ 'buftype': [['', 'nofile', 'nowrite', 'acwrite', 'quickfix', 'help',
150 \ 'terminal', 'prompt', 'popup'],
151 \ ['xxx', 'help,nofile']],
152 \ 'casemap': [['', 'internal', 'keepascii', 'internal,keepascii'],
153 \ ['xxx']],
Millya9c6f902024-10-06 16:47:02 +0200154 \ 'cedit': [['', '^Y', '^@', '<Esc>', '<t_xx>'],
Millycc15bbc2024-10-18 19:58:04 +0200155 \ ['xxx', 'f', '<xxx>', '<t_xxx>', '<Esc', '<t_xx']],
156 \ 'clipboard': [['', 'unnamed', 'unnamedplus', 'autoselect',
157 \ 'autoselectplus', 'autoselectml', 'html', 'exclude:vimdisplay',
158 \ 'autoselect,unnamed', 'unnamed,exclude:.*'],
159 \ ['xxx', 'exclude:\\ze*', 'exclude:\\%(']],
160 \ 'colorcolumn': [['', '8', '+2', '1,+1,+3'], ['xxx', '-a', '1,', '1;']],
161 \ 'comments': [['', 'b:#', 'b:#,:%'], ['xxx', '-']],
Riley Bruins0a083062024-06-03 20:40:45 +0200162 \ 'commentstring': [['', '/*\ %s\ */'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200163 \ 'complete': [['', '.', 'w', 'b', 'u', 'U', 'i', 'd', ']', 't',
164 \ 'k', 'kspell', 'k/tmp/dir\\\ with\\\ space/*',
165 \ 's', 's/tmp/dir\\\ with\\\ space/*',
166 \ 'w,b,k/tmp/dir\\\ with\\\ space/*,s'],
167 \ ['xxx']],
168 \ 'concealcursor': [['', 'n', 'v', 'i', 'c', 'nvic'], ['xxx']],
169 \ 'completeopt': [['', 'menu', 'menuone', 'longest', 'preview', 'popup',
170 \ 'popuphidden', 'noinsert', 'noselect', 'fuzzy', 'menu,longest'],
171 \ ['xxx', 'menu,,,longest,']],
172 \ 'completeitemalign': [['abbr,kind,menu', 'menu,abbr,kind'],
173 \ ['', 'xxx', 'abbr', 'abbr,menu', 'abbr,menu,kind,abbr',
174 \ 'abbr1234,kind,menu']],
175 \ 'completepopup': [['', 'height:13', 'width:20', 'highlight:That',
176 \ 'align:item', 'align:menu', 'border:on', 'border:off',
177 \ 'width:10,height:234,highlight:Mine'],
178 \ ['xxx', 'xxx:99', 'height:yes', 'width:no', 'align:xxx',
179 \ 'border:maybe', 'border:1', 'border:']],
Bram Moolenaard4404b42019-07-28 18:38:09 +0200180 \ 'completeslash': [['', 'slash', 'backslash'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100181 \ 'cryptmethod': [['', 'zip'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200182 \ 'cscopequickfix': [['', 's-', 'g-', 'd-', 'c-', 't-', 'e-', 'f-', 'i-',
183 \ 'a-', 's-,c+,e0'],
184 \ ['xxx', 's,g,d']],
185 \ 'cursorlineopt': [['both', 'line', 'number', 'screenline',
186 \ 'line,number'],
187 \ ['', 'xxx', 'line,screenline']],
188 \ 'debug': [['', 'msg', 'throw', 'beep'], ['xxx']],
189 \ 'diffopt': [['', 'filler', 'context:0', 'context:999', 'iblank',
190 \ 'icase', 'iwhite', 'iwhiteall', 'horizontal', 'vertical',
191 \ 'closeoff', 'hiddenoff', 'foldcolumn:0', 'foldcolumn:12',
192 \ 'followwrap', 'internal', 'indent-heuristic', 'algorithm:myers',
193 \ 'algorithm:minimal', 'algorithm:patience',
194 \ 'algorithm:histogram', 'icase,iwhite'],
195 \ ['xxx', 'foldcolumn:xxx', 'algorithm:xxx', 'algorithm:']],
196 \ 'display': [['', 'lastline', 'truncate', 'uhex', 'lastline,uhex'],
197 \ ['xxx']],
198 \ 'eadirection': [['', 'both', 'ver', 'hor'], ['xxx', 'ver,hor']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100199 \ 'encoding': [['latin1'], ['xxx', '']],
Millycc15bbc2024-10-18 19:58:04 +0200200 \ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter'],
201 \ ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100202 \ 'fileencoding': [['', 'latin1', 'xxx'], []],
Millycc15bbc2024-10-18 19:58:04 +0200203 \ 'fileformat': [['', 'dos', 'unix', 'mac'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100204 \ 'fileformats': [['', 'dos', 'dos,unix'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200205 \ 'fillchars': [['', 'stl:x', 'stlnc:x', 'vert:x', 'fold:x', 'foldopen:x',
206 \ 'foldclose:x', 'foldsep:x', 'diff:x', 'eob:x', 'lastline:x',
207 \ 'stl:\ ,vert:\|,fold:\\,diff:x'],
208 \ ['xxx', 'vert:']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100209 \ 'foldclose': [['', 'all'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200210 \ 'foldmethod': [['manual', 'indent', 'expr', 'marker', 'syntax', 'diff'],
211 \ ['', 'xxx', 'expr,diff']],
212 \ 'foldopen': [['', 'all', 'block', 'hor', 'insert', 'jump', 'mark',
213 \ 'percent', 'quickfix', 'search', 'tag', 'undo', 'hor,jump'],
214 \ ['xxx']],
215 \ 'foldmarker': [['((,))'], ['', 'xxx', '{{{,']],
216 \ 'formatoptions': [['', 't', 'c', 'r', 'o', '/', 'q', 'w', 'a', 'n', '2',
217 \ 'v', 'b', 'l', 'm', 'M', 'B', '1', ']', 'j', 'p', 'vt', 'v,t'],
218 \ ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100219 \ 'guicursor': [['', 'n:block-Cursor'], ['xxx']],
Bram Moolenaar17471e82017-11-26 23:47:18 +0100220 \ 'guifont': [['', fontname], []],
221 \ 'guifontwide': [['', fontname], []],
222 \ 'guifontset': [['', fontname], []],
Millycc15bbc2024-10-18 19:58:04 +0200223 \ 'guioptions': [['', '!', 'a', 'P', 'A', 'c', 'd', 'e', 'f', 'i', 'm',
224 \ 'M', 'g', 't', 'T', 'r', 'R', 'l', 'L', 'b', 'h', 'v', 'p', 'F',
225 \ 'k', '!abvR'],
226 \ ['xxx', 'a,b']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100227 \ 'helplang': [['', 'de', 'de,it'], ['xxx']],
228 \ 'highlight': [['', 'e:Error'], ['xxx']],
Bram Moolenaar86e57922017-04-23 18:44:26 +0200229 \ 'imactivatekey': [['', 'S-space'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100230 \ 'isfname': [['', '@', '@,48-52'], ['xxx', '@48']],
231 \ 'isident': [['', '@', '@,48-52'], ['xxx', '@48']],
232 \ 'iskeyword': [['', '@', '@,48-52'], ['xxx', '@48']],
233 \ 'isprint': [['', '@', '@,48-52'], ['xxx', '@48']],
Yegappan Lakshmanan87018252023-09-20 20:20:04 +0200234 \ 'jumpoptions': [['', 'stack'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200235 \ 'keymap': [['', 'accents'], ['/']],
236 \ 'keymodel': [['', 'startsel', 'stopsel', 'startsel,stopsel'], ['xxx']],
Bram Moolenaar63a2e362022-11-23 20:20:18 +0000237 \ 'keyprotocol': [['', 'xxx:none', 'yyy:mok2', 'zzz:kitty'],
Millycc15bbc2024-10-18 19:58:04 +0200238 \ ['xxx', ':none', 'xxx:', 'x:non', 'y:mok3', 'z:kittty']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100239 \ 'langmap': [['', 'xX', 'aA,bB'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200240 \ 'lispoptions': [['', 'expr:0', 'expr:1'], ['xxx', 'expr:x', 'expr:']],
241 \ 'listchars': [['', 'eol:x', 'tab:xy', 'tab:xyz', 'space:x',
242 \ 'multispace:xxxy', 'lead:x', 'leadmultispace:xxxy', 'trail:x',
243 \ 'extends:x', 'precedes:x', 'conceal:x', 'nbsp:x', 'eol:\\x24',
244 \ 'eol:\\u21b5', 'eol:\\U000021b5', 'eol:x,space:y'],
245 \ ['xxx', 'eol:']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100246 \ 'matchpairs': [['', '(:)', '(:),<:>'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200247 \ 'mkspellmem': [['10000,100,12'], ['', 'xxx', '10000,100']],
248 \ 'mouse': [['', 'n', 'v', 'i', 'c', 'h', 'a', 'r', 'nvi'],
249 \ ['xxx', 'n,v,i']],
250 \ 'mousemodel': [['', 'extend', 'popup', 'popup_setpos'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100251 \ 'mouseshape': [['', 'n:arrow'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200252 \ 'nrformats': [['', 'alpha', 'octal', 'hex', 'bin', 'unsigned', 'blank',
253 \ 'alpha,hex,bin'],
254 \ ['xxx']],
255 \ 'patchmode': [['', 'xxx', '.x'], [&backupext, '*']],
256 \ 'previewpopup': [['', 'height:13', 'width:20', 'highlight:That',
257 \ 'align:item', 'align:menu', 'border:on', 'border:off',
258 \ 'width:10,height:234,highlight:Mine'],
259 \ ['xxx', 'xxx:99', 'height:yes', 'width:no', 'align:xxx',
260 \ 'border:maybe', 'border:1', 'border:']],
261 \ 'printmbfont': [['', 'r:some', 'b:some', 'i:some', 'o:some', 'c:yes',
262 \ 'c:no', 'a:yes', 'a:no', 'b:Bold,c:yes'],
263 \ ['xxx', 'xxx,c:yes', 'xxx:', 'xxx:,c:yes']],
264 \ 'printoptions': [['', 'header:0', 'left:10pc,top:5pc'],
265 \ ['xxx', 'header:-1']],
266 \ 'scrollopt': [['', 'ver', 'hor', 'jump', 'ver,hor'], ['xxx']],
Bram Moolenaar0c1e3742019-12-27 13:49:24 +0100267 \ 'renderoptions': [[''], ['xxx']],
Yegappan Lakshmanan5da901b2023-02-27 12:47:47 +0000268 \ 'rightleftcmd': [['search'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200269 \ 'rulerformat': [['', 'xxx'], ['%-', '%(', '%15(%%']],
270 \ 'selection': [['old', 'inclusive', 'exclusive'], ['', 'xxx']],
271 \ 'selectmode': [['', 'mouse', 'key', 'cmd', 'key,cmd'], ['xxx']],
272 \ 'sessionoptions': [['', 'blank', 'curdir', 'sesdir',
273 \ 'help,options,slash'],
274 \ ['xxx', 'curdir,sesdir']],
275 \ 'showcmdloc': [['', 'last', 'statusline', 'tabline'], ['xxx']],
276 \ 'signcolumn': [['', 'auto', 'no', 'yes', 'number'], ['xxx', 'no,yes']],
Milly322ad0c2024-10-14 20:21:48 +0200277 \ 'spellfile': [['', 'file.en.add', 'xxx.en.add,yyy.gb.add,zzz.ja.add',
278 \ '/tmp/dir\ with\ space/en.utf-8.add',
279 \ '/tmp/dir\\,with\\,comma/en.utf-8.add'],
Millycc15bbc2024-10-18 19:58:04 +0200280 \ ['xxx', '/tmp/file', '/tmp/dir*with:invalid?char/file.en.add',
281 \ ',file.en.add', 'xxx,yyy.en.add', 'xxx.en.add,yyy,zzz.ja.add']],
Bram Moolenaar9a061cb2019-05-05 16:55:03 +0200282 \ 'spelllang': [['', 'xxx', 'sr@latin'], ['not&lang', "that\\\rthere"]],
Bram Moolenaar362b44b2020-06-10 21:47:00 +0200283 \ 'spelloptions': [['', 'camel'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200284 \ 'spellsuggest': [['', 'best', 'double', 'fast', '100', 'timeout:100',
285 \ 'timeout:-1', 'file:/tmp/file', 'expr:Func()', 'double,33'],
286 \ ['xxx', '-1', 'timeout:', 'best,double', 'double,fast']],
287 \ 'splitkeep': [['', 'cursor', 'screen', 'topline'], ['xxx']],
288 \ 'statusline': [['', 'xxx'], ['%$', '%{', '%{%', '%{%}', '%(', '%)']],
Yegappan Lakshmanan5da901b2023-02-27 12:47:47 +0000289 \ 'swapsync': [['', 'sync', 'fsync'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200290 \ 'switchbuf': [['', 'useopen', 'usetab', 'split', 'vsplit', 'newtab',
291 \ 'uselast', 'split,newtab'],
292 \ ['xxx']],
293 \ 'tabclose': [['', 'left', 'uselast', 'left,uselast'], ['xxx']],
294 \ 'tabline': [['', 'xxx'], ['%$', '%{', '%{%', '%{%}', '%(', '%)']],
295 \ 'tagcase': [['followic', 'followscs', 'ignore', 'match', 'smart'],
296 \ ['', 'xxx', 'smart,match']],
Bram Moolenaar17471e82017-11-26 23:47:18 +0100297 \ 'termencoding': [has('gui_gtk') ? [] : ['', 'utf-8'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200298 \ 'termwinkey': [['', 'f', '^Y', '^@', '<Esc>', '<t_xx>', "\u3042", '<',
299 \ '^'],
300 \ ['<xxx>', '<t_xxx>', '<Esc', '<t_xx']],
301 \ 'termwinsize': [['', '24x80', '0x80', '32x0', '0x0'],
302 \ ['xxx', '80', '8ax9', '24x80b']],
Bram Moolenaarc6ddce32019-02-08 12:47:03 +0100303 \ 'termwintype': [['', 'winpty', 'conpty'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200304 \ 'titlestring': [['', 'xxx', '%('], []],
305 \ 'toolbar': [['', 'icons', 'text', 'horiz', 'tooltips', 'icons,text'],
306 \ ['xxx']],
307 \ 'toolbariconsize': [['', 'tiny', 'small', 'medium', 'large', 'huge',
308 \ 'giant'],
309 \ ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100310 \ 'ttymouse': [['', 'xterm'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200311 \ 'varsofttabstop': [['8', '4,8,16,32'], ['xxx', '-1', '4,-1,20', '1,']],
312 \ 'vartabstop': [['8', '4,8,16,32'], ['xxx', '-1', '4,-1,20', '1,']],
313 \ 'verbosefile': [['', './Xfile'], []],
314 \ 'viewoptions': [['', 'cursor', 'folds', 'options', 'localoptions',
315 \ 'slash', 'unix', 'curdir', 'unix,slash'], ['xxx']],
316 \ 'viminfo': [['', '''50', '"30', "'100,<50,s10,h"], ['xxx', 'h']],
317 \ 'virtualedit': [['', 'block', 'insert', 'all', 'onemore', 'none',
318 \ 'NONE', 'all,block'],
319 \ ['xxx']],
320 \ 'whichwrap': [['', 'b', 's', 'h', 'l', '<', '>', '~', '[', ']', 'b,s',
321 \ 'bs'],
322 \ ['xxx']],
323 \ 'wildmode': [['', 'full', 'longest', 'list', 'lastused', 'list:full',
324 \ 'full,longest', 'full,full,full,full'],
325 \ ['xxx', 'a4', 'full,full,full,full,full']],
Yegappan Lakshmanan38b85cb2022-02-24 13:28:41 +0000326 \ 'wildoptions': [['', 'tagfile', 'pum', 'fuzzy'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200327 \ 'winaltkeys': [['no', 'yes', 'menu'], ['', 'xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100328 \
Millycc15bbc2024-10-18 19:58:04 +0200329 "\ skipped options
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100330 \ 'luadll': [[], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100331 \ 'perldll': [[], []],
332 \ 'pythondll': [[], []],
333 \ 'pythonthreedll': [[], []],
334 \ 'pyxversion': [[], []],
335 \ 'rubydll': [[], []],
336 \ 'tcldll': [[], []],
Millycc15bbc2024-10-18 19:58:04 +0200337 \ 'term': [[], []],
338 \ 'ttytype': [[], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100339 \
Millycc15bbc2024-10-18 19:58:04 +0200340 "\ default behaviours
Bram Moolenaara12e4032017-02-25 21:37:57 +0100341 \ 'othernum': [[-1, 0, 100], ['']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100342 \ 'otherstring': [['', 'xxx'], []],
343 \}
344
Milly6eca04e2024-10-21 22:20:51 +0200345" Two lists with values: values that pre- and post-processing in test.
346" Clear out t_WS: we don't want to resize the actual terminal.
347let test_prepost = {
348 \ 'browsedir': [["call mkdir('Xdir with space', 'D')"], []],
349 \ 'columns': [[
350 \ 'set t_WS=',
351 \ 'let save_columns = &columns'
352 \ ], [
353 \ 'let &columns = save_columns',
354 \ 'set t_WS&'
355 \ ]],
356 \ 'lines': [[
357 \ 'set t_WS=',
358 \ 'let save_lines = &lines'
359 \ ], [
360 \ 'let &lines = save_lines',
361 \ 'set t_WS&'
362 \ ]],
363 \ 'verbosefile': [[], ['call delete("Xfile")']],
364 \}
365
Millyb498c442024-10-17 21:05:31 +0200366const invalid_options = test_values->keys()
367 \->filter({-> v:val !~# '^other' && !exists($"&{v:val}")})
368if !empty(invalid_options)
369 throw $"Invalid option name in test_values: '{invalid_options->join("', '")}'"
370endif
371
Bram Moolenaar2f5463d2017-02-25 20:40:46 +01003721
Milly6eca04e2024-10-21 22:20:51 +0200373call search('struct vimoption options')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100374while 1
Milly6eca04e2024-10-21 22:20:51 +0200375 if search('{"', 'W') > end
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100376 break
377 endif
378 let line = getline('.')
Milly6eca04e2024-10-21 22:20:51 +0200379 let fullname = substitute(line, '.*{"\([^"]*\)".*', '\1', '')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100380 let shortname = substitute(line, '.*"\([^"]*\)".*', '\1', '')
381
Milly6eca04e2024-10-21 22:20:51 +0200382 let [valid_values, invalid_values] = test_values[
383 \ has_key(test_values, fullname) ? fullname
384 \ : line =~ 'P_NUM' ? 'othernum'
385 \ : 'otherstring']
386
387 if empty(valid_values) && empty(invalid_values)
388 continue
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100389 endif
Millycc15bbc2024-10-18 19:58:04 +0200390
Milly6eca04e2024-10-21 22:20:51 +0200391 call add(script, $"func Test_opt_set_{fullname}()")
392 call add(script, $"if exists('+{fullname}') && execute('set!') =~# '\\n..{fullname}\\([=\\n]\\|$\\)'")
393 call add(script, $"let l:saved = [&g:{fullname}, &l:{fullname}]")
394 call add(script, 'endif')
395
396 let [pre_processing, post_processing] = get(test_prepost, fullname, [[], []])
397 let script += pre_processing
398
399 if line =~ 'P_BOOL'
400 for opt in [fullname, shortname]
401 for cmd in ['set', 'setlocal', 'setglobal']
402 call add(script, $'{cmd} {opt}')
403 call add(script, $'{cmd} no{opt}')
404 call add(script, $'{cmd} inv{opt}')
405 call add(script, $'{cmd} {opt}!')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100406 endfor
Milly6eca04e2024-10-21 22:20:51 +0200407 endfor
408 else " P_NUM || P_STRING
409 " Normal tests
410 for opt in [fullname, shortname]
411 for cmd in ['set', 'setlocal', 'setglobal']
412 for val in valid_values
413 if local_noglobals->has_key(fullname) && cmd ==# 'setglobal'
414 " Skip `:setglobal {option}={val}` for local-noglobal option.
415 " It has no effect.
416 let pre = '" Skip local-noglobal: '
417 else
418 let pre = ''
419 endif
420 call add(script, $'{pre}{cmd} {opt}={val}')
421 endfor
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100422 endfor
Milly6eca04e2024-10-21 22:20:51 +0200423 " Testing to clear the local value and switch back to the global value.
424 if global_locals->has_key(fullname)
425 let swichback_val = global_locals[fullname]
426 call add(script, $'setlocal {opt}={swichback_val}')
427 endif
428 endfor
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100429
Milly6eca04e2024-10-21 22:20:51 +0200430 " Failure tests
431 " Setting an option can only fail when it's implemented.
432 call add(script, $"if exists('+{fullname}')")
433 for opt in [fullname, shortname]
434 for cmd in ['set', 'setlocal', 'setglobal']
435 for val in invalid_values
436 if val is# global_locals->get(fullname, {}) && cmd ==# 'setlocal'
437 " Skip setlocal switchback-value to global-local option. It will
438 " not result in failure.
439 let pre = '" Skip global-local: '
440 elseif local_noglobals->has_key(fullname) && cmd ==# 'setglobal'
441 " Skip setglobal to local-noglobal option. It will not result in
442 " failure.
443 let pre = '" Skip local-noglobal: '
444 elseif skip_setglobal_reasons->has_key(fullname) && cmd ==# 'setglobal'
445 " Skip setglobal to reasoned option. It will not result in failure.
446 let reason = skip_setglobal_reasons[fullname]
447 let pre = $'" Skip {reason}: '
448 else
449 let pre = ''
450 endif
451 let cmdline = $'{cmd} {opt}={val}'
452 call add(script, $"{pre}silent! call assert_fails({string(cmdline)})")
453 endfor
454 endfor
455 endfor
456 call add(script, "endif")
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100457 endif
Milly6eca04e2024-10-21 22:20:51 +0200458
459 " Cannot change 'termencoding' in GTK
460 if fullname != 'termencoding' || !has('gui_gtk')
461 call add(script, $'set {fullname}&')
462 call add(script, $'set {shortname}&')
463 call add(script, $"if exists('l:saved')")
464 call add(script, $"let [&g:{fullname}, &l:{fullname}] = l:saved")
465 call add(script, 'endif')
466 endif
467
468 let script += post_processing
469 call add(script, 'endfunc')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100470endwhile
471
Bram Moolenaare8512d72017-03-07 22:33:32 +0100472call writefile(script, 'opt_test.vim')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100473
Millyb498c442024-10-17 21:05:31 +0200474" Write error messages if error occurs.
Millyd4ad4c92024-10-06 16:27:28 +0200475catch
Millyb498c442024-10-17 21:05:31 +0200476 " Append errors to test.log
477 let error = $'Error: {v:exception} in {v:throwpoint}'
478 echoc error
479 split test.log
480 call append('$', error)
481 write
Millyd4ad4c92024-10-06 16:27:28 +0200482endtry
483
Bram Moolenaar5b3af142017-02-27 22:59:40 +0100484endif
485
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100486qa!
Milly6eca04e2024-10-21 22:20:51 +0200487
488" vim:sw=2:ts=8:noet:nolist:nosta: