gen_opt_test.vim (24095B)
1 " Script to generate test/old/testdir/opt_test.vim from src/nvim/options.lua 2 " and runtime/doc/options.txt 3 4 set cpo&vim 5 6 " Only do this when build with the +eval feature. 7 if 1 8 9 try 10 11 set nomore 12 13 const K_KENTER = -16715 14 15 " 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. 18 b options.txt 19 call cursor(1, 1) 20 let global_locals = {} 21 while search("^'[^']*'.*\\n.*|global-local", 'W') 22 let fullname = getline('.')->matchstr("^'\\zs[^']*") 23 let global_locals[fullname] = '' 24 endwhile 25 call extend(global_locals, #{ 26 \ scrolloff: -1, 27 \ sidescrolloff: -1, 28 \ undolevels: -123456, 29 \}) 30 31 " Get local-noglobal options. 32 " "key" is full-name of the option. 33 " "value" is no used. 34 b options.txt 35 call cursor(1, 1) 36 let local_noglobals = {} 37 while search("^'[^']*'.*\\n.*|local-noglobal", 'W') 38 let fullname = getline('.')->matchstr("^'\\zs[^']*") 39 let local_noglobals[fullname] = v:true 40 endwhile 41 42 " Options to skip `setglobal` tests. 43 " "key" is full-name of the option. 44 " "value" is the reason. 45 let 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 \} 49 50 " Script header. 51 " The test values contains multibyte characters. 52 let script = [ 53 \ '" DO NOT EDIT: Generated with gen_opt_test.vim', 54 \ '" Used by test_options_all.vim.', 55 \ '', 56 \ 'scriptencoding utf-8', 57 \ ] 58 59 let options = luaeval('loadfile("../../../src/nvim/options.lua")().options') 60 61 " font name that works everywhere (hopefully) 62 let fontname = has('win32') ? 'fixedsys' : 'fixed' 63 64 " Two lists with values: values that work and values that fail. 65 " When not listed, "othernum" or "otherstring" is used. 66 " When both lists are empty, skip tests for the option. 67 " For boolean options, if non-empty a fixed test will be run, otherwise skipped. 68 let test_values = { 69 "\ Nvim-only options 70 \ 'channel': [[], []], 71 \ 'inccommand': [['', 'nosplit', 'split'], ['xxx']], 72 \ 'mousescroll': [['ver:1', 'hor:2', 'ver:1,hor:2', 'hor:1,ver:2'], 73 \ ['xxx', 'ver:1,xxx', 'hor:2,xxx']], 74 \ 'redrawdebug': [[''], ['xxx']], 75 \ 'shada': [['', '''50', '"30'], ['xxx']], 76 \ 'termpastefilter': [['BS', 'HT', 'FF', 'ESC', 'DEL', 'C0', 'C1', 'C0,C1'], 77 \ ['xxx', 'C0,C1,xxx']], 78 \ 'winborder': [['rounded', 'none', 'single', 'solid'], ['xxx', 'none,solid']], 79 \ 'winhighlight': [['', 'a:b', 'a:', 'a:b,c:d'], 80 \ ['a', ':', ':b', 'a:b:c', 'a:/', '/:b', ',', 'a:b,,', 'a:b,c']], 81 \ 82 "\ Options for which Nvim has different allowed values 83 \ 'backspace': [[2, '', 'indent', 'eol', 'start', 'nostop', 84 \ 'eol,start', 'indent,eol,nostop'], 85 \ [-1, 4, 'xxx']], 86 \ 'buftype': [['', 'nofile', 'nowrite', 'acwrite', 'quickfix', 'help', 87 \ 'prompt'], 88 \ ['xxx', 'help,nofile']], 89 \ 'clipboard': [['', 'unnamed'], ['xxx', '\ze*', 'exclude:\\%(']], 90 \ 'completeopt': [['', 'menu', 'menuone', 'longest', 'preview', 'popup', 91 \ 'noinsert', 'noselect', 'fuzzy', 'preinsert', 'menu,longest'], 92 \ ['xxx', 'menu,,,longest,']], 93 \ 'encoding': [['utf8'], []], 94 \ 'foldcolumn': [[0, 1, 4, 'auto', 'auto:1', 'auto:9'], [-1, 13, 999]], 95 \ 'foldlevel': [[0, 100], [-1, '']], 96 \ 'highlight': [[&highlight], []], 97 \ 'iminsert': [[0, 1], [-1, 2, 3, 999]], 98 \ 'imsearch': [[-1, 0, 1], [-2, 2, 3, 999]], 99 \ 'pumborder': [['rounded', 'none', 'single', 'solid'], ['xxx', 'none,solid']], 100 \ 'signcolumn': [['auto', 'no', 'yes', 'number', 'yes:1', 'auto:1-9'], 101 \ ['', 'xxx', 'no,yes', 'auto:0-9', 'auto:9-1', 'auto:1-@']], 102 \ 'writedelay': [[0, 100], [-1, '']], 103 \ 104 "\ boolean options 105 \ 'termguicolors': [ 106 \ has('vtp') && !has('vcon') && !has('gui_running') ? [] : [1], 107 \ []], 108 \ 109 "\ number options 110 \ 'chistory': [[1, 2, 10, 50], [1000, -1]], 111 \ 'cmdheight': [[0, 1, 2, 10], [-1]], 112 \ 'cmdwinheight': [[1, 2, 10], [-1, 0]], 113 \ 'columns': [[12, 80, 10000], [-1, 0, 10]], 114 \ 'conceallevel': [[0, 1, 2, 3], [-1, 4, 99]], 115 "\ 'foldcolumn': [[0, 1, 4, 12], [-1, 13, 999]], 116 \ 'helpheight': [[0, 10, 100], [-1]], 117 \ 'history': [[0, 1, 100, 10000], [-1, 10001]], 118 "\ 'iminsert': [[0, 1, 2], [-1, 3, 999]], 119 "\ 'imsearch': [[-1, 0, 1, 2], [-2, 3, 999]], 120 "\ 'imstyle': [[0, 1], [-1, 2, 999]], 121 \ 'lhistory': [[1, 2, 10, 50], [1000, -1]], 122 \ 'lines': [[2, 24, 1000], [-1, 0, 1]], 123 \ 'linespace': [[-1, 0, 2, 4, 999], ['']], 124 \ 'numberwidth': [[1, 4, 8, 10, 11, 20], [-1, 0, 21]], 125 \ 'regexpengine': [[0, 1, 2], [-1, 3, 999]], 126 \ 'report': [[0, 1, 2, 9999], [-1]], 127 \ 'scroll': [[0, 1, 2, 15], [-1, 999]], 128 \ 'scrolljump': [[-100, -1, 0, 1, 2, 15], [-101, 999]], 129 \ 'scrolloff': [[0, 1, 8, 999], [-1]], 130 \ 'shiftwidth': [[0, 1, 8, 999], [-1]], 131 \ 'sidescroll': [[0, 1, 8, 999], [-1]], 132 \ 'sidescrolloff': [[0, 1, 8, 999], [-1]], 133 \ 'tabstop': [[1, 4, 8, 12, 9999], [-1, 0, 10000]], 134 \ 'textwidth': [[0, 1, 8, 99], [-1]], 135 \ 'timeoutlen': [[0, 8, 99999], [-1]], 136 \ 'titlelen': [[0, 1, 8, 9999], [-1]], 137 \ 'updatecount': [[0, 1, 8, 9999], [-1]], 138 \ 'updatetime': [[0, 1, 8, 9999], [-1]], 139 \ 'verbose': [[-1, 0, 1, 8, 9999], ['']], 140 \ 'wildchar': [[-1, 0, 100, 'x', '^Y', '^@', '<Esc>', '<t_xx>', '<', '^'], 141 \ ['', 'xxx', '<xxx>', '<t_xxx>', '<Esc', '<t_xx', '<C-C>', 142 \ '<NL>', '<CR>', K_KENTER]], 143 \ 'wildcharm': [[-1, 0, 100, 'x', '^Y', '^@', '<Esc>', '<', '^'], 144 \ ['', 'xxx', '<xxx>', '<t_xxx>', '<Esc', '<t_xx', '<C-C>', 145 \ '<NL>', '<CR>', K_KENTER]], 146 \ 'winheight': [[1, 10, 999], [-1, 0]], 147 \ 'winminheight': [[0, 1], [-1]], 148 \ 'winminwidth': [[0, 1, 10], [-1]], 149 \ 'winwidth': [[1, 10, 999], [-1, 0]], 150 \ 151 "\ string options 152 \ 'ambiwidth': [['single', 'double'], ['xxx']], 153 \ 'background': [['light', 'dark'], ['xxx']], 154 "\ 'backspace': [[0, 1, 2, 3, '', 'indent', 'eol', 'start', 'nostop', 155 "\ " 'eol,start', 'indent,eol,nostop'], 156 "\ " [-1, 4, 'xxx']], 157 \ 'backupcopy': [['yes', 'no', 'auto'], ['', 'xxx', 'yes,no']], 158 \ 'backupext': [['xxx'], [&patchmode, '*']], 159 \ 'belloff': [['', 'all', 'backspace', 'cursor', 'complete', 'copy', 160 \ 'ctrlg', 'error', 'esc', 'ex', 'hangul', 'insertmode', 'lang', 161 \ 'mess', 'showmatch', 'operator', 'register', 'shell', 'spell', 162 \ 'term', 'wildmode', 'copy,error,shell'], 163 \ ['xxx']], 164 \ 'breakindentopt': [['', 'min:3', 'shift:4', 'shift:-2', 'sbr', 'list:5', 165 \ 'list:-1', 'column:10', 'column:-5', 'min:1,sbr,shift:2'], 166 \ ['xxx', 'min', 'min:x', 'min:-1', 'shift:x', 'sbr:1', 'list:x', 167 \ 'column:x']], 168 \ 'browsedir': [['', 'last', 'buffer', 'current', './Xdir\ with\ space'], 169 \ ['xxx']], 170 \ 'bufhidden': [['', 'hide', 'unload', 'delete', 'wipe'], 171 \ ['xxx', 'hide,wipe']], 172 "\ 'buftype': [['', 'nofile', 'nowrite', 'acwrite', 'quickfix', 'help', 173 "\ " 'terminal', 'prompt', 'popup'], 174 "\ " ['xxx', 'help,nofile']], 175 \ 'casemap': [['', 'internal', 'keepascii', 'internal,keepascii'], 176 \ ['xxx']], 177 \ 'cedit': [['', '^Y', '^@', '<Esc>', '<t_xx>'], 178 \ ['xxx', 'f', '<xxx>', '<t_xxx>', '<Esc', '<t_xx']], 179 "\ 'clipboard': [['', 'unnamed', 'unnamedplus', 'autoselect', 180 "\ " 'autoselectplus', 'autoselectml', 'html', 'exclude:vimdisplay', 181 "\ " 'autoselect,unnamed', 'unnamed,exclude:.*'], 182 "\ " ['xxx', 'exclude:\\ze*', 'exclude:\\%(']], 183 \ 'colorcolumn': [['', '8', '+2', '1,+1,+3'], ['xxx', '-a', '1,', '1;']], 184 \ 'comments': [['', 'b:#', 'b:#,:%'], ['xxx', '-']], 185 \ 'commentstring': [['', '/*\ %s\ */'], ['xxx']], 186 \ 'complete': [['', '.', 'w', 'b', 'u', 'U', 'i', 'd', ']', 't', 187 \ 'k', 'kspell', 'k/tmp/dir\\\ with\\\ space/*', 188 \ 's', 's/tmp/dir\\\ with\\\ space/*', 189 \ 'w,b,k/tmp/dir\\\ with\\\ space/*,s'], 190 \ ['xxx']], 191 "\ 'completefuzzycollect': [['', 'keyword', 'files', 'whole_line', 192 "\ " 'keyword,whole_line', 'files,whole_line', 'keyword,files,whole_line'], 193 "\ " ['xxx', 'keyword,,,whole_line,']], 194 \ 'completeitemalign': [['abbr,kind,menu', 'menu,abbr,kind'], 195 \ ['', 'xxx', 'abbr', 'abbr,menu', 'abbr,menu,kind,abbr', 196 \ 'abbr1234,kind,menu']], 197 "\ 'completeopt': [['', 'menu', 'menuone', 'longest', 'preview', 'popup', 198 "\ " 'popuphidden', 'noinsert', 'noselect', 'fuzzy', 'preinsert', 'menu,longest'], 199 "\ " ['xxx', 'menu,,,longest,']], 200 "\ 'completepopup': [['', 'height:13', 'width:20', 'highlight:That', 201 "\ " 'align:item', 'align:menu', 'border:on', 'border:off', 202 "\ " 'width:10,height:234,highlight:Mine'], 203 "\ " ['xxx', 'xxx:99', 'height:yes', 'width:no', 'align:xxx', 204 "\ " 'border:maybe', 'border:1', 'border:']], 205 \ 'completeslash': [['', 'slash', 'backslash'], ['xxx']], 206 \ 'concealcursor': [['', 'n', 'v', 'i', 'c', 'nvic'], ['xxx']], 207 "\ 'cryptmethod': [['', 'zip'], ['xxx']], 208 "\ 'cscopequickfix': [['', 's-', 'g-', 'd-', 'c-', 't-', 'e-', 'f-', 'i-', 209 "\ " 'a-', 's-,c+,e0'], 210 "\ " ['xxx', 's,g,d']], 211 \ 'cursorlineopt': [['both', 'line', 'number', 'screenline', 212 \ 'line,number'], 213 \ ['', 'xxx', 'line,screenline']], 214 \ 'debug': [['', 'msg', 'throw', 'beep'], ['xxx']], 215 \ 'diffanchors': [['', "'a", '/foo/', "'a-1,'>,/foo,xxx/,'b,123", 216 \ '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20', 217 \ '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,'], 218 \ [',', '12,,34', 'xxx', '123,xxx', 219 \ '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21']], 220 \ 'diffopt': [['', 'filler', 'context:0', 'context:999', 'iblank', 221 \ 'icase', 'iwhite', 'iwhiteall', 'horizontal', 'vertical', 222 \ 'closeoff', 'hiddenoff', 'foldcolumn:0', 'foldcolumn:12', 223 \ 'followwrap', 'internal', 'indent-heuristic', 'algorithm:myers', 224 \ 'icase,iwhite', 'algorithm:minimal', 'algorithm:patience', 225 \ 'anchor', 'algorithm:histogram', 'inline:none', 'inline:simple', 226 \ 'inline:char', 'inline:word', 'inline:char,inline:word', 'linematch:5'], 227 \ ['xxx', 'foldcolumn:', 'foldcolumn:x', 'foldcolumn:xxx', 228 \ 'linematch:', 'linematch:x', 'linematch:xxx', 'algorithm:', 229 \ 'algorithm:xxx', 'context:', 'context:x', 'context:xxx', 230 \ 'inline:xxx']], 231 \ 'display': [['', 'lastline', 'truncate', 'uhex', 'lastline,uhex'], 232 \ ['xxx']], 233 \ 'eadirection': [['both', 'ver', 'hor'], ['xxx', 'ver,hor']], 234 "\ 'encoding': [['latin1'], ['xxx', '']], 235 \ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter', 'all,-WinLeave'], 236 \ ['xxx']], 237 \ 'eventignorewin': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter', 'all,-WinLeave'], 238 \ ['xxx', 'WinNew']], 239 \ 'fileencoding': [['', 'latin1', 'xxx'], []], 240 \ 'fileformat': [['dos', 'unix', 'mac'], ['xxx']], 241 \ 'fileformats': [['', 'dos', 'dos,unix'], ['xxx']], 242 \ 'fillchars': [['', 'stl:x', 'stlnc:x', 'vert:x', 'fold:x', 'foldopen:x', 243 \ 'foldclose:x', 'foldsep:x', 'diff:x', 'eob:x', 'lastline:x', 244 \ 'trunc:_', 'trunc:_,eob:x,trunc:_', 245 \ 'stl:\ ,vert:\|,fold:\\,trunc:…,diff:x'], 246 \ ['xxx', 'vert:', 'trunc:', "trunc:\b"]], 247 \ 'foldclose': [['', 'all'], ['xxx']], 248 \ 'foldmarker': [['((,))'], ['', 'xxx', '{{{,']], 249 \ 'foldmethod': [['manual', 'indent', 'expr', 'marker', 'syntax', 'diff'], 250 \ ['', 'xxx', 'expr,diff']], 251 \ 'foldopen': [['', 'all', 'block', 'hor', 'insert', 'jump', 'mark', 252 \ 'percent', 'quickfix', 'search', 'tag', 'undo', 'hor,jump'], 253 \ ['xxx']], 254 \ 'formatoptions': [['', 't', 'c', 'r', 'o', '/', 'q', 'w', 'a', 'n', '2', 255 \ 'v', 'b', 'l', 'm', 'M', 'B', '1', ']', 'j', 'p', 'vt', 'v,t'], 256 \ ['xxx']], 257 \ 'guicursor': [['', 'n:block-Cursor'], ['xxx']], 258 \ 'guifont': [['', fontname], []], 259 "\ 'guifontset': [['', fontname], []], 260 \ 'guifontwide': [['', fontname], []], 261 \ 'guioptions': [['', '!', 'a', 'P', 'A', 'c', 'd', 'e', 'f', 'i', 'm', 262 \ 'M', 'g', 't', 'T', 'r', 'R', 'l', 'L', 'b', 'h', 'v', 'p', 'F', 263 \ 'k', '!abvR'], 264 \ ['xxx', 'a,b']], 265 \ 'helplang': [['', 'de', 'de,it'], ['xxx']], 266 "\ 'highlight': [['', 'e:Error'], ['xxx']], 267 "\ 'imactivatekey': [['', 'S-space'], ['xxx']], 268 \ 'isfname': [['', '@', '@,48-52'], ['xxx', '@48']], 269 \ 'isident': [['', '@', '@,48-52'], ['xxx', '@48']], 270 \ 'iskeyword': [['', '@', '@,48-52'], ['xxx', '@48']], 271 \ 'isprint': [['', '@', '@,48-52'], ['xxx', '@48']], 272 \ 'jumpoptions': [['', 'stack'], ['xxx']], 273 \ 'keymap': [['', 'accents'], ['/']], 274 \ 'keymodel': [['', 'startsel', 'stopsel', 'startsel,stopsel'], ['xxx']], 275 "\ 'keyprotocol': [['', 'xxx:none', 'yyy:mok2', 'zzz:kitty'], 276 "\ " ['xxx', ':none', 'xxx:', 'x:non', 'y:mok3', 'z:kittty']], 277 \ 'langmap': [['', 'xX', 'aA,bB'], ['xxx']], 278 \ 'lispoptions': [['', 'expr:0', 'expr:1'], ['xxx', 'expr:x', 'expr:']], 279 \ 'listchars': [['', 'eol:x', 'tab:xy', 'tab:xyz', 'space:x', 280 \ 'multispace:xxxy', 'lead:x', 'tab:xy,leadtab:xyz', 'leadmultispace:xxxy', 281 \ 'trail:x', 'extends:x', 'precedes:x', 'conceal:x', 'nbsp:x', 282 \ 'eol:\\x24', 'eol:\\u21b5', 'eol:\\U000021b5', 'eol:x,space:y'], 283 \ ['xxx', 'eol:', 'leadtab:xyz']], 284 \ 'matchpairs': [['', '(:)', '(:),<:>'], ['xxx']], 285 \ 'maxsearchcount': [[1, 10, 100, 1000], [0, -1, 10000]], 286 \ 'messagesopt': [['hit-enter,history:1', 'hit-enter,history:10000', 287 \ 'history:100,wait:100', 'history:0,wait:0', 288 \ 'hit-enter,history:1,wait:1'], 289 \ ['xxx', 'history:500', 'hit-enter,history:-1', 290 \ 'hit-enter,history:10001', 'history:0,wait:10001', 291 \ 'hit-enter', 'history:10,wait:99999999999999999999', 292 \ 'history:99999999999999999999,wait:10', 'wait:10', 293 \ 'history:-10', 'history:10,wait:-10']], 294 \ 'mkspellmem': [['10000,100,12'], ['', 'xxx', '10000,100']], 295 \ 'mouse': [['', 'n', 'v', 'i', 'c', 'h', 'a', 'r', 'nvi'], 296 \ ['xxx', 'n,v,i']], 297 \ 'mousemodel': [['extend', 'popup', 'popup_setpos'], ['xxx']], 298 \ 'mouseshape': [['', 'n:arrow'], ['xxx']], 299 \ 'nrformats': [['', 'alpha', 'octal', 'hex', 'bin', 'unsigned', 'blank', 300 \ 'alpha,hex,bin'], 301 \ ['xxx']], 302 \ 'patchmode': [['', 'xxx', '.x'], [&backupext, '*']], 303 "\ 'previewpopup': [['', 'height:13', 'width:20', 'highlight:That', 304 "\ " 'align:item', 'align:menu', 'border:on', 'border:off', 305 "\ " 'width:10,height:234,highlight:Mine'], 306 "\ " ['xxx', 'xxx:99', 'height:yes', 'width:no', 'align:xxx', 307 "\ " 'border:maybe', 'border:1', 'border:']], 308 "\ 'printmbfont': [['', 'r:some', 'b:some', 'i:some', 'o:some', 'c:yes', 309 "\ " 'c:no', 'a:yes', 'a:no', 'b:Bold,c:yes'], 310 "\ " ['xxx', 'xxx,c:yes', 'xxx:', 'xxx:,c:yes']], 311 "\ 'printoptions': [['', 'header:0', 'left:10pc,top:5pc'], 312 "\ " ['xxx', 'header:-1']], 313 "\ 'pumborder': [['', 'single', 'double', 'round', 'ascii', 'shadow', 314 "\ " 'double,margin,shadow', 'custom:─;│;─;│;┌;┐;┘;└,shadow', 315 "\ " 'ascii,margin'], 316 "\ " ['xxx', 'margin', 'margin,shadow', 'custom:', 'custom:+;']], 317 "\ 'renderoptions': [[''], ['xxx']], 318 \ 'rightleftcmd': [['search'], ['xxx']], 319 \ 'rulerformat': [['', 'xxx'], ['%-', '%(', '%15(%%']], 320 \ 'scrollopt': [['', 'ver', 'hor', 'jump', 'ver,hor'], ['xxx']], 321 \ 'selection': [['old', 'inclusive', 'exclusive'], ['', 'xxx']], 322 \ 'selectmode': [['', 'mouse', 'key', 'cmd', 'key,cmd'], ['xxx']], 323 \ 'sessionoptions': [['', 'blank', 'curdir', 'sesdir', 324 \ 'help,options,slash'], 325 \ ['xxx', 'curdir,sesdir']], 326 \ 'showcmdloc': [['last', 'statusline', 'tabline'], ['xxx']], 327 "\ 'signcolumn': [['', 'auto', 'no', 'yes', 'number'], ['xxx', 'no,yes']], 328 \ 'spellfile': [['', 'file.en.add', 'xxx.en.add,yyy.gb.add,zzz.ja.add', 329 \ '/tmp/dir\ with\ space/en.utf-8.add', 330 \ '/tmp/dir\\,with\\,comma/en.utf-8.add'], 331 \ ['xxx', '/tmp/file', '/tmp/dir*with:invalid?char/file.en.add', 332 \ ',file.en.add', 'xxx,yyy.en.add', 'xxx.en.add,yyy,zzz.ja.add']], 333 \ 'spelllang': [['', 'xxx', 'sr@latin'], ['not&lang', "that\\\rthere"]], 334 \ 'spelloptions': [['', 'camel'], ['xxx']], 335 \ 'spellsuggest': [['', 'best', 'double', 'fast', '100', 'timeout:100', 336 \ 'timeout:-1', 'file:/tmp/file', 'expr:Func()', 'double,33'], 337 \ ['xxx', '-1', 'timeout:', 'best,double', 'double,fast']], 338 \ 'splitkeep': [['cursor', 'screen', 'topline'], ['xxx']], 339 \ 'statusline': [['', 'xxx'], ['%^', '%{', '%{%', '%{%}', '%(', '%)']], 340 "\ 'swapsync': [['', 'sync', 'fsync'], ['xxx']], 341 \ 'switchbuf': [['', 'useopen', 'usetab', 'split', 'vsplit', 'newtab', 342 \ 'uselast', 'split,newtab'], 343 \ ['xxx']], 344 \ 'tabclose': [['', 'left', 'uselast', 'left,uselast'], ['xxx']], 345 \ 'tabline': [['', 'xxx'], ['%^', '%{', '%{%', '%{%}', '%(', '%)']], 346 \ 'tagcase': [['followic', 'followscs', 'ignore', 'match', 'smart'], 347 \ ['', 'xxx', 'smart,match']], 348 \ 'termencoding': [has('gui_gtk') ? [] : ['', 'utf-8'], ['xxx']], 349 "\ 'termwinkey': [['', 'f', '^Y', '^@', '<Esc>', '<t_xx>', "\u3042", '<', 350 "\ " '^'], 351 "\ " ['<xxx>', '<t_xxx>', '<Esc', '<t_xx']], 352 "\ 'termwinsize': [['', '24x80', '0x80', '32x0', '0x0'], 353 "\ " ['xxx', '80', '8ax9', '24x80b']], 354 "\ 'termwintype': [['', 'winpty', 'conpty'], ['xxx']], 355 "\ 'titlestring': [['', 'xxx', '%('], []], 356 "\ 'toolbar': [['', 'icons', 'text', 'horiz', 'tooltips', 'icons,text'], 357 "\ " ['xxx']], 358 "\ 'toolbariconsize': [['', 'tiny', 'small', 'medium', 'large', 'huge', 359 "\ " 'giant'], 360 "\ " ['xxx']], 361 "\ 'ttymouse': [['', 'xterm'], ['xxx']], 362 \ 'varsofttabstop': [['8', '4,8,16,32'], ['xxx', '-1', '4,-1,20', '1,']], 363 \ 'vartabstop': [['8', '4,8,16,32'], ['xxx', '-1', '4,-1,20', '1,']], 364 \ 'verbosefile': [['', './Xfile'], []], 365 \ 'viewoptions': [['', 'cursor', 'folds', 'options', 'localoptions', 366 \ 'slash', 'unix', 'curdir', 'unix,slash'], ['xxx']], 367 \ 'viminfo': [['', '''50', '"30', "'100,<50,s10,h"], ['xxx', 'h']], 368 \ 'virtualedit': [['', 'block', 'insert', 'all', 'onemore', 'none', 369 \ 'NONE', 'all,block'], 370 \ ['xxx']], 371 \ 'whichwrap': [['', 'b', 's', 'h', 'l', '<', '>', '~', '[', ']', 'b,s', 372 \ 'bs'], 373 \ ['xxx']], 374 \ 'wildmode': [['', 'full', 'longest', 'list', 'lastused', 'list:full', 375 \ 'noselect', 'noselect,full', 'noselect:lastused,full', 376 \ 'full,longest', 'full,full,full,full'], 377 \ ['xxx', 'a4', 'full,full,full,full,full']], 378 \ 'wildoptions': [['', 'tagfile', 'pum', 'fuzzy'], ['xxx']], 379 \ 'winaltkeys': [['no', 'yes', 'menu'], ['', 'xxx']], 380 \ 381 "\ skipped options 382 "\ 'luadll': [[], []], 383 "\ 'perldll': [[], []], 384 "\ 'pythondll': [[], []], 385 "\ 'pythonthreedll': [[], []], 386 \ 'pyxversion': [[], []], 387 "\ 'rubydll': [[], []], 388 "\ 'tcldll': [[], []], 389 \ 'term': [[], []], 390 \ 'ttytype': [[], []], 391 \ 392 "\ default behaviours 393 \ 'othernum': [[-1, 0, 100], ['']], 394 \ 'otherstring': [['', 'xxx'], []], 395 \} 396 397 " Two lists with values: values that pre- and post-processing in test. 398 " Clear out t_WS: we don't want to resize the actual terminal. 399 let test_prepost = { 400 \ 'browsedir': [["call mkdir('Xdir with space', 'D')"], []], 401 \ 'columns': [[ 402 \ 'set t_WS=', 403 \ 'let save_columns = &columns' 404 \ ], [ 405 \ 'let &columns = save_columns', 406 \ 'set t_WS&' 407 \ ]], 408 \ 'lines': [[ 409 \ 'set t_WS=', 410 \ 'let save_lines = &lines' 411 \ ], [ 412 \ 'let &lines = save_lines', 413 \ 'set t_WS&' 414 \ ]], 415 \ 'verbosefile': [[], ['call delete("Xfile")']], 416 \} 417 418 const invalid_options = test_values->keys() 419 \->filter({-> v:val !~# '^other' && !exists($"&{v:val}")}) 420 if !empty(invalid_options) 421 throw $"Invalid option name in test_values: '{invalid_options->join("', '")}'" 422 endif 423 424 for option in options 425 let fullname = option.full_name 426 let shortname = get(option, 'abbreviation', fullname) 427 428 if !exists('+' .. fullname) 429 continue 430 endif 431 432 let [valid_values, invalid_values] = test_values[ 433 \ has_key(test_values, fullname) ? fullname 434 \ : option.type == 'number' ? 'othernum' 435 \ : 'otherstring'] 436 437 if empty(valid_values) && empty(invalid_values) 438 continue 439 endif 440 441 call add(script, $"func Test_opt_set_{fullname}()") 442 call add(script, $"if exists('+{fullname}') && execute('set!') =~# '\\n..{fullname}\\([=\\n]\\|$\\)'") 443 call add(script, $"let l:saved = [&g:{fullname}, &l:{fullname}]") 444 call add(script, 'endif') 445 446 let [pre_processing, post_processing] = get(test_prepost, fullname, [[], []]) 447 let script += pre_processing 448 449 if option.type == 'boolean' 450 for opt in [fullname, shortname] 451 for cmd in ['set', 'setlocal', 'setglobal'] 452 call add(script, $'{cmd} {opt}') 453 call add(script, $'{cmd} no{opt}') 454 call add(script, $'{cmd} inv{opt}') 455 call add(script, $'{cmd} {opt}!') 456 endfor 457 endfor 458 else " P_NUM || P_STRING 459 " Normal tests 460 for opt in [fullname, shortname] 461 for cmd in ['set', 'setlocal', 'setglobal'] 462 for val in valid_values 463 if local_noglobals->has_key(fullname) && cmd ==# 'setglobal' 464 " Skip `:setglobal {option}={val}` for local-noglobal option. 465 " It has no effect. 466 let pre = '" Skip local-noglobal: ' 467 else 468 let pre = '' 469 endif 470 call add(script, $'{pre}{cmd} {opt}={val}') 471 endfor 472 endfor 473 " Testing to clear the local value and switch back to the global value. 474 if global_locals->has_key(fullname) 475 let switchback_val = global_locals[fullname] 476 call add(script, $'setlocal {opt}={switchback_val}') 477 call add(script, $'call assert_equal(&g:{fullname}, &{fullname})') 478 endif 479 endfor 480 481 " Failure tests 482 " Setting an option can only fail when it's implemented. 483 call add(script, $"if exists('+{fullname}')") 484 for opt in [fullname, shortname] 485 for cmd in ['set', 'setlocal', 'setglobal'] 486 for val in invalid_values 487 if val is# global_locals->get(fullname, {}) && cmd ==# 'setlocal' 488 " Skip setlocal switchback-value to global-local option. It will 489 " not result in failure. 490 let pre = '" Skip global-local: ' 491 elseif local_noglobals->has_key(fullname) && cmd ==# 'setglobal' 492 " Skip setglobal to local-noglobal option. It will not result in 493 " failure. 494 let pre = '" Skip local-noglobal: ' 495 elseif skip_setglobal_reasons->has_key(fullname) && cmd ==# 'setglobal' 496 " Skip setglobal to reasoned option. It will not result in failure. 497 let reason = skip_setglobal_reasons[fullname] 498 let pre = $'" Skip {reason}: ' 499 else 500 let pre = '' 501 endif 502 let cmdline = $'{cmd} {opt}={val}' 503 call add(script, $"{pre}silent! call assert_fails({string(cmdline)})") 504 endfor 505 endfor 506 endfor 507 call add(script, "endif") 508 endif 509 510 " Cannot change 'termencoding' in GTK 511 if fullname != 'termencoding' || !has('gui_gtk') 512 call add(script, $'set {fullname}&') 513 call add(script, $'set {shortname}&') 514 call add(script, $"if exists('l:saved')") 515 call add(script, $"let [&g:{fullname}, &l:{fullname}] = l:saved") 516 call add(script, 'endif') 517 endif 518 519 let script += post_processing 520 call add(script, 'endfunc') 521 endfor 522 523 call writefile(script, 'opt_test.vim') 524 525 " Write error messages if error occurs. 526 catch 527 " Append errors to test.log 528 let error = $'Error: {v:exception} in {v:throwpoint}' 529 echo error 530 split gen_opt_test.log 531 call append('$', error) 532 write 533 endtry 534 535 endif 536 537 qa! 538 539 " vim:sw=2:ts=8:noet:nosta: