comparison src/gen_opt_test.vim @ 10958:e5896de85dcf v8.0.0368

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