Bram Moolenaar | 2f5463d | 2017-02-25 20:40:46 +0100 | [diff] [blame] | 1 | " Script to generate testdir/opt_test.vim from option.c |
| 2 | |
Bram Moolenaar | 2f5463d | 2017-02-25 20:40:46 +0100 | [diff] [blame] | 3 | set cpo=&vim |
Bram Moolenaar | 5b3af14 | 2017-02-27 22:59:40 +0100 | [diff] [blame] | 4 | |
| 5 | " Only do this when build with the +eval feature. |
| 6 | if 1 |
| 7 | |
Bram Moolenaar | 2f5463d | 2017-02-25 20:40:46 +0100 | [diff] [blame] | 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]], |
Bram Moolenaar | c43a8b8 | 2017-02-25 21:12:29 +0100 | [diff] [blame] | 30 | \ 'iminsert': [[0, 1], [-1, 3, 999]], |
| 31 | \ 'imsearch': [[-1, 0, 1], [-2, 3, 999]], |
Bram Moolenaar | 2f5463d | 2017-02-25 20:40:46 +0100 | [diff] [blame] | 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], []], |
Bram Moolenaar | a12e403 | 2017-02-25 21:37:57 +0100 | [diff] [blame] | 49 | \ 'wildcharm': [[-1, 0, 100], []], |
Bram Moolenaar | 2f5463d | 2017-02-25 20:40:46 +0100 | [diff] [blame] | 50 | \ 'winheight': [[1, 10, 999], [-1, 0]], |
| 51 | \ 'winminheight': [[0, 1], [-1]], |
| 52 | \ 'winminwidth': [[0, 1, 10], [-1]], |
| 53 | \ 'winwidth': [[1, 10, 999], [-1, 0]], |
| 54 | \ |
| 55 | \ 'ambiwidth': [['', 'single'], ['xxx']], |
| 56 | \ 'background': [['', 'light', 'dark'], ['xxx']], |
| 57 | \ 'backspace': [[0, 2, '', 'eol', 'eol,start'], ['xxx']], |
| 58 | \ 'backupcopy': [['yes', 'auto'], ['', 'xxx', 'yes,no']], |
| 59 | \ 'backupext': [['xxx'], ['']], |
| 60 | \ 'belloff': [['', 'all', 'copy,error'], ['xxx']], |
| 61 | \ 'breakindentopt': [['', 'min:3', 'sbr'], ['xxx', 'min', 'min:x']], |
| 62 | \ 'browsedir': [['', 'last', '/tmp/'], ['xxx']], |
| 63 | \ 'bufhidden': [['', 'hide', 'wipe'], ['xxx', 'hide,wipe']], |
| 64 | \ 'buftype': [['', 'help', 'nofile'], ['xxx', 'help,nofile']], |
| 65 | \ 'casemap': [['', 'internal'], ['xxx']], |
| 66 | \ 'cedit': [['', '\<Esc>'], ['xxx', 'f']], |
| 67 | \ 'clipboard': [['', 'unnamed', 'autoselect,unnamed'], ['xxx']], |
| 68 | \ 'colorcolumn': [['', '8', '+2'], ['xxx']], |
| 69 | \ 'comments': [['', 'b:#'], ['xxx']], |
| 70 | \ 'commentstring': [['', '/*%s*/'], ['xxx']], |
| 71 | \ 'complete': [['', 'w,b'], ['xxx']], |
| 72 | \ 'concealcursor': [['', 'n', 'nvic'], ['xxx']], |
| 73 | \ 'completeopt': [['', 'menu', 'menu,longest'], ['xxx', 'menu,,,longest,']], |
| 74 | \ 'cryptmethod': [['', 'zip'], ['xxx']], |
| 75 | \ 'cscopequickfix': [['', 's-', 's-,c+,e0'], ['xxx', 's,g,d']], |
| 76 | \ 'debug': [['', 'msg', 'msg', 'beep'], ['xxx']], |
| 77 | \ 'diffopt': [['', 'filler', 'icase,iwhite'], ['xxx']], |
| 78 | \ 'display': [['', 'lastline', 'lastline,uhex'], ['xxx']], |
| 79 | \ 'eadirection': [['', 'both', 'ver'], ['xxx', 'ver,hor']], |
| 80 | \ 'encoding': [['latin1'], ['xxx', '']], |
| 81 | \ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter'], ['xxx']], |
| 82 | \ 'fileencoding': [['', 'latin1', 'xxx'], []], |
| 83 | \ 'fileformat': [['', 'dos', 'unix'], ['xxx']], |
| 84 | \ 'fileformats': [['', 'dos', 'dos,unix'], ['xxx']], |
| 85 | \ 'fillchars': [['', 'vert:x'], ['xxx']], |
| 86 | \ 'foldclose': [['', 'all'], ['xxx']], |
| 87 | \ 'foldmethod': [['manual', 'indent'], ['', 'xxx', 'expr,diff']], |
| 88 | \ 'foldopen': [['', 'all', 'hor,jump'], ['xxx']], |
| 89 | \ 'foldmarker': [['((,))'], ['', 'xxx']], |
| 90 | \ 'formatoptions': [['', 'vt', 'v,t'], ['xxx']], |
| 91 | \ 'guicursor': [['', 'n:block-Cursor'], ['xxx']], |
| 92 | \ 'helplang': [['', 'de', 'de,it'], ['xxx']], |
| 93 | \ 'highlight': [['', 'e:Error'], ['xxx']], |
| 94 | \ 'isfname': [['', '@', '@,48-52'], ['xxx', '@48']], |
| 95 | \ 'isident': [['', '@', '@,48-52'], ['xxx', '@48']], |
| 96 | \ 'iskeyword': [['', '@', '@,48-52'], ['xxx', '@48']], |
| 97 | \ 'isprint': [['', '@', '@,48-52'], ['xxx', '@48']], |
| 98 | \ 'keymap': [['', 'accents'], ['xxx']], |
| 99 | \ 'keymodel': [['', 'startsel', 'startsel,stopsel'], ['xxx']], |
| 100 | \ 'langmap': [['', 'xX', 'aA,bB'], ['xxx']], |
| 101 | \ 'listchars': [['', 'eol:x', 'eol:x,space:y'], ['xxx']], |
| 102 | \ 'matchpairs': [['', '(:)', '(:),<:>'], ['xxx']], |
| 103 | \ 'mkspellmem': [['10000,100,12'], ['', 'xxx']], |
| 104 | \ 'mouse': [['', 'a', 'nvi'], ['xxx', 'n,v,i']], |
| 105 | \ 'mousemodel': [['', 'popup'], ['xxx']], |
| 106 | \ 'mouseshape': [['', 'n:arrow'], ['xxx']], |
| 107 | \ 'nrformats': [['', 'alpha', 'alpha,hex,bin'], ['xxx']], |
| 108 | \ 'printmbfont': [['', 'r:some', 'b:Bold,c:yes'], ['xxx']], |
| 109 | \ 'printoptions': [['', 'header:0', 'left:10pc,top:5pc'], ['xxx']], |
| 110 | \ 'scrollopt': [['', 'ver', 'ver,hor'], ['xxx']], |
| 111 | \ 'selection': [['old', 'inclusive'], ['', 'xxx']], |
| 112 | \ 'selectmode': [['', 'mouse', 'key,cmd'], ['xxx']], |
| 113 | \ 'sessionoptions': [['', 'blank', 'help,options,slash'], ['xxx']], |
| 114 | \ 'signcolumn': [['', 'auto', 'no'], ['xxx', 'no,yes']], |
| 115 | \ 'spellfile': [['', 'file.en.add'], ['xxx', '/tmp/file']], |
| 116 | \ 'spellsuggest': [['', 'best', 'double,33'], ['xxx']], |
| 117 | \ 'switchbuf': [['', 'useopen', 'split,newtab'], ['xxx']], |
| 118 | \ 'tagcase': [['smart', 'match'], ['', 'xxx', 'smart,match']], |
| 119 | \ 'term': [['ansi'], ['', 'gui']], |
| 120 | \ 'toolbar': [['', 'icons', 'text'], ['xxx']], |
| 121 | \ 'toolbariconsize': [['', 'tiny', 'huge'], ['xxx']], |
| 122 | \ 'ttymouse': [['', 'xterm'], ['xxx']], |
| 123 | \ 'ttytype': [['ansi'], ['', 'gui']], |
| 124 | \ 'viewoptions': [['', 'cursor', 'unix,slash'], ['xxx']], |
| 125 | \ 'viminfo': [['', '''50', '"30'], ['xxx']], |
| 126 | \ 'virtualedit': [['', 'all', 'all,block'], ['xxx']], |
| 127 | \ 'whichwrap': [['', 'b,s', 'bs'], ['xxx']], |
| 128 | \ 'wildmode': [['', 'full', 'list:full', 'full,longest'], ['xxx']], |
| 129 | \ 'wildoptions': [['', 'tagfile'], ['xxx']], |
| 130 | \ 'winaltkeys': [['menu', 'no'], ['', 'xxx']], |
| 131 | \ |
| 132 | \ 'luadll': [[], []], |
Bram Moolenaar | 2f5463d | 2017-02-25 20:40:46 +0100 | [diff] [blame] | 133 | \ 'perldll': [[], []], |
| 134 | \ 'pythondll': [[], []], |
| 135 | \ 'pythonthreedll': [[], []], |
| 136 | \ 'pyxversion': [[], []], |
| 137 | \ 'rubydll': [[], []], |
| 138 | \ 'tcldll': [[], []], |
| 139 | \ |
Bram Moolenaar | a12e403 | 2017-02-25 21:37:57 +0100 | [diff] [blame] | 140 | \ 'othernum': [[-1, 0, 100], ['']], |
Bram Moolenaar | 2f5463d | 2017-02-25 20:40:46 +0100 | [diff] [blame] | 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) |
Bram Moolenaar | 65408f7 | 2017-03-07 21:31:27 +0100 | [diff] [blame^] | 172 | |
| 173 | if name == 'verbosefile' && !empty(val) |
| 174 | call add(script, 'call delete("'. val. '")') |
| 175 | endif |
Bram Moolenaar | 2f5463d | 2017-02-25 20:40:46 +0100 | [diff] [blame] | 176 | endfor |
Bram Moolenaar | c43a8b8 | 2017-02-25 21:12:29 +0100 | [diff] [blame] | 177 | |
| 178 | " setting an option can only fail when it's implemented. |
| 179 | call add(script, "if exists('+" . name . "')") |
Bram Moolenaar | 2f5463d | 2017-02-25 20:40:46 +0100 | [diff] [blame] | 180 | for val in a[1] |
| 181 | call add(script, "call assert_fails('set " . name . "=" . val . "')") |
| 182 | call add(script, "call assert_fails('set " . shortname . "=" . val . "')") |
| 183 | endfor |
Bram Moolenaar | c43a8b8 | 2017-02-25 21:12:29 +0100 | [diff] [blame] | 184 | call add(script, "endif") |
Bram Moolenaar | 2f5463d | 2017-02-25 20:40:46 +0100 | [diff] [blame] | 185 | endif |
| 186 | |
| 187 | call add(script, 'set ' . name . '&') |
| 188 | call add(script, 'set ' . shortname . '&') |
Bram Moolenaar | 65408f7 | 2017-03-07 21:31:27 +0100 | [diff] [blame^] | 189 | |
| 190 | if name == 'more' |
| 191 | call add(script, 'set nomore') |
| 192 | endif |
Bram Moolenaar | 2f5463d | 2017-02-25 20:40:46 +0100 | [diff] [blame] | 193 | endif |
| 194 | endwhile |
| 195 | |
| 196 | call add(script, 'let &term = save_term') |
| 197 | call add(script, 'let &columns = save_columns') |
| 198 | call add(script, 'let &lines = save_lines') |
| 199 | |
| 200 | call writefile(script, 'testdir/opt_test.vim') |
| 201 | |
Bram Moolenaar | 5b3af14 | 2017-02-27 22:59:40 +0100 | [diff] [blame] | 202 | endif |
| 203 | |
Bram Moolenaar | 2f5463d | 2017-02-25 20:40:46 +0100 | [diff] [blame] | 204 | qa! |