blob: 58db1f90a9495b167ad910b415d534bb708dceb1 [file] [log] [blame]
Bram Moolenaar2f5463d2017-02-25 20:40:46 +01001" Script to generate testdir/opt_test.vim from option.c
2
Bram Moolenaar2f5463d2017-02-25 20:40:46 +01003set cpo=&vim
Bram Moolenaar5b3af142017-02-27 22:59:40 +01004
5" Only do this when build with the +eval feature.
6if 1
7
Bram Moolenaar2f5463d2017-02-25 20:40:46 +01008set nomore
9
Bram Moolenaaree1dd1c2017-03-09 13:55:01 +010010" The terminal size is restored at the end.
11" Clear out t_WS, we don't want to resize the actual terminal.
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010012let script = [
13 \ 'let save_columns = &columns',
14 \ 'let save_lines = &lines',
15 \ 'let save_term = &term',
Bram Moolenaaree1dd1c2017-03-09 13:55:01 +010016 \ 'set t_WS=',
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010017 \ ]
18
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010019/#define p_term
20let end = line('.')
21
Bram Moolenaar17471e82017-11-26 23:47:18 +010022" font name that works everywhere (hopefully)
23let fontname = has('win32') ? 'fixedsys' : 'fixed'
24
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010025" Two lists with values: values that work and values that fail.
26" When not listed, "othernum" or "otherstring" is used.
27let test_values = {
28 \ 'cmdheight': [[1, 2, 10], [-1, 0]],
29 \ 'cmdwinheight': [[1, 2, 10], [-1, 0]],
30 \ 'columns': [[12, 80], [-1, 0, 10]],
31 \ 'conceallevel': [[0, 1, 2, 3], [-1, 4, 99]],
32 \ 'foldcolumn': [[0, 1, 4, 12], [-1, 13, 999]],
33 \ 'helpheight': [[0, 10, 100], [-1]],
34 \ 'history': [[0, 1, 100], [-1, 10001]],
Bram Moolenaarc43a8b82017-02-25 21:12:29 +010035 \ 'iminsert': [[0, 1], [-1, 3, 999]],
36 \ 'imsearch': [[-1, 0, 1], [-2, 3, 999]],
Bram Moolenaar5c6dbcb2017-08-30 22:00:20 +020037 \ 'imstyle': [[0, 1], [-1, 2, 999]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010038 \ 'lines': [[2, 24], [-1, 0, 1]],
Bram Moolenaarbb962262017-03-08 00:01:35 +010039 \ 'linespace': [[0, 2, 4], ['']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010040 \ 'numberwidth': [[1, 4, 8, 10], [-1, 0, 11]],
41 \ 'regexpengine': [[0, 1, 2], [-1, 3, 999]],
42 \ 'report': [[0, 1, 2, 9999], [-1]],
43 \ 'scroll': [[0, 1, 2, 20], [-1]],
44 \ 'scrolljump': [[-50, -1, 0, 1, 2, 20], [999]],
45 \ 'scrolloff': [[0, 1, 2, 20], [-1]],
46 \ 'shiftwidth': [[0, 1, 8, 999], [-1]],
47 \ 'sidescroll': [[0, 1, 8, 999], [-1]],
48 \ 'sidescrolloff': [[0, 1, 8, 999], [-1]],
49 \ 'tabstop': [[1, 4, 8, 12], [-1, 0]],
50 \ 'textwidth': [[0, 1, 8, 99], [-1]],
51 \ 'timeoutlen': [[0, 8, 99999], [-1]],
52 \ 'titlelen': [[0, 1, 8, 9999], [-1]],
53 \ 'updatecount': [[0, 1, 8, 9999], [-1]],
54 \ 'updatetime': [[0, 1, 8, 9999], [-1]],
55 \ 'verbose': [[-1, 0, 1, 8, 9999], []],
Bram Moolenaara12e4032017-02-25 21:37:57 +010056 \ 'wildcharm': [[-1, 0, 100], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010057 \ 'winheight': [[1, 10, 999], [-1, 0]],
58 \ 'winminheight': [[0, 1], [-1]],
59 \ 'winminwidth': [[0, 1, 10], [-1]],
60 \ 'winwidth': [[1, 10, 999], [-1, 0]],
61 \
62 \ 'ambiwidth': [['', 'single'], ['xxx']],
63 \ 'background': [['', 'light', 'dark'], ['xxx']],
64 \ 'backspace': [[0, 2, '', 'eol', 'eol,start'], ['xxx']],
65 \ 'backupcopy': [['yes', 'auto'], ['', 'xxx', 'yes,no']],
66 \ 'backupext': [['xxx'], ['']],
67 \ 'belloff': [['', 'all', 'copy,error'], ['xxx']],
68 \ 'breakindentopt': [['', 'min:3', 'sbr'], ['xxx', 'min', 'min:x']],
Bram Moolenaarbb962262017-03-08 00:01:35 +010069 \ 'browsedir': [['', 'last', '/'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010070 \ 'bufhidden': [['', 'hide', 'wipe'], ['xxx', 'hide,wipe']],
71 \ 'buftype': [['', 'help', 'nofile'], ['xxx', 'help,nofile']],
72 \ 'casemap': [['', 'internal'], ['xxx']],
73 \ 'cedit': [['', '\<Esc>'], ['xxx', 'f']],
74 \ 'clipboard': [['', 'unnamed', 'autoselect,unnamed'], ['xxx']],
75 \ 'colorcolumn': [['', '8', '+2'], ['xxx']],
76 \ 'comments': [['', 'b:#'], ['xxx']],
77 \ 'commentstring': [['', '/*%s*/'], ['xxx']],
78 \ 'complete': [['', 'w,b'], ['xxx']],
79 \ 'concealcursor': [['', 'n', 'nvic'], ['xxx']],
80 \ 'completeopt': [['', 'menu', 'menu,longest'], ['xxx', 'menu,,,longest,']],
81 \ 'cryptmethod': [['', 'zip'], ['xxx']],
82 \ 'cscopequickfix': [['', 's-', 's-,c+,e0'], ['xxx', 's,g,d']],
83 \ 'debug': [['', 'msg', 'msg', 'beep'], ['xxx']],
84 \ 'diffopt': [['', 'filler', 'icase,iwhite'], ['xxx']],
85 \ 'display': [['', 'lastline', 'lastline,uhex'], ['xxx']],
86 \ 'eadirection': [['', 'both', 'ver'], ['xxx', 'ver,hor']],
87 \ 'encoding': [['latin1'], ['xxx', '']],
88 \ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter'], ['xxx']],
89 \ 'fileencoding': [['', 'latin1', 'xxx'], []],
90 \ 'fileformat': [['', 'dos', 'unix'], ['xxx']],
91 \ 'fileformats': [['', 'dos', 'dos,unix'], ['xxx']],
92 \ 'fillchars': [['', 'vert:x'], ['xxx']],
93 \ 'foldclose': [['', 'all'], ['xxx']],
94 \ 'foldmethod': [['manual', 'indent'], ['', 'xxx', 'expr,diff']],
95 \ 'foldopen': [['', 'all', 'hor,jump'], ['xxx']],
96 \ 'foldmarker': [['((,))'], ['', 'xxx']],
97 \ 'formatoptions': [['', 'vt', 'v,t'], ['xxx']],
98 \ 'guicursor': [['', 'n:block-Cursor'], ['xxx']],
Bram Moolenaar17471e82017-11-26 23:47:18 +010099 \ 'guifont': [['', fontname], []],
100 \ 'guifontwide': [['', fontname], []],
101 \ 'guifontset': [['', fontname], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100102 \ 'helplang': [['', 'de', 'de,it'], ['xxx']],
103 \ 'highlight': [['', 'e:Error'], ['xxx']],
Bram Moolenaar86e57922017-04-23 18:44:26 +0200104 \ 'imactivatekey': [['', 'S-space'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100105 \ 'isfname': [['', '@', '@,48-52'], ['xxx', '@48']],
106 \ 'isident': [['', '@', '@,48-52'], ['xxx', '@48']],
107 \ 'iskeyword': [['', '@', '@,48-52'], ['xxx', '@48']],
108 \ 'isprint': [['', '@', '@,48-52'], ['xxx', '@48']],
109 \ 'keymap': [['', 'accents'], ['xxx']],
110 \ 'keymodel': [['', 'startsel', 'startsel,stopsel'], ['xxx']],
111 \ 'langmap': [['', 'xX', 'aA,bB'], ['xxx']],
112 \ 'listchars': [['', 'eol:x', 'eol:x,space:y'], ['xxx']],
113 \ 'matchpairs': [['', '(:)', '(:),<:>'], ['xxx']],
114 \ 'mkspellmem': [['10000,100,12'], ['', 'xxx']],
115 \ 'mouse': [['', 'a', 'nvi'], ['xxx', 'n,v,i']],
116 \ 'mousemodel': [['', 'popup'], ['xxx']],
117 \ 'mouseshape': [['', 'n:arrow'], ['xxx']],
118 \ 'nrformats': [['', 'alpha', 'alpha,hex,bin'], ['xxx']],
119 \ 'printmbfont': [['', 'r:some', 'b:Bold,c:yes'], ['xxx']],
120 \ 'printoptions': [['', 'header:0', 'left:10pc,top:5pc'], ['xxx']],
121 \ 'scrollopt': [['', 'ver', 'ver,hor'], ['xxx']],
Bram Moolenaarbb962262017-03-08 00:01:35 +0100122 \ 'renderoptions': [['', 'type:directx'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100123 \ 'selection': [['old', 'inclusive'], ['', 'xxx']],
124 \ 'selectmode': [['', 'mouse', 'key,cmd'], ['xxx']],
125 \ 'sessionoptions': [['', 'blank', 'help,options,slash'], ['xxx']],
126 \ 'signcolumn': [['', 'auto', 'no'], ['xxx', 'no,yes']],
127 \ 'spellfile': [['', 'file.en.add'], ['xxx', '/tmp/file']],
128 \ 'spellsuggest': [['', 'best', 'double,33'], ['xxx']],
129 \ 'switchbuf': [['', 'useopen', 'split,newtab'], ['xxx']],
130 \ 'tagcase': [['smart', 'match'], ['', 'xxx', 'smart,match']],
Bram Moolenaarbb962262017-03-08 00:01:35 +0100131 \ 'term': [[], []],
Bram Moolenaarcafafb32018-02-22 21:07:09 +0100132 \ 'termguicolors': [[], []],
Bram Moolenaar17471e82017-11-26 23:47:18 +0100133 \ 'termencoding': [has('gui_gtk') ? [] : ['', 'utf-8'], ['xxx']],
Bram Moolenaar6d150f72018-04-21 20:03:20 +0200134 \ 'termsize': [['', '24x80', '0x80', '32x0', '0x0'], ['xxx', '80', '8ax9', '24x80b']],
135 \ 'termwinsize': [['', '24x80', '0x80', '32x0', '0x0'], ['xxx', '80', '8ax9', '24x80b']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100136 \ 'toolbar': [['', 'icons', 'text'], ['xxx']],
137 \ 'toolbariconsize': [['', 'tiny', 'huge'], ['xxx']],
138 \ 'ttymouse': [['', 'xterm'], ['xxx']],
Bram Moolenaarbb962262017-03-08 00:01:35 +0100139 \ 'ttytype': [[], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100140 \ 'viewoptions': [['', 'cursor', 'unix,slash'], ['xxx']],
141 \ 'viminfo': [['', '''50', '"30'], ['xxx']],
142 \ 'virtualedit': [['', 'all', 'all,block'], ['xxx']],
143 \ 'whichwrap': [['', 'b,s', 'bs'], ['xxx']],
144 \ 'wildmode': [['', 'full', 'list:full', 'full,longest'], ['xxx']],
145 \ 'wildoptions': [['', 'tagfile'], ['xxx']],
146 \ 'winaltkeys': [['menu', 'no'], ['', 'xxx']],
147 \
148 \ 'luadll': [[], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100149 \ 'perldll': [[], []],
150 \ 'pythondll': [[], []],
151 \ 'pythonthreedll': [[], []],
152 \ 'pyxversion': [[], []],
153 \ 'rubydll': [[], []],
154 \ 'tcldll': [[], []],
155 \
Bram Moolenaara12e4032017-02-25 21:37:57 +0100156 \ 'othernum': [[-1, 0, 100], ['']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100157 \ 'otherstring': [['', 'xxx'], []],
158 \}
159
1601
161/struct vimoption options
162while 1
163 /{"
164 if line('.') > end
165 break
166 endif
167 let line = getline('.')
168 let name = substitute(line, '.*{"\([^"]*\)".*', '\1', '')
169 let shortname = substitute(line, '.*"\([^"]*\)".*', '\1', '')
170
171 if has_key(test_values, name)
172 let a = test_values[name]
173 elseif line =~ 'P_NUM'
174 let a = test_values['othernum']
175 else
176 let a = test_values['otherstring']
177 endif
178 if len(a[0]) > 0 || len(a[1]) > 0
179 if line =~ 'P_BOOL'
180 call add(script, 'set ' . name)
181 call add(script, 'set ' . shortname)
182 call add(script, 'set no' . name)
183 call add(script, 'set no' . shortname)
184 else
185 for val in a[0]
186 call add(script, 'set ' . name . '=' . val)
187 call add(script, 'set ' . shortname . '=' . val)
188 endfor
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100189
190 " setting an option can only fail when it's implemented.
191 call add(script, "if exists('+" . name . "')")
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100192 for val in a[1]
193 call add(script, "call assert_fails('set " . name . "=" . val . "')")
194 call add(script, "call assert_fails('set " . shortname . "=" . val . "')")
195 endfor
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100196 call add(script, "endif")
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100197 endif
198
Bram Moolenaar17471e82017-11-26 23:47:18 +0100199 " cannot change 'termencoding' in GTK
200 if name != 'termencoding' || !has('gui_gtk')
201 call add(script, 'set ' . name . '&')
202 call add(script, 'set ' . shortname . '&')
203 endif
Bram Moolenaarb4c55722017-03-19 19:11:35 +0100204 if name == 'verbosefile'
205 call add(script, 'call delete("xxx")')
206 endif
Bram Moolenaar65408f72017-03-07 21:31:27 +0100207
208 if name == 'more'
209 call add(script, 'set nomore')
Bram Moolenaarbb962262017-03-08 00:01:35 +0100210 elseif name == 'lines'
211 call add(script, 'let &lines = save_lines')
Bram Moolenaar65408f72017-03-07 21:31:27 +0100212 endif
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100213 endif
214endwhile
215
216call add(script, 'let &term = save_term')
217call add(script, 'let &columns = save_columns')
218call add(script, 'let &lines = save_lines')
219
Bram Moolenaare8512d72017-03-07 22:33:32 +0100220call writefile(script, 'opt_test.vim')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100221
Bram Moolenaar5b3af142017-02-27 22:59:40 +0100222endif
223
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100224qa!