blob: 1f1545382fff10e9b5ee1d2771e5015a97c85fed [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
Milly231480f2024-10-22 22:53:01 +02004set 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,
Milly231480f2024-10-22 22:53:01 +020028 \ undolevels: -123456,
Milly6eca04e2024-10-21 22:20:51 +020029 \})
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',
Milly6eca04e2024-10-21 22:20:51 +020048 \}
49
Milly231480f2024-10-22 22:53:01 +020050" Script header.
51" The test values contains multibyte characters.
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010052let script = [
Bram Moolenaar0c1e3742019-12-27 13:49:24 +010053 \ '" DO NOT EDIT: Generated with gen_opt_test.vim',
Milly6eca04e2024-10-21 22:20:51 +020054 \ '" Used by test_options_all.vim.',
Bram Moolenaar0c1e3742019-12-27 13:49:24 +010055 \ '',
Milly6eca04e2024-10-21 22:20:51 +020056 \ 'scriptencoding utf-8',
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010057 \ ]
58
Milly6eca04e2024-10-21 22:20:51 +020059b optiondefs.h
60const end = search('#define p_term', 'nw')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010061
Bram Moolenaar17471e82017-11-26 23:47:18 +010062" font name that works everywhere (hopefully)
63let fontname = has('win32') ? 'fixedsys' : 'fixed'
64
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010065" Two lists with values: values that work and values that fail.
66" When not listed, "othernum" or "otherstring" is used.
Millycc15bbc2024-10-18 19:58:04 +020067" When both lists are empty, skip tests for the option.
68" For boolean options, if non-empty a fixed test will be run, otherwise skipped.
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010069let test_values = {
Millycc15bbc2024-10-18 19:58:04 +020070 "\ boolean options
71 \ 'termguicolors': [
72 \ has('vtp') && !has('vcon') && !has('gui_running') ? [] : [1],
73 \ []],
74 \
75 "\ number options
64-bitman88d41ab2025-04-06 17:20:39 +020076 \ 'chistory': [[1, 2, 10, 50], [1000, -1]],
Bram Moolenaara2a89732022-08-31 14:46:18 +010077 \ 'cmdheight': [[1, 2, 10], [-1, 0]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010078 \ 'cmdwinheight': [[1, 2, 10], [-1, 0]],
Millycc15bbc2024-10-18 19:58:04 +020079 \ 'columns': [[12, 80, 10000], [-1, 0, 10]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010080 \ 'conceallevel': [[0, 1, 2, 3], [-1, 4, 99]],
81 \ 'foldcolumn': [[0, 1, 4, 12], [-1, 13, 999]],
82 \ 'helpheight': [[0, 10, 100], [-1]],
Millycc15bbc2024-10-18 19:58:04 +020083 \ 'history': [[0, 1, 100, 10000], [-1, 10001]],
84 \ 'iminsert': [[0, 1, 2], [-1, 3, 999]],
85 \ 'imsearch': [[-1, 0, 1, 2], [-2, 3, 999]],
Bram Moolenaar5c6dbcb2017-08-30 22:00:20 +020086 \ 'imstyle': [[0, 1], [-1, 2, 999]],
64-bitman88d41ab2025-04-06 17:20:39 +020087 \ 'lhistory': [[1, 2, 10, 50], [1000, -1]],
Millycc15bbc2024-10-18 19:58:04 +020088 \ 'lines': [[2, 24, 1000], [-1, 0, 1]],
89 \ 'linespace': [[-1, 0, 2, 4, 999], ['']],
Bram Moolenaarf8a07122019-07-01 22:06:07 +020090 \ 'numberwidth': [[1, 4, 8, 10, 11, 20], [-1, 0, 21]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010091 \ 'regexpengine': [[0, 1, 2], [-1, 3, 999]],
92 \ 'report': [[0, 1, 2, 9999], [-1]],
Christian Brabandt2e1f7572024-12-30 10:05:49 +010093 \ 'scroll': [[0, 1, 2, 15], [-1, 999]],
94 \ 'scrolljump': [[-100, -1, 0, 1, 2, 15], [-101, 999]],
Millycc15bbc2024-10-18 19:58:04 +020095 \ 'scrolloff': [[0, 1, 8, 999], [-1]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010096 \ 'shiftwidth': [[0, 1, 8, 999], [-1]],
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +020097 \ 'showtabpanel': [[0, 1, 2], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010098 \ 'sidescroll': [[0, 1, 8, 999], [-1]],
99 \ 'sidescrolloff': [[0, 1, 8, 999], [-1]],
Millycc15bbc2024-10-18 19:58:04 +0200100 \ 'tabstop': [[1, 4, 8, 12, 9999], [-1, 0, 10000]],
Milly6d5f4a02024-10-22 23:17:45 +0200101 \ 'termwinscroll': [[1, 100, 99999], [-1, 0]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100102 \ 'textwidth': [[0, 1, 8, 99], [-1]],
103 \ 'timeoutlen': [[0, 8, 99999], [-1]],
104 \ 'titlelen': [[0, 1, 8, 9999], [-1]],
105 \ 'updatecount': [[0, 1, 8, 9999], [-1]],
106 \ 'updatetime': [[0, 1, 8, 9999], [-1]],
Millycc15bbc2024-10-18 19:58:04 +0200107 \ 'verbose': [[-1, 0, 1, 8, 9999], ['']],
Millya9c6f902024-10-06 16:47:02 +0200108 \ 'wildchar': [[-1, 0, 100, 'x', '^Y', '^@', '<Esc>', '<t_xx>', '<', '^'],
Millycc15bbc2024-10-18 19:58:04 +0200109 \ ['', 'xxx', '<xxx>', '<t_xxx>', '<Esc', '<t_xx', '<C-C>',
110 \ '<NL>', '<CR>', K_KENTER]],
Millya9c6f902024-10-06 16:47:02 +0200111 \ 'wildcharm': [[-1, 0, 100, 'x', '^Y', '^@', '<Esc>', '<', '^'],
Millycc15bbc2024-10-18 19:58:04 +0200112 \ ['', 'xxx', '<xxx>', '<t_xxx>', '<Esc', '<t_xx', '<C-C>',
113 \ '<NL>', '<CR>', K_KENTER]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100114 \ 'winheight': [[1, 10, 999], [-1, 0]],
115 \ 'winminheight': [[0, 1], [-1]],
116 \ 'winminwidth': [[0, 1, 10], [-1]],
117 \ 'winwidth': [[1, 10, 999], [-1, 0]],
118 \
Millycc15bbc2024-10-18 19:58:04 +0200119 "\ string options
120 \ 'ambiwidth': [['', 'single', 'double'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100121 \ 'background': [['', 'light', 'dark'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200122 \ 'backspace': [[0, 1, 2, 3, '', 'indent', 'eol', 'start', 'nostop',
123 \ 'eol,start', 'indent,eol,nostop'],
124 \ [-1, 4, 'xxx']],
125 \ 'backupcopy': [['yes', 'no', 'auto'], ['', 'xxx', 'yes,no']],
126 \ 'backupext': [['xxx'], [&patchmode, '*']],
127 \ 'belloff': [['', 'all', 'backspace', 'cursor', 'complete', 'copy',
128 \ 'ctrlg', 'error', 'esc', 'ex', 'hangul', 'insertmode', 'lang',
129 \ 'mess', 'showmatch', 'operator', 'register', 'shell', 'spell',
130 \ 'term', 'wildmode', 'copy,error,shell'],
131 \ ['xxx']],
132 \ 'breakindentopt': [['', 'min:3', 'shift:4', 'shift:-2', 'sbr', 'list:5',
133 \ 'list:-1', 'column:10', 'column:-5', 'min:1,sbr,shift:2'],
134 \ ['xxx', 'min', 'min:x', 'min:-1', 'shift:x', 'sbr:1', 'list:x',
135 \ 'column:x']],
136 \ 'browsedir': [['', 'last', 'buffer', 'current', './Xdir\ with\ space'],
137 \ ['xxx']],
138 \ 'bufhidden': [['', 'hide', 'unload', 'delete', 'wipe'],
139 \ ['xxx', 'hide,wipe']],
140 \ 'buftype': [['', 'nofile', 'nowrite', 'acwrite', 'quickfix', 'help',
141 \ 'terminal', 'prompt', 'popup'],
142 \ ['xxx', 'help,nofile']],
143 \ 'casemap': [['', 'internal', 'keepascii', 'internal,keepascii'],
144 \ ['xxx']],
Millya9c6f902024-10-06 16:47:02 +0200145 \ 'cedit': [['', '^Y', '^@', '<Esc>', '<t_xx>'],
Millycc15bbc2024-10-18 19:58:04 +0200146 \ ['xxx', 'f', '<xxx>', '<t_xxx>', '<Esc', '<t_xx']],
147 \ 'clipboard': [['', 'unnamed', 'unnamedplus', 'autoselect',
148 \ 'autoselectplus', 'autoselectml', 'html', 'exclude:vimdisplay',
149 \ 'autoselect,unnamed', 'unnamed,exclude:.*'],
150 \ ['xxx', 'exclude:\\ze*', 'exclude:\\%(']],
151 \ 'colorcolumn': [['', '8', '+2', '1,+1,+3'], ['xxx', '-a', '1,', '1;']],
152 \ 'comments': [['', 'b:#', 'b:#,:%'], ['xxx', '-']],
Riley Bruins0a083062024-06-03 20:40:45 +0200153 \ 'commentstring': [['', '/*\ %s\ */'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200154 \ 'complete': [['', '.', 'w', 'b', 'u', 'U', 'i', 'd', ']', 't',
155 \ 'k', 'kspell', 'k/tmp/dir\\\ with\\\ space/*',
156 \ 's', 's/tmp/dir\\\ with\\\ space/*',
157 \ 'w,b,k/tmp/dir\\\ with\\\ space/*,s'],
158 \ ['xxx']],
159 \ 'concealcursor': [['', 'n', 'v', 'i', 'c', 'nvic'], ['xxx']],
160 \ 'completeopt': [['', 'menu', 'menuone', 'longest', 'preview', 'popup',
glepniredd4ac32025-01-29 18:53:51 +0100161 \ 'popuphidden', 'noinsert', 'noselect', 'fuzzy', "preinsert", 'menu,longest'],
Millycc15bbc2024-10-18 19:58:04 +0200162 \ ['xxx', 'menu,,,longest,']],
glepnirf31cfa22025-03-06 21:59:13 +0100163 \ 'completefuzzycollect': [['', 'keyword', 'files', 'whole_line',
164 \ 'keyword,whole_line', 'files,whole_line', 'keyword,files,whole_line'],
165 \ ['xxx', 'keyword,,,whole_line,']],
Millycc15bbc2024-10-18 19:58:04 +0200166 \ 'completeitemalign': [['abbr,kind,menu', 'menu,abbr,kind'],
167 \ ['', 'xxx', 'abbr', 'abbr,menu', 'abbr,menu,kind,abbr',
168 \ 'abbr1234,kind,menu']],
169 \ 'completepopup': [['', 'height:13', 'width:20', 'highlight:That',
170 \ 'align:item', 'align:menu', 'border:on', 'border:off',
171 \ 'width:10,height:234,highlight:Mine'],
172 \ ['xxx', 'xxx:99', 'height:yes', 'width:no', 'align:xxx',
173 \ 'border:maybe', 'border:1', 'border:']],
Bram Moolenaard4404b42019-07-28 18:38:09 +0200174 \ 'completeslash': [['', 'slash', 'backslash'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100175 \ 'cryptmethod': [['', 'zip'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200176 \ 'cscopequickfix': [['', 's-', 'g-', 'd-', 'c-', 't-', 'e-', 'f-', 'i-',
177 \ 'a-', 's-,c+,e0'],
178 \ ['xxx', 's,g,d']],
179 \ 'cursorlineopt': [['both', 'line', 'number', 'screenline',
180 \ 'line,number'],
181 \ ['', 'xxx', 'line,screenline']],
182 \ 'debug': [['', 'msg', 'throw', 'beep'], ['xxx']],
183 \ 'diffopt': [['', 'filler', 'context:0', 'context:999', 'iblank',
184 \ 'icase', 'iwhite', 'iwhiteall', 'horizontal', 'vertical',
185 \ 'closeoff', 'hiddenoff', 'foldcolumn:0', 'foldcolumn:12',
186 \ 'followwrap', 'internal', 'indent-heuristic', 'algorithm:myers',
zeertzjqccd7f452025-02-03 18:49:49 +0100187 \ 'icase,iwhite', 'algorithm:minimal', 'algorithm:patience',
Yee Cheng Chin9943d472025-03-26 19:41:02 +0100188 \ 'algorithm:histogram', 'inline:none', 'inline:simple',
189 \ 'inline:char', 'inline:word', 'inline:char,inline:word', 'linematch:5'],
zeertzjqccd7f452025-02-03 18:49:49 +0100190 \ ['xxx', 'foldcolumn:', 'foldcolumn:x', 'foldcolumn:xxx',
191 \ 'linematch:', 'linematch:x', 'linematch:xxx', 'algorithm:',
Yee Cheng Chin9943d472025-03-26 19:41:02 +0100192 \ 'algorithm:xxx', 'context:', 'context:x', 'context:xxx',
193 \ 'inline:xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200194 \ 'display': [['', 'lastline', 'truncate', 'uhex', 'lastline,uhex'],
195 \ ['xxx']],
196 \ 'eadirection': [['', 'both', 'ver', 'hor'], ['xxx', 'ver,hor']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100197 \ 'encoding': [['latin1'], ['xxx', '']],
Millycc15bbc2024-10-18 19:58:04 +0200198 \ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter'],
199 \ ['xxx']],
Luuk van Baalb7147f82025-02-08 18:52:39 +0100200 \ 'eventignorewin': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter'],
201 \ ['xxx', 'WinNew']],
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',
glepnirb8762042025-04-07 20:57:14 +0200207 \ 'trunc:_', 'trunc:_,eob:x,trunc:_',
208 \ 'stl:\ ,vert:\|,fold:\\,trunc:…,diff:x'],
209 \ ['xxx', 'vert:', 'trunc:', "trunc:\b"]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100210 \ 'foldclose': [['', 'all'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200211 \ 'foldmethod': [['manual', 'indent', 'expr', 'marker', 'syntax', 'diff'],
212 \ ['', 'xxx', 'expr,diff']],
213 \ 'foldopen': [['', 'all', 'block', 'hor', 'insert', 'jump', 'mark',
214 \ 'percent', 'quickfix', 'search', 'tag', 'undo', 'hor,jump'],
215 \ ['xxx']],
216 \ 'foldmarker': [['((,))'], ['', 'xxx', '{{{,']],
217 \ 'formatoptions': [['', 't', 'c', 'r', 'o', '/', 'q', 'w', 'a', 'n', '2',
218 \ 'v', 'b', 'l', 'm', 'M', 'B', '1', ']', 'j', 'p', 'vt', 'v,t'],
219 \ ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100220 \ 'guicursor': [['', 'n:block-Cursor'], ['xxx']],
Bram Moolenaar17471e82017-11-26 23:47:18 +0100221 \ 'guifont': [['', fontname], []],
222 \ 'guifontwide': [['', fontname], []],
223 \ 'guifontset': [['', fontname], []],
Millycc15bbc2024-10-18 19:58:04 +0200224 \ 'guioptions': [['', '!', 'a', 'P', 'A', 'c', 'd', 'e', 'f', 'i', 'm',
225 \ 'M', 'g', 't', 'T', 'r', 'R', 'l', 'L', 'b', 'h', 'v', 'p', 'F',
226 \ 'k', '!abvR'],
227 \ ['xxx', 'a,b']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100228 \ 'helplang': [['', 'de', 'de,it'], ['xxx']],
229 \ 'highlight': [['', 'e:Error'], ['xxx']],
Bram Moolenaar86e57922017-04-23 18:44:26 +0200230 \ 'imactivatekey': [['', 'S-space'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100231 \ 'isfname': [['', '@', '@,48-52'], ['xxx', '@48']],
232 \ 'isident': [['', '@', '@,48-52'], ['xxx', '@48']],
glepnirbcd59952025-04-24 21:48:35 +0200233 \ 'isexpand': [['', '.,->', '/,/*,\\,'], [',,', '\\,,']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100234 \ 'iskeyword': [['', '@', '@,48-52'], ['xxx', '@48']],
235 \ 'isprint': [['', '@', '@,48-52'], ['xxx', '@48']],
Yegappan Lakshmanan87018252023-09-20 20:20:04 +0200236 \ 'jumpoptions': [['', 'stack'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200237 \ 'keymap': [['', 'accents'], ['/']],
238 \ 'keymodel': [['', 'startsel', 'stopsel', 'startsel,stopsel'], ['xxx']],
Bram Moolenaar63a2e362022-11-23 20:20:18 +0000239 \ 'keyprotocol': [['', 'xxx:none', 'yyy:mok2', 'zzz:kitty'],
Millycc15bbc2024-10-18 19:58:04 +0200240 \ ['xxx', ':none', 'xxx:', 'x:non', 'y:mok3', 'z:kittty']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100241 \ 'langmap': [['', 'xX', 'aA,bB'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200242 \ 'lispoptions': [['', 'expr:0', 'expr:1'], ['xxx', 'expr:x', 'expr:']],
243 \ 'listchars': [['', 'eol:x', 'tab:xy', 'tab:xyz', 'space:x',
244 \ 'multispace:xxxy', 'lead:x', 'leadmultispace:xxxy', 'trail:x',
245 \ 'extends:x', 'precedes:x', 'conceal:x', 'nbsp:x', 'eol:\\x24',
246 \ 'eol:\\u21b5', 'eol:\\U000021b5', 'eol:x,space:y'],
247 \ ['xxx', 'eol:']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100248 \ 'matchpairs': [['', '(:)', '(:),<:>'], ['xxx']],
Christian Brabandt51d4d842024-12-06 17:26:25 +0100249 \ 'messagesopt': [['hit-enter,history:1', 'hit-enter,history:10000',
250 \ 'history:100,wait:100', 'history:0,wait:0',
251 \ 'hit-enter,history:1,wait:1'],
252 \ ['xxx', 'history:500', 'hit-enter,history:-1',
Shougo Matsushitad9e9f892024-12-07 16:00:25 +0100253 \ 'hit-enter,history:10001', 'history:0,wait:10001',
h-east65be8342024-12-08 10:05:26 +0100254 \ 'hit-enter', 'history:10,wait:99999999999999999999',
255 \ 'history:99999999999999999999,wait:10', 'wait:10',
256 \ 'history:-10', 'history:10,wait:-10']],
Millycc15bbc2024-10-18 19:58:04 +0200257 \ 'mkspellmem': [['10000,100,12'], ['', 'xxx', '10000,100']],
258 \ 'mouse': [['', 'n', 'v', 'i', 'c', 'h', 'a', 'r', 'nvi'],
259 \ ['xxx', 'n,v,i']],
260 \ 'mousemodel': [['', 'extend', 'popup', 'popup_setpos'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100261 \ 'mouseshape': [['', 'n:arrow'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200262 \ 'nrformats': [['', 'alpha', 'octal', 'hex', 'bin', 'unsigned', 'blank',
263 \ 'alpha,hex,bin'],
264 \ ['xxx']],
265 \ 'patchmode': [['', 'xxx', '.x'], [&backupext, '*']],
266 \ 'previewpopup': [['', 'height:13', 'width:20', 'highlight:That',
267 \ 'align:item', 'align:menu', 'border:on', 'border:off',
268 \ 'width:10,height:234,highlight:Mine'],
269 \ ['xxx', 'xxx:99', 'height:yes', 'width:no', 'align:xxx',
270 \ 'border:maybe', 'border:1', 'border:']],
271 \ 'printmbfont': [['', 'r:some', 'b:some', 'i:some', 'o:some', 'c:yes',
272 \ 'c:no', 'a:yes', 'a:no', 'b:Bold,c:yes'],
273 \ ['xxx', 'xxx,c:yes', 'xxx:', 'xxx:,c:yes']],
274 \ 'printoptions': [['', 'header:0', 'left:10pc,top:5pc'],
275 \ ['xxx', 'header:-1']],
276 \ 'scrollopt': [['', 'ver', 'hor', 'jump', 'ver,hor'], ['xxx']],
Bram Moolenaar0c1e3742019-12-27 13:49:24 +0100277 \ 'renderoptions': [[''], ['xxx']],
Yegappan Lakshmanan5da901b2023-02-27 12:47:47 +0000278 \ 'rightleftcmd': [['search'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200279 \ 'rulerformat': [['', 'xxx'], ['%-', '%(', '%15(%%']],
280 \ 'selection': [['old', 'inclusive', 'exclusive'], ['', 'xxx']],
281 \ 'selectmode': [['', 'mouse', 'key', 'cmd', 'key,cmd'], ['xxx']],
282 \ 'sessionoptions': [['', 'blank', 'curdir', 'sesdir',
283 \ 'help,options,slash'],
284 \ ['xxx', 'curdir,sesdir']],
285 \ 'showcmdloc': [['', 'last', 'statusline', 'tabline'], ['xxx']],
286 \ 'signcolumn': [['', 'auto', 'no', 'yes', 'number'], ['xxx', 'no,yes']],
Milly322ad0c2024-10-14 20:21:48 +0200287 \ 'spellfile': [['', 'file.en.add', 'xxx.en.add,yyy.gb.add,zzz.ja.add',
288 \ '/tmp/dir\ with\ space/en.utf-8.add',
289 \ '/tmp/dir\\,with\\,comma/en.utf-8.add'],
Millycc15bbc2024-10-18 19:58:04 +0200290 \ ['xxx', '/tmp/file', '/tmp/dir*with:invalid?char/file.en.add',
291 \ ',file.en.add', 'xxx,yyy.en.add', 'xxx.en.add,yyy,zzz.ja.add']],
Bram Moolenaar9a061cb2019-05-05 16:55:03 +0200292 \ 'spelllang': [['', 'xxx', 'sr@latin'], ['not&lang', "that\\\rthere"]],
Bram Moolenaar362b44b2020-06-10 21:47:00 +0200293 \ 'spelloptions': [['', 'camel'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200294 \ 'spellsuggest': [['', 'best', 'double', 'fast', '100', 'timeout:100',
295 \ 'timeout:-1', 'file:/tmp/file', 'expr:Func()', 'double,33'],
296 \ ['xxx', '-1', 'timeout:', 'best,double', 'double,fast']],
297 \ 'splitkeep': [['', 'cursor', 'screen', 'topline'], ['xxx']],
298 \ 'statusline': [['', 'xxx'], ['%$', '%{', '%{%', '%{%}', '%(', '%)']],
Yegappan Lakshmanan5da901b2023-02-27 12:47:47 +0000299 \ 'swapsync': [['', 'sync', 'fsync'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200300 \ 'switchbuf': [['', 'useopen', 'usetab', 'split', 'vsplit', 'newtab',
301 \ 'uselast', 'split,newtab'],
302 \ ['xxx']],
303 \ 'tabclose': [['', 'left', 'uselast', 'left,uselast'], ['xxx']],
304 \ 'tabline': [['', 'xxx'], ['%$', '%{', '%{%', '%{%}', '%(', '%)']],
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200305 \ 'tabpanel': [['', 'aaa', 'bbb'], []],
306 \ 'tabpanelopt': [['', 'align:left', 'align:right', 'vert', 'columns:0',
307 \ 'columns:20', 'columns:999'],
308 \ ['xxx', 'align:', 'align:middle', 'colomns:', 'cols:10',
309 \ 'cols:-1']],
Millycc15bbc2024-10-18 19:58:04 +0200310 \ 'tagcase': [['followic', 'followscs', 'ignore', 'match', 'smart'],
311 \ ['', 'xxx', 'smart,match']],
Bram Moolenaar17471e82017-11-26 23:47:18 +0100312 \ 'termencoding': [has('gui_gtk') ? [] : ['', 'utf-8'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200313 \ 'termwinkey': [['', 'f', '^Y', '^@', '<Esc>', '<t_xx>', "\u3042", '<',
314 \ '^'],
315 \ ['<xxx>', '<t_xxx>', '<Esc', '<t_xx']],
316 \ 'termwinsize': [['', '24x80', '0x80', '32x0', '0x0'],
317 \ ['xxx', '80', '8ax9', '24x80b']],
Bram Moolenaarc6ddce32019-02-08 12:47:03 +0100318 \ 'termwintype': [['', 'winpty', 'conpty'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200319 \ 'titlestring': [['', 'xxx', '%('], []],
320 \ 'toolbar': [['', 'icons', 'text', 'horiz', 'tooltips', 'icons,text'],
321 \ ['xxx']],
322 \ 'toolbariconsize': [['', 'tiny', 'small', 'medium', 'large', 'huge',
323 \ 'giant'],
324 \ ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100325 \ 'ttymouse': [['', 'xterm'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200326 \ 'varsofttabstop': [['8', '4,8,16,32'], ['xxx', '-1', '4,-1,20', '1,']],
327 \ 'vartabstop': [['8', '4,8,16,32'], ['xxx', '-1', '4,-1,20', '1,']],
328 \ 'verbosefile': [['', './Xfile'], []],
329 \ 'viewoptions': [['', 'cursor', 'folds', 'options', 'localoptions',
330 \ 'slash', 'unix', 'curdir', 'unix,slash'], ['xxx']],
331 \ 'viminfo': [['', '''50', '"30', "'100,<50,s10,h"], ['xxx', 'h']],
332 \ 'virtualedit': [['', 'block', 'insert', 'all', 'onemore', 'none',
333 \ 'NONE', 'all,block'],
334 \ ['xxx']],
335 \ 'whichwrap': [['', 'b', 's', 'h', 'l', '<', '>', '~', '[', ']', 'b,s',
336 \ 'bs'],
337 \ ['xxx']],
338 \ 'wildmode': [['', 'full', 'longest', 'list', 'lastused', 'list:full',
Girish Palya2bacc3e2025-03-02 22:55:57 +0100339 \ 'noselect', 'noselect,full', 'noselect:lastused,full',
Millycc15bbc2024-10-18 19:58:04 +0200340 \ 'full,longest', 'full,full,full,full'],
341 \ ['xxx', 'a4', 'full,full,full,full,full']],
Yegappan Lakshmanan38b85cb2022-02-24 13:28:41 +0000342 \ 'wildoptions': [['', 'tagfile', 'pum', 'fuzzy'], ['xxx']],
Millycc15bbc2024-10-18 19:58:04 +0200343 \ 'winaltkeys': [['no', 'yes', 'menu'], ['', 'xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100344 \
Millycc15bbc2024-10-18 19:58:04 +0200345 "\ skipped options
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100346 \ 'luadll': [[], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100347 \ 'perldll': [[], []],
348 \ 'pythondll': [[], []],
349 \ 'pythonthreedll': [[], []],
350 \ 'pyxversion': [[], []],
351 \ 'rubydll': [[], []],
352 \ 'tcldll': [[], []],
Millycc15bbc2024-10-18 19:58:04 +0200353 \ 'term': [[], []],
354 \ 'ttytype': [[], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100355 \
Millycc15bbc2024-10-18 19:58:04 +0200356 "\ default behaviours
Bram Moolenaara12e4032017-02-25 21:37:57 +0100357 \ 'othernum': [[-1, 0, 100], ['']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100358 \ 'otherstring': [['', 'xxx'], []],
359 \}
360
Milly6eca04e2024-10-21 22:20:51 +0200361" Two lists with values: values that pre- and post-processing in test.
362" Clear out t_WS: we don't want to resize the actual terminal.
363let test_prepost = {
364 \ 'browsedir': [["call mkdir('Xdir with space', 'D')"], []],
365 \ 'columns': [[
366 \ 'set t_WS=',
367 \ 'let save_columns = &columns'
368 \ ], [
369 \ 'let &columns = save_columns',
370 \ 'set t_WS&'
371 \ ]],
372 \ 'lines': [[
373 \ 'set t_WS=',
374 \ 'let save_lines = &lines'
375 \ ], [
376 \ 'let &lines = save_lines',
377 \ 'set t_WS&'
378 \ ]],
379 \ 'verbosefile': [[], ['call delete("Xfile")']],
380 \}
381
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200382let invalid_options = test_values->keys()
Millyb498c442024-10-17 21:05:31 +0200383 \->filter({-> v:val !~# '^other' && !exists($"&{v:val}")})
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200384for s:skip_option in [
385 \ [!has('tabpanel'), 'tabpanel'],
386 \ [!has('tabpanel'), 'tabpanelopt'],
387 \ [!has('tabpanel'), 'showtabpanel'],
388 \ ]
389 if s:skip_option[0]
390 call remove(invalid_options, s:skip_option[1])
391 endif
392endfor
Millyb498c442024-10-17 21:05:31 +0200393if !empty(invalid_options)
394 throw $"Invalid option name in test_values: '{invalid_options->join("', '")}'"
395endif
396
Bram Moolenaar2f5463d2017-02-25 20:40:46 +01003971
Milly6eca04e2024-10-21 22:20:51 +0200398call search('struct vimoption options')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100399while 1
Milly6eca04e2024-10-21 22:20:51 +0200400 if search('{"', 'W') > end
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100401 break
402 endif
403 let line = getline('.')
Milly6eca04e2024-10-21 22:20:51 +0200404 let fullname = substitute(line, '.*{"\([^"]*\)".*', '\1', '')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100405 let shortname = substitute(line, '.*"\([^"]*\)".*', '\1', '')
406
Milly6eca04e2024-10-21 22:20:51 +0200407 let [valid_values, invalid_values] = test_values[
408 \ has_key(test_values, fullname) ? fullname
409 \ : line =~ 'P_NUM' ? 'othernum'
410 \ : 'otherstring']
411
412 if empty(valid_values) && empty(invalid_values)
413 continue
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100414 endif
Millycc15bbc2024-10-18 19:58:04 +0200415
Milly6eca04e2024-10-21 22:20:51 +0200416 call add(script, $"func Test_opt_set_{fullname}()")
417 call add(script, $"if exists('+{fullname}') && execute('set!') =~# '\\n..{fullname}\\([=\\n]\\|$\\)'")
418 call add(script, $"let l:saved = [&g:{fullname}, &l:{fullname}]")
419 call add(script, 'endif')
420
421 let [pre_processing, post_processing] = get(test_prepost, fullname, [[], []])
422 let script += pre_processing
423
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200424 " Setting an option can only fail when it's implemented.
425 call add(script, $"if exists('+{fullname}')")
Milly6eca04e2024-10-21 22:20:51 +0200426 if line =~ 'P_BOOL'
427 for opt in [fullname, shortname]
428 for cmd in ['set', 'setlocal', 'setglobal']
429 call add(script, $'{cmd} {opt}')
430 call add(script, $'{cmd} no{opt}')
431 call add(script, $'{cmd} inv{opt}')
432 call add(script, $'{cmd} {opt}!')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100433 endfor
Milly6eca04e2024-10-21 22:20:51 +0200434 endfor
435 else " P_NUM || P_STRING
436 " Normal tests
437 for opt in [fullname, shortname]
438 for cmd in ['set', 'setlocal', 'setglobal']
439 for val in valid_values
440 if local_noglobals->has_key(fullname) && cmd ==# 'setglobal'
441 " Skip `:setglobal {option}={val}` for local-noglobal option.
442 " It has no effect.
443 let pre = '" Skip local-noglobal: '
444 else
445 let pre = ''
446 endif
447 call add(script, $'{pre}{cmd} {opt}={val}')
448 endfor
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100449 endfor
Milly6eca04e2024-10-21 22:20:51 +0200450 " Testing to clear the local value and switch back to the global value.
451 if global_locals->has_key(fullname)
Milly231480f2024-10-22 22:53:01 +0200452 let switchback_val = global_locals[fullname]
453 call add(script, $'setlocal {opt}={switchback_val}')
454 call add(script, $'call assert_equal(&g:{fullname}, &{fullname})')
Milly6eca04e2024-10-21 22:20:51 +0200455 endif
456 endfor
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100457
Milly6eca04e2024-10-21 22:20:51 +0200458 " Failure tests
Milly6eca04e2024-10-21 22:20:51 +0200459 for opt in [fullname, shortname]
460 for cmd in ['set', 'setlocal', 'setglobal']
461 for val in invalid_values
462 if val is# global_locals->get(fullname, {}) && cmd ==# 'setlocal'
463 " Skip setlocal switchback-value to global-local option. It will
464 " not result in failure.
465 let pre = '" Skip global-local: '
466 elseif local_noglobals->has_key(fullname) && cmd ==# 'setglobal'
467 " Skip setglobal to local-noglobal option. It will not result in
468 " failure.
469 let pre = '" Skip local-noglobal: '
470 elseif skip_setglobal_reasons->has_key(fullname) && cmd ==# 'setglobal'
471 " Skip setglobal to reasoned option. It will not result in failure.
472 let reason = skip_setglobal_reasons[fullname]
473 let pre = $'" Skip {reason}: '
474 else
475 let pre = ''
476 endif
477 let cmdline = $'{cmd} {opt}={val}'
478 call add(script, $"{pre}silent! call assert_fails({string(cmdline)})")
479 endfor
480 endfor
481 endfor
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100482 endif
Milly6eca04e2024-10-21 22:20:51 +0200483
484 " Cannot change 'termencoding' in GTK
485 if fullname != 'termencoding' || !has('gui_gtk')
486 call add(script, $'set {fullname}&')
487 call add(script, $'set {shortname}&')
488 call add(script, $"if exists('l:saved')")
489 call add(script, $"let [&g:{fullname}, &l:{fullname}] = l:saved")
490 call add(script, 'endif')
491 endif
492
Naruhiko Nishinobe5bd4d2025-05-14 21:20:28 +0200493 call add(script, "endif")
494
Milly6eca04e2024-10-21 22:20:51 +0200495 let script += post_processing
496 call add(script, 'endfunc')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100497endwhile
498
Bram Moolenaare8512d72017-03-07 22:33:32 +0100499call writefile(script, 'opt_test.vim')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100500
Millyb498c442024-10-17 21:05:31 +0200501" Write error messages if error occurs.
Millyd4ad4c92024-10-06 16:27:28 +0200502catch
Millyb498c442024-10-17 21:05:31 +0200503 " Append errors to test.log
504 let error = $'Error: {v:exception} in {v:throwpoint}'
505 echoc error
506 split test.log
507 call append('$', error)
508 write
Millyd4ad4c92024-10-06 16:27:28 +0200509endtry
510
Bram Moolenaar5b3af142017-02-27 22:59:40 +0100511endif
512
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100513qa!
Milly6eca04e2024-10-21 22:20:51 +0200514
zeertzjq3e5bbb82024-10-22 23:11:27 +0200515" vim:sw=2:ts=8:noet:nosta: