gen_opt_test.vim 22 KB

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