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