gen_opt_test.vim 21 KB

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