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 | |
Doug Kearns | ea84202 | 2024-09-29 17:17:41 +0200 | [diff] [blame] | 43 | def Test_keep_cmdmods_names() |
| 44 | # :k only available in legacy script |
| 45 | legacy call assert_equal('k', fullcommand(':k')) |
| 46 | legacy call assert_equal('k', fullcommand(':ke')) |
| 47 | # single character commands not supported in Vim9 |
| 48 | assert_equal('', fullcommand(':k')) |
| 49 | assert_equal('keepmarks', fullcommand(':ke')) |
| 50 | assert_equal('keepmarks', fullcommand(':kee')) |
| 51 | assert_equal('keepmarks', fullcommand(':keep')) |
| 52 | assert_equal('keepmarks', fullcommand(':keepm')) |
| 53 | assert_equal('keepmarks', fullcommand(':keepma')) |
| 54 | assert_equal('keepmarks', fullcommand(':keepmar')) |
| 55 | assert_equal('keepmarks', fullcommand(':keepmark')) |
| 56 | assert_equal('keepmarks', fullcommand(':keepmarks')) |
| 57 | assert_equal('keepalt', fullcommand(':keepa')) |
| 58 | assert_equal('keepalt', fullcommand(':keepal')) |
| 59 | assert_equal('keepalt', fullcommand(':keepalt')) |
| 60 | assert_equal('keepjumps', fullcommand(':keepj')) |
| 61 | assert_equal('keepjumps', fullcommand(':keepju')) |
| 62 | assert_equal('keepjumps', fullcommand(':keepjum')) |
| 63 | assert_equal('keepjumps', fullcommand(':keepjump')) |
| 64 | assert_equal('keepjumps', fullcommand(':keepjumps')) |
| 65 | assert_equal('keeppatterns', fullcommand(':keepp')) |
| 66 | assert_equal('keeppatterns', fullcommand(':keeppa')) |
| 67 | assert_equal('keeppatterns', fullcommand(':keeppat')) |
| 68 | assert_equal('keeppatterns', fullcommand(':keeppatt')) |
| 69 | assert_equal('keeppatterns', fullcommand(':keeppatte')) |
| 70 | assert_equal('keeppatterns', fullcommand(':keeppatter')) |
| 71 | assert_equal('keeppatterns', fullcommand(':keeppattern')) |
| 72 | assert_equal('keeppatterns', fullcommand(':keeppatterns')) |
| 73 | enddef |
| 74 | |
| 75 | def Test_cmdmod_completion() |
| 76 | assert_equal('edit', getcompletion('keepalt ed', 'cmdline')[0]) |
| 77 | assert_equal('edit', getcompletion('keepjumps ed', 'cmdline')[0]) |
| 78 | assert_equal('edit', getcompletion('keepmarks ed', 'cmdline')[0]) |
| 79 | assert_equal('edit', getcompletion('keeppatterns ed', 'cmdline')[0]) |
| 80 | enddef |
Bram Moolenaar | 9132426 | 2022-09-09 13:27:59 +0100 | [diff] [blame] | 81 | |
| 82 | " vim: shiftwidth=2 sts=2 expandtab |
| 83 | |