dundargoc | c57b5bc | 2022-11-02 13:30:51 +0000 | [diff] [blame] | 1 | " Test for all command modifiers in |
Bram Moolenaar | 9132426 | 2022-09-09 13:27:59 +0100 | [diff] [blame] | 2 | |
| 3 | def Test_cmdmods_array() |
| 4 | # Get all the command modifiers from ex_cmds.h. |
| 5 | var lines = readfile('../ex_cmds.h')->filter((_, l) => l =~ 'ex_wrongmodifier,') |
| 6 | var cmds = lines->map((_, v) => substitute(v, '.*"\(\k*\)".*', '\1', '')) |
| 7 | |
| 8 | # :hide is both a command and a modifier |
| 9 | cmds->extend(['hide']) |
| 10 | |
John Marriott | ed908f7 | 2024-04-18 22:46:56 +0200 | [diff] [blame] | 11 | # Get the entries of cmdmod_info_tab[] in ex_docmd.c |
Bram Moolenaar | 9132426 | 2022-09-09 13:27:59 +0100 | [diff] [blame] | 12 | edit ../ex_docmd.c |
John Marriott | ed908f7 | 2024-04-18 22:46:56 +0200 | [diff] [blame] | 13 | var top = search('^static cmdmod_info_T cmdmod_info_tab[') + 1 |
| 14 | var bot = search('^};.*\/\/ cmdmod_info_tab') - 1 |
Bram Moolenaar | 9132426 | 2022-09-09 13:27:59 +0100 | [diff] [blame] | 15 | lines = getline(top, bot) |
| 16 | var mods = lines->map((_, v) => substitute(v, '.*"\(\k*\)".*', '\1', '')) |
| 17 | |
Bram Moolenaar | c1c365c | 2022-12-04 20:13:24 +0000 | [diff] [blame] | 18 | # Add the other commands that use ex_wrongmodifier. |
| 19 | mods->extend([ |
| 20 | 'endclass', |
| 21 | 'endenum', |
| 22 | 'endinterface', |
| 23 | 'public', |
| 24 | 'static', |
| 25 | 'this', |
| 26 | ]) |
| 27 | |
Bram Moolenaar | 9132426 | 2022-09-09 13:27:59 +0100 | [diff] [blame] | 28 | # Check the lists are equal. Convert them to a dict to get a clearer error |
| 29 | # message. |
| 30 | var cmds_dict = {} |
| 31 | for v in cmds |
| 32 | cmds_dict[v] = 1 |
| 33 | endfor |
| 34 | var mods_dict = {} |
| 35 | for v in mods |
| 36 | mods_dict[v] = 1 |
| 37 | endfor |
| 38 | assert_equal(cmds_dict, mods_dict) |
| 39 | |
| 40 | bwipe! |
| 41 | enddef |
| 42 | |
| 43 | |
| 44 | " vim: shiftwidth=2 sts=2 expandtab |
| 45 | |