blob: 16723be04ce3232922ef729388082c167e43d6e0 [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 Moolenaar2f5463d2017-02-25 20:40:46 +010034 \ 'lines': [[2, 24], [-1, 0, 1]],
Bram Moolenaarbb962262017-03-08 00:01:35 +010035 \ 'linespace': [[0, 2, 4], ['']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010036 \ '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], []],
Bram Moolenaara12e4032017-02-25 21:37:57 +010052 \ 'wildcharm': [[-1, 0, 100], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010053 \ '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']],
Bram Moolenaarbb962262017-03-08 00:01:35 +010065 \ 'browsedir': [['', 'last', '/'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010066 \ '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']],
Bram Moolenaarbb962262017-03-08 00:01:35 +010095 \ 'guifont': [['', 'fixedsys'], []],
96 \ 'guifontwide': [['', 'fixedsys'], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010097 \ 'helplang': [['', 'de', 'de,it'], ['xxx']],
98 \ 'highlight': [['', 'e:Error'], ['xxx']],
99 \ 'isfname': [['', '@', '@,48-52'], ['xxx', '@48']],
100 \ 'isident': [['', '@', '@,48-52'], ['xxx', '@48']],
101 \ 'iskeyword': [['', '@', '@,48-52'], ['xxx', '@48']],
102 \ 'isprint': [['', '@', '@,48-52'], ['xxx', '@48']],
103 \ 'keymap': [['', 'accents'], ['xxx']],
104 \ 'keymodel': [['', 'startsel', 'startsel,stopsel'], ['xxx']],
105 \ 'langmap': [['', 'xX', 'aA,bB'], ['xxx']],
106 \ 'listchars': [['', 'eol:x', 'eol:x,space:y'], ['xxx']],
107 \ 'matchpairs': [['', '(:)', '(:),<:>'], ['xxx']],
108 \ 'mkspellmem': [['10000,100,12'], ['', 'xxx']],
109 \ 'mouse': [['', 'a', 'nvi'], ['xxx', 'n,v,i']],
110 \ 'mousemodel': [['', 'popup'], ['xxx']],
111 \ 'mouseshape': [['', 'n:arrow'], ['xxx']],
112 \ 'nrformats': [['', 'alpha', 'alpha,hex,bin'], ['xxx']],
113 \ 'printmbfont': [['', 'r:some', 'b:Bold,c:yes'], ['xxx']],
114 \ 'printoptions': [['', 'header:0', 'left:10pc,top:5pc'], ['xxx']],
115 \ 'scrollopt': [['', 'ver', 'ver,hor'], ['xxx']],
Bram Moolenaarbb962262017-03-08 00:01:35 +0100116 \ 'renderoptions': [['', 'type:directx'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100117 \ 'selection': [['old', 'inclusive'], ['', 'xxx']],
118 \ 'selectmode': [['', 'mouse', 'key,cmd'], ['xxx']],
119 \ 'sessionoptions': [['', 'blank', 'help,options,slash'], ['xxx']],
120 \ 'signcolumn': [['', 'auto', 'no'], ['xxx', 'no,yes']],
121 \ 'spellfile': [['', 'file.en.add'], ['xxx', '/tmp/file']],
122 \ 'spellsuggest': [['', 'best', 'double,33'], ['xxx']],
123 \ 'switchbuf': [['', 'useopen', 'split,newtab'], ['xxx']],
124 \ 'tagcase': [['smart', 'match'], ['', 'xxx', 'smart,match']],
Bram Moolenaarbb962262017-03-08 00:01:35 +0100125 \ 'term': [[], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100126 \ 'toolbar': [['', 'icons', 'text'], ['xxx']],
127 \ 'toolbariconsize': [['', 'tiny', 'huge'], ['xxx']],
128 \ 'ttymouse': [['', 'xterm'], ['xxx']],
Bram Moolenaarbb962262017-03-08 00:01:35 +0100129 \ 'ttytype': [[], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100130 \ 'viewoptions': [['', 'cursor', 'unix,slash'], ['xxx']],
131 \ 'viminfo': [['', '''50', '"30'], ['xxx']],
132 \ 'virtualedit': [['', 'all', 'all,block'], ['xxx']],
133 \ 'whichwrap': [['', 'b,s', 'bs'], ['xxx']],
134 \ 'wildmode': [['', 'full', 'list:full', 'full,longest'], ['xxx']],
135 \ 'wildoptions': [['', 'tagfile'], ['xxx']],
136 \ 'winaltkeys': [['menu', 'no'], ['', 'xxx']],
137 \
138 \ 'luadll': [[], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100139 \ 'perldll': [[], []],
140 \ 'pythondll': [[], []],
141 \ 'pythonthreedll': [[], []],
142 \ 'pyxversion': [[], []],
143 \ 'rubydll': [[], []],
144 \ 'tcldll': [[], []],
145 \
Bram Moolenaara12e4032017-02-25 21:37:57 +0100146 \ 'othernum': [[-1, 0, 100], ['']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100147 \ 'otherstring': [['', 'xxx'], []],
148 \}
149
1501
151/struct vimoption options
152while 1
153 /{"
154 if line('.') > end
155 break
156 endif
157 let line = getline('.')
158 let name = substitute(line, '.*{"\([^"]*\)".*', '\1', '')
159 let shortname = substitute(line, '.*"\([^"]*\)".*', '\1', '')
160
161 if has_key(test_values, name)
162 let a = test_values[name]
163 elseif line =~ 'P_NUM'
164 let a = test_values['othernum']
165 else
166 let a = test_values['otherstring']
167 endif
168 if len(a[0]) > 0 || len(a[1]) > 0
169 if line =~ 'P_BOOL'
170 call add(script, 'set ' . name)
171 call add(script, 'set ' . shortname)
172 call add(script, 'set no' . name)
173 call add(script, 'set no' . shortname)
174 else
175 for val in a[0]
176 call add(script, 'set ' . name . '=' . val)
177 call add(script, 'set ' . shortname . '=' . val)
Bram Moolenaar65408f72017-03-07 21:31:27 +0100178
179 if name == 'verbosefile' && !empty(val)
180 call add(script, 'call delete("'. val. '")')
181 endif
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100182 endfor
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100183
184 " setting an option can only fail when it's implemented.
185 call add(script, "if exists('+" . name . "')")
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100186 for val in a[1]
187 call add(script, "call assert_fails('set " . name . "=" . val . "')")
188 call add(script, "call assert_fails('set " . shortname . "=" . val . "')")
189 endfor
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100190 call add(script, "endif")
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100191 endif
192
193 call add(script, 'set ' . name . '&')
194 call add(script, 'set ' . shortname . '&')
Bram Moolenaar65408f72017-03-07 21:31:27 +0100195
196 if name == 'more'
197 call add(script, 'set nomore')
Bram Moolenaarbb962262017-03-08 00:01:35 +0100198 elseif name == 'lines'
199 call add(script, 'let &lines = save_lines')
Bram Moolenaar65408f72017-03-07 21:31:27 +0100200 endif
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100201 endif
202endwhile
203
204call add(script, 'let &term = save_term')
205call add(script, 'let &columns = save_columns')
206call add(script, 'let &lines = save_lines')
207
Bram Moolenaare8512d72017-03-07 22:33:32 +0100208call writefile(script, 'opt_test.vim')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100209
Bram Moolenaar5b3af142017-02-27 22:59:40 +0100210endif
211
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100212qa!