blob: 66ff6a1fa8a0df43da62bb45a018a3bf2d42a73c [file] [log] [blame]
dundargocc57b5bc2022-11-02 13:30:51 +00001" Test for all command modifiers in
Bram Moolenaar91324262022-09-09 13:27:59 +01002
3def 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 Marriotted908f72024-04-18 22:46:56 +020011 # Get the entries of cmdmod_info_tab[] in ex_docmd.c
Bram Moolenaar91324262022-09-09 13:27:59 +010012 edit ../ex_docmd.c
John Marriotted908f72024-04-18 22:46:56 +020013 var top = search('^static cmdmod_info_T cmdmod_info_tab[') + 1
14 var bot = search('^};.*\/\/ cmdmod_info_tab') - 1
Bram Moolenaar91324262022-09-09 13:27:59 +010015 lines = getline(top, bot)
16 var mods = lines->map((_, v) => substitute(v, '.*"\(\k*\)".*', '\1', ''))
17
Bram Moolenaarc1c365c2022-12-04 20:13:24 +000018 # 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 Moolenaar91324262022-09-09 13:27:59 +010028 # 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!
41enddef
42
43
44" vim: shiftwidth=2 sts=2 expandtab
45