view src/testdir/test_cmdmods.vim @ 33525:09dac7f0916b v9.0.2011

patch 9.0.2011: INI files not detected Commit: https://github.com/vim/vim/commit/4a82bdfaa8022402b1ca0f0000c94c47a13f1014 Author: Martin Tournoij <martin@arp242.net> Date: Wed Oct 11 21:20:06 2023 +0200 patch 9.0.2011: INI files not detected Problem: INI files not detected Solution: detect uppercase .INI as dosini files It previo~1 only worked for lower-case .ini files, but upperc~1 .INI is also somewhat common on account of DOS' old 8.3 upperc~2 only filena~1. closes: #13316 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Martin Tournoij <martin@arp242.net>
author Christian Brabandt <cb@256bit.org>
date Wed, 11 Oct 2023 21:30:07 +0200
parents 5acc0d2cf4f7
children cda1a8a06777
line wrap: on
line source

" Test for all command modifiers in

def Test_cmdmods_array()
  # Get all the command modifiers from ex_cmds.h.
  var lines = readfile('../ex_cmds.h')->filter((_, l) => l =~ 'ex_wrongmodifier,')
  var cmds = lines->map((_, v) => substitute(v, '.*"\(\k*\)".*', '\1', ''))

  # :hide is both a command and a modifier
  cmds->extend(['hide'])

  # Get the entries of cmdmods[] in ex_docmd.c
  edit ../ex_docmd.c
  var top = search('^} cmdmods[') + 1
  var bot = search('^};') - 1
  lines = getline(top, bot)
  var mods = lines->map((_, v) => substitute(v, '.*"\(\k*\)".*', '\1', ''))

  # Add the other commands that use ex_wrongmodifier.
  mods->extend([
                'endclass',
                'endenum',
                'endinterface',
                'public',
                'static',
                'this',
              ])

  # Check the lists are equal.  Convert them to a dict to get a clearer error
  # message.
  var cmds_dict = {}
  for v in cmds
    cmds_dict[v] = 1
  endfor
  var mods_dict = {}
  for v in mods
    mods_dict[v] = 1
  endfor
  assert_equal(cmds_dict, mods_dict)

  bwipe!
enddef


" vim: shiftwidth=2 sts=2 expandtab