xref: /vim-8.2.3635/src/testdir/gen_opt_test.vim (revision e16b00a1)
1" Script to generate testdir/opt_test.vim from option.c
2
3set cpo=&vim
4
5" Only do this when build with the +eval feature.
6if 1
7
8set nomore
9
10" The terminal size is restored at the end.
11" Clear out t_WS, we don't want to resize the actual terminal.
12let script = [
13      \ 'let save_columns = &columns',
14      \ 'let save_lines = &lines',
15      \ 'let save_term = &term',
16      \ 'set t_WS=',
17      \ ]
18
19/#define p_term
20let end = line('.')
21
22" Two lists with values: values that work and values that fail.
23" When not listed, "othernum" or "otherstring" is used.
24let test_values = {
25      \ 'cmdheight': [[1, 2, 10], [-1, 0]],
26      \ 'cmdwinheight': [[1, 2, 10], [-1, 0]],
27      \ 'columns': [[12, 80], [-1, 0, 10]],
28      \ 'conceallevel': [[0, 1, 2, 3], [-1, 4, 99]],
29      \ 'foldcolumn': [[0, 1, 4, 12], [-1, 13, 999]],
30      \ 'helpheight': [[0, 10, 100], [-1]],
31      \ 'history': [[0, 1, 100], [-1, 10001]],
32      \ 'iminsert': [[0, 1], [-1, 3, 999]],
33      \ 'imsearch': [[-1, 0, 1], [-2, 3, 999]],
34      \ 'lines': [[2, 24], [-1, 0, 1]],
35      \ 'linespace': [[0, 2, 4], ['']],
36      \ 'numberwidth': [[1, 4, 8, 10], [-1, 0, 11]],
37      \ 'regexpengine': [[0, 1, 2], [-1, 3, 999]],
38      \ 'report': [[0, 1, 2, 9999], [-1]],
39      \ 'scroll': [[0, 1, 2, 20], [-1]],
40      \ 'scrolljump': [[-50, -1, 0, 1, 2, 20], [999]],
41      \ 'scrolloff': [[0, 1, 2, 20], [-1]],
42      \ 'shiftwidth': [[0, 1, 8, 999], [-1]],
43      \ 'sidescroll': [[0, 1, 8, 999], [-1]],
44      \ 'sidescrolloff': [[0, 1, 8, 999], [-1]],
45      \ 'tabstop': [[1, 4, 8, 12], [-1, 0]],
46      \ 'textwidth': [[0, 1, 8, 99], [-1]],
47      \ 'timeoutlen': [[0, 8, 99999], [-1]],
48      \ 'titlelen': [[0, 1, 8, 9999], [-1]],
49      \ 'updatecount': [[0, 1, 8, 9999], [-1]],
50      \ 'updatetime': [[0, 1, 8, 9999], [-1]],
51      \ 'verbose': [[-1, 0, 1, 8, 9999], []],
52      \ 'wildcharm': [[-1, 0, 100], []],
53      \ 'winheight': [[1, 10, 999], [-1, 0]],
54      \ 'winminheight': [[0, 1], [-1]],
55      \ 'winminwidth': [[0, 1, 10], [-1]],
56      \ 'winwidth': [[1, 10, 999], [-1, 0]],
57      \
58      \ 'ambiwidth': [['', 'single'], ['xxx']],
59      \ 'background': [['', 'light', 'dark'], ['xxx']],
60      \ 'backspace': [[0, 2, '', 'eol', 'eol,start'], ['xxx']],
61      \ 'backupcopy': [['yes', 'auto'], ['', 'xxx', 'yes,no']],
62      \ 'backupext': [['xxx'], ['']],
63      \ 'belloff': [['', 'all', 'copy,error'], ['xxx']],
64      \ 'breakindentopt': [['', 'min:3', 'sbr'], ['xxx', 'min', 'min:x']],
65      \ 'browsedir': [['', 'last', '/'], ['xxx']],
66      \ 'bufhidden': [['', 'hide', 'wipe'], ['xxx', 'hide,wipe']],
67      \ 'buftype': [['', 'help', 'nofile'], ['xxx', 'help,nofile']],
68      \ 'casemap': [['', 'internal'], ['xxx']],
69      \ 'cedit': [['', '\<Esc>'], ['xxx', 'f']],
70      \ 'clipboard': [['', 'unnamed', 'autoselect,unnamed'], ['xxx']],
71      \ 'colorcolumn': [['', '8', '+2'], ['xxx']],
72      \ 'comments': [['', 'b:#'], ['xxx']],
73      \ 'commentstring': [['', '/*%s*/'], ['xxx']],
74      \ 'complete': [['', 'w,b'], ['xxx']],
75      \ 'concealcursor': [['', 'n', 'nvic'], ['xxx']],
76      \ 'completeopt': [['', 'menu', 'menu,longest'], ['xxx', 'menu,,,longest,']],
77      \ 'cryptmethod': [['', 'zip'], ['xxx']],
78      \ 'cscopequickfix': [['', 's-', 's-,c+,e0'], ['xxx', 's,g,d']],
79      \ 'debug': [['', 'msg', 'msg', 'beep'], ['xxx']],
80      \ 'diffopt': [['', 'filler', 'icase,iwhite'], ['xxx']],
81      \ 'display': [['', 'lastline', 'lastline,uhex'], ['xxx']],
82      \ 'eadirection': [['', 'both', 'ver'], ['xxx', 'ver,hor']],
83      \ 'encoding': [['latin1'], ['xxx', '']],
84      \ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter'], ['xxx']],
85      \ 'fileencoding': [['', 'latin1', 'xxx'], []],
86      \ 'fileformat': [['', 'dos', 'unix'], ['xxx']],
87      \ 'fileformats': [['', 'dos', 'dos,unix'], ['xxx']],
88      \ 'fillchars': [['', 'vert:x'], ['xxx']],
89      \ 'foldclose': [['', 'all'], ['xxx']],
90      \ 'foldmethod': [['manual', 'indent'], ['', 'xxx', 'expr,diff']],
91      \ 'foldopen': [['', 'all', 'hor,jump'], ['xxx']],
92      \ 'foldmarker': [['((,))'], ['', 'xxx']],
93      \ 'formatoptions': [['', 'vt', 'v,t'], ['xxx']],
94      \ 'guicursor': [['', 'n:block-Cursor'], ['xxx']],
95      \ 'guifont': [['', 'fixedsys'], []],
96      \ 'guifontwide': [['', 'fixedsys'], []],
97      \ 'helplang': [['', 'de', 'de,it'], ['xxx']],
98      \ 'highlight': [['', 'e:Error'], ['xxx']],
99      \ 'imactivatekey': [['', 'S-space'], ['xxx']],
100      \ 'isfname': [['', '@', '@,48-52'], ['xxx', '@48']],
101      \ 'isident': [['', '@', '@,48-52'], ['xxx', '@48']],
102      \ 'iskeyword': [['', '@', '@,48-52'], ['xxx', '@48']],
103      \ 'isprint': [['', '@', '@,48-52'], ['xxx', '@48']],
104      \ 'keymap': [['', 'accents'], ['xxx']],
105      \ 'keymodel': [['', 'startsel', 'startsel,stopsel'], ['xxx']],
106      \ 'langmap': [['', 'xX', 'aA,bB'], ['xxx']],
107      \ 'listchars': [['', 'eol:x', 'eol:x,space:y'], ['xxx']],
108      \ 'matchpairs': [['', '(:)', '(:),<:>'], ['xxx']],
109      \ 'mkspellmem': [['10000,100,12'], ['', 'xxx']],
110      \ 'mouse': [['', 'a', 'nvi'], ['xxx', 'n,v,i']],
111      \ 'mousemodel': [['', 'popup'], ['xxx']],
112      \ 'mouseshape': [['', 'n:arrow'], ['xxx']],
113      \ 'nrformats': [['', 'alpha', 'alpha,hex,bin'], ['xxx']],
114      \ 'printmbfont': [['', 'r:some', 'b:Bold,c:yes'], ['xxx']],
115      \ 'printoptions': [['', 'header:0', 'left:10pc,top:5pc'], ['xxx']],
116      \ 'scrollopt': [['', 'ver', 'ver,hor'], ['xxx']],
117      \ 'renderoptions': [['', 'type:directx'], ['xxx']],
118      \ 'selection': [['old', 'inclusive'], ['', 'xxx']],
119      \ 'selectmode': [['', 'mouse', 'key,cmd'], ['xxx']],
120      \ 'sessionoptions': [['', 'blank', 'help,options,slash'], ['xxx']],
121      \ 'signcolumn': [['', 'auto', 'no'], ['xxx', 'no,yes']],
122      \ 'spellfile': [['', 'file.en.add'], ['xxx', '/tmp/file']],
123      \ 'spellsuggest': [['', 'best', 'double,33'], ['xxx']],
124      \ 'switchbuf': [['', 'useopen', 'split,newtab'], ['xxx']],
125      \ 'tagcase': [['smart', 'match'], ['', 'xxx', 'smart,match']],
126      \ 'term': [[], []],
127      \ 'termsize': [['', '24x80', '0x80', '32x0', '0x0'], ['xxx', '80', '8ax9', '24x80b']],
128      \ 'toolbar': [['', 'icons', 'text'], ['xxx']],
129      \ 'toolbariconsize': [['', 'tiny', 'huge'], ['xxx']],
130      \ 'ttymouse': [['', 'xterm'], ['xxx']],
131      \ 'ttytype': [[], []],
132      \ 'viewoptions': [['', 'cursor', 'unix,slash'], ['xxx']],
133      \ 'viminfo': [['', '''50', '"30'], ['xxx']],
134      \ 'virtualedit': [['', 'all', 'all,block'], ['xxx']],
135      \ 'whichwrap': [['', 'b,s', 'bs'], ['xxx']],
136      \ 'wildmode': [['', 'full', 'list:full', 'full,longest'], ['xxx']],
137      \ 'wildoptions': [['', 'tagfile'], ['xxx']],
138      \ 'winaltkeys': [['menu', 'no'], ['', 'xxx']],
139      \
140      \ 'luadll': [[], []],
141      \ 'perldll': [[], []],
142      \ 'pythondll': [[], []],
143      \ 'pythonthreedll': [[], []],
144      \ 'pyxversion': [[], []],
145      \ 'rubydll': [[], []],
146      \ 'tcldll': [[], []],
147      \
148      \ 'othernum': [[-1, 0, 100], ['']],
149      \ 'otherstring': [['', 'xxx'], []],
150      \}
151
1521
153/struct vimoption options
154while 1
155  /{"
156  if line('.') > end
157    break
158  endif
159  let line = getline('.')
160  let name = substitute(line, '.*{"\([^"]*\)".*', '\1', '')
161  let shortname = substitute(line, '.*"\([^"]*\)".*', '\1', '')
162
163  if has_key(test_values, name)
164    let a = test_values[name]
165  elseif line =~ 'P_NUM'
166    let a = test_values['othernum']
167  else
168    let a = test_values['otherstring']
169  endif
170  if len(a[0]) > 0 || len(a[1]) > 0
171    if line =~ 'P_BOOL'
172      call add(script, 'set ' . name)
173      call add(script, 'set ' . shortname)
174      call add(script, 'set no' . name)
175      call add(script, 'set no' . shortname)
176    else
177      for val in a[0]
178	call add(script, 'set ' . name . '=' . val)
179	call add(script, 'set ' . shortname . '=' . val)
180      endfor
181
182      " setting an option can only fail when it's implemented.
183      call add(script, "if exists('+" . name . "')")
184      for val in a[1]
185	call add(script, "call assert_fails('set " . name . "=" . val . "')")
186	call add(script, "call assert_fails('set " . shortname . "=" . val . "')")
187      endfor
188      call add(script, "endif")
189    endif
190
191    call add(script, 'set ' . name . '&')
192    call add(script, 'set ' . shortname . '&')
193    if name == 'verbosefile'
194      call add(script, 'call delete("xxx")')
195    endif
196
197    if name == 'more'
198      call add(script, 'set nomore')
199    elseif name == 'lines'
200      call add(script, 'let &lines = save_lines')
201    endif
202  endif
203endwhile
204
205call add(script, 'let &term = save_term')
206call add(script, 'let &columns = save_columns')
207call add(script, 'let &lines = save_lines')
208
209call writefile(script, 'opt_test.vim')
210
211endif
212
213qa!
214