blob: 32283c99bf4ff0d34de4787badfc8416f5ecf7d2 [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
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]],
Bram Moolenaarc43a8b82017-02-25 21:12:29 +010032 \ 'iminsert': [[0, 1], [-1, 3, 999]],
33 \ 'imsearch': [[-1, 0, 1], [-2, 3, 999]],
Bram Moolenaar5c6dbcb2017-08-30 22:00:20 +020034 \ 'imstyle': [[0, 1], [-1, 2, 999]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010035 \ 'lines': [[2, 24], [-1, 0, 1]],
Bram Moolenaarbb962262017-03-08 00:01:35 +010036 \ 'linespace': [[0, 2, 4], ['']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010037 \ 'numberwidth': [[1, 4, 8, 10], [-1, 0, 11]],
38 \ 'regexpengine': [[0, 1, 2], [-1, 3, 999]],
39 \ 'report': [[0, 1, 2, 9999], [-1]],
40 \ 'scroll': [[0, 1, 2, 20], [-1]],
41 \ 'scrolljump': [[-50, -1, 0, 1, 2, 20], [999]],
42 \ 'scrolloff': [[0, 1, 2, 20], [-1]],
43 \ 'shiftwidth': [[0, 1, 8, 999], [-1]],
44 \ 'sidescroll': [[0, 1, 8, 999], [-1]],
45 \ 'sidescrolloff': [[0, 1, 8, 999], [-1]],
46 \ 'tabstop': [[1, 4, 8, 12], [-1, 0]],
47 \ 'textwidth': [[0, 1, 8, 99], [-1]],
48 \ 'timeoutlen': [[0, 8, 99999], [-1]],
49 \ 'titlelen': [[0, 1, 8, 9999], [-1]],
50 \ 'updatecount': [[0, 1, 8, 9999], [-1]],
51 \ 'updatetime': [[0, 1, 8, 9999], [-1]],
52 \ 'verbose': [[-1, 0, 1, 8, 9999], []],
Bram Moolenaara12e4032017-02-25 21:37:57 +010053 \ 'wildcharm': [[-1, 0, 100], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010054 \ 'winheight': [[1, 10, 999], [-1, 0]],
55 \ 'winminheight': [[0, 1], [-1]],
56 \ 'winminwidth': [[0, 1, 10], [-1]],
57 \ 'winwidth': [[1, 10, 999], [-1, 0]],
58 \
59 \ 'ambiwidth': [['', 'single'], ['xxx']],
60 \ 'background': [['', 'light', 'dark'], ['xxx']],
61 \ 'backspace': [[0, 2, '', 'eol', 'eol,start'], ['xxx']],
62 \ 'backupcopy': [['yes', 'auto'], ['', 'xxx', 'yes,no']],
63 \ 'backupext': [['xxx'], ['']],
64 \ 'belloff': [['', 'all', 'copy,error'], ['xxx']],
65 \ 'breakindentopt': [['', 'min:3', 'sbr'], ['xxx', 'min', 'min:x']],
Bram Moolenaarbb962262017-03-08 00:01:35 +010066 \ 'browsedir': [['', 'last', '/'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010067 \ 'bufhidden': [['', 'hide', 'wipe'], ['xxx', 'hide,wipe']],
68 \ 'buftype': [['', 'help', 'nofile'], ['xxx', 'help,nofile']],
69 \ 'casemap': [['', 'internal'], ['xxx']],
70 \ 'cedit': [['', '\<Esc>'], ['xxx', 'f']],
71 \ 'clipboard': [['', 'unnamed', 'autoselect,unnamed'], ['xxx']],
72 \ 'colorcolumn': [['', '8', '+2'], ['xxx']],
73 \ 'comments': [['', 'b:#'], ['xxx']],
74 \ 'commentstring': [['', '/*%s*/'], ['xxx']],
75 \ 'complete': [['', 'w,b'], ['xxx']],
76 \ 'concealcursor': [['', 'n', 'nvic'], ['xxx']],
77 \ 'completeopt': [['', 'menu', 'menu,longest'], ['xxx', 'menu,,,longest,']],
78 \ 'cryptmethod': [['', 'zip'], ['xxx']],
79 \ 'cscopequickfix': [['', 's-', 's-,c+,e0'], ['xxx', 's,g,d']],
80 \ 'debug': [['', 'msg', 'msg', 'beep'], ['xxx']],
81 \ 'diffopt': [['', 'filler', 'icase,iwhite'], ['xxx']],
82 \ 'display': [['', 'lastline', 'lastline,uhex'], ['xxx']],
83 \ 'eadirection': [['', 'both', 'ver'], ['xxx', 'ver,hor']],
84 \ 'encoding': [['latin1'], ['xxx', '']],
85 \ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter'], ['xxx']],
86 \ 'fileencoding': [['', 'latin1', 'xxx'], []],
87 \ 'fileformat': [['', 'dos', 'unix'], ['xxx']],
88 \ 'fileformats': [['', 'dos', 'dos,unix'], ['xxx']],
89 \ 'fillchars': [['', 'vert:x'], ['xxx']],
90 \ 'foldclose': [['', 'all'], ['xxx']],
91 \ 'foldmethod': [['manual', 'indent'], ['', 'xxx', 'expr,diff']],
92 \ 'foldopen': [['', 'all', 'hor,jump'], ['xxx']],
93 \ 'foldmarker': [['((,))'], ['', 'xxx']],
94 \ 'formatoptions': [['', 'vt', 'v,t'], ['xxx']],
95 \ 'guicursor': [['', 'n:block-Cursor'], ['xxx']],
Bram Moolenaarbb962262017-03-08 00:01:35 +010096 \ 'guifont': [['', 'fixedsys'], []],
97 \ 'guifontwide': [['', 'fixedsys'], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010098 \ 'helplang': [['', 'de', 'de,it'], ['xxx']],
99 \ 'highlight': [['', 'e:Error'], ['xxx']],
Bram Moolenaar86e57922017-04-23 18:44:26 +0200100 \ 'imactivatekey': [['', 'S-space'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100101 \ 'isfname': [['', '@', '@,48-52'], ['xxx', '@48']],
102 \ 'isident': [['', '@', '@,48-52'], ['xxx', '@48']],
103 \ 'iskeyword': [['', '@', '@,48-52'], ['xxx', '@48']],
104 \ 'isprint': [['', '@', '@,48-52'], ['xxx', '@48']],
105 \ 'keymap': [['', 'accents'], ['xxx']],
106 \ 'keymodel': [['', 'startsel', 'startsel,stopsel'], ['xxx']],
107 \ 'langmap': [['', 'xX', 'aA,bB'], ['xxx']],
108 \ 'listchars': [['', 'eol:x', 'eol:x,space:y'], ['xxx']],
109 \ 'matchpairs': [['', '(:)', '(:),<:>'], ['xxx']],
110 \ 'mkspellmem': [['10000,100,12'], ['', 'xxx']],
111 \ 'mouse': [['', 'a', 'nvi'], ['xxx', 'n,v,i']],
112 \ 'mousemodel': [['', 'popup'], ['xxx']],
113 \ 'mouseshape': [['', 'n:arrow'], ['xxx']],
114 \ 'nrformats': [['', 'alpha', 'alpha,hex,bin'], ['xxx']],
115 \ 'printmbfont': [['', 'r:some', 'b:Bold,c:yes'], ['xxx']],
116 \ 'printoptions': [['', 'header:0', 'left:10pc,top:5pc'], ['xxx']],
117 \ 'scrollopt': [['', 'ver', 'ver,hor'], ['xxx']],
Bram Moolenaarbb962262017-03-08 00:01:35 +0100118 \ 'renderoptions': [['', 'type:directx'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100119 \ 'selection': [['old', 'inclusive'], ['', 'xxx']],
120 \ 'selectmode': [['', 'mouse', 'key,cmd'], ['xxx']],
121 \ 'sessionoptions': [['', 'blank', 'help,options,slash'], ['xxx']],
122 \ 'signcolumn': [['', 'auto', 'no'], ['xxx', 'no,yes']],
123 \ 'spellfile': [['', 'file.en.add'], ['xxx', '/tmp/file']],
124 \ 'spellsuggest': [['', 'best', 'double,33'], ['xxx']],
125 \ 'switchbuf': [['', 'useopen', 'split,newtab'], ['xxx']],
126 \ 'tagcase': [['smart', 'match'], ['', 'xxx', 'smart,match']],
Bram Moolenaarbb962262017-03-08 00:01:35 +0100127 \ 'term': [[], []],
Bram Moolenaar825680f2017-07-22 17:04:02 +0200128 \ 'termsize': [['', '24x80', '0x80', '32x0', '0x0'], ['xxx', '80', '8ax9', '24x80b']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100129 \ 'toolbar': [['', 'icons', 'text'], ['xxx']],
130 \ 'toolbariconsize': [['', 'tiny', 'huge'], ['xxx']],
131 \ 'ttymouse': [['', 'xterm'], ['xxx']],
Bram Moolenaarbb962262017-03-08 00:01:35 +0100132 \ 'ttytype': [[], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100133 \ 'viewoptions': [['', 'cursor', 'unix,slash'], ['xxx']],
134 \ 'viminfo': [['', '''50', '"30'], ['xxx']],
135 \ 'virtualedit': [['', 'all', 'all,block'], ['xxx']],
136 \ 'whichwrap': [['', 'b,s', 'bs'], ['xxx']],
137 \ 'wildmode': [['', 'full', 'list:full', 'full,longest'], ['xxx']],
138 \ 'wildoptions': [['', 'tagfile'], ['xxx']],
139 \ 'winaltkeys': [['menu', 'no'], ['', 'xxx']],
140 \
141 \ 'luadll': [[], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100142 \ 'perldll': [[], []],
143 \ 'pythondll': [[], []],
144 \ 'pythonthreedll': [[], []],
145 \ 'pyxversion': [[], []],
146 \ 'rubydll': [[], []],
147 \ 'tcldll': [[], []],
148 \
Bram Moolenaara12e4032017-02-25 21:37:57 +0100149 \ 'othernum': [[-1, 0, 100], ['']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100150 \ 'otherstring': [['', 'xxx'], []],
151 \}
152
1531
154/struct vimoption options
155while 1
156 /{"
157 if line('.') > end
158 break
159 endif
160 let line = getline('.')
161 let name = substitute(line, '.*{"\([^"]*\)".*', '\1', '')
162 let shortname = substitute(line, '.*"\([^"]*\)".*', '\1', '')
163
164 if has_key(test_values, name)
165 let a = test_values[name]
166 elseif line =~ 'P_NUM'
167 let a = test_values['othernum']
168 else
169 let a = test_values['otherstring']
170 endif
171 if len(a[0]) > 0 || len(a[1]) > 0
172 if line =~ 'P_BOOL'
173 call add(script, 'set ' . name)
174 call add(script, 'set ' . shortname)
175 call add(script, 'set no' . name)
176 call add(script, 'set no' . shortname)
177 else
178 for val in a[0]
179 call add(script, 'set ' . name . '=' . val)
180 call add(script, 'set ' . shortname . '=' . val)
181 endfor
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100182
183 " setting an option can only fail when it's implemented.
184 call add(script, "if exists('+" . name . "')")
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100185 for val in a[1]
186 call add(script, "call assert_fails('set " . name . "=" . val . "')")
187 call add(script, "call assert_fails('set " . shortname . "=" . val . "')")
188 endfor
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100189 call add(script, "endif")
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100190 endif
191
192 call add(script, 'set ' . name . '&')
193 call add(script, 'set ' . shortname . '&')
Bram Moolenaarb4c55722017-03-19 19:11:35 +0100194 if name == 'verbosefile'
195 call add(script, 'call delete("xxx")')
196 endif
Bram Moolenaar65408f72017-03-07 21:31:27 +0100197
198 if name == 'more'
199 call add(script, 'set nomore')
Bram Moolenaarbb962262017-03-08 00:01:35 +0100200 elseif name == 'lines'
201 call add(script, 'let &lines = save_lines')
Bram Moolenaar65408f72017-03-07 21:31:27 +0100202 endif
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100203 endif
204endwhile
205
206call add(script, 'let &term = save_term')
207call add(script, 'let &columns = save_columns')
208call add(script, 'let &lines = save_lines')
209
Bram Moolenaare8512d72017-03-07 22:33:32 +0100210call writefile(script, 'opt_test.vim')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100211
Bram Moolenaar5b3af142017-02-27 22:59:40 +0100212endif
213
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100214qa!