view src/testdir/test_tagcase.vim @ 19783:546bdeef35f1 v8.2.0448

patch 8.2.0448: various functions not properly tested Commit: https://github.com/vim/vim/commit/0e05de46226eb4e5ea580beefa71831f92d613d3 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Mar 25 22:23:46 2020 +0100 patch 8.2.0448: various functions not properly tested Problem: Various functions not properly tested. Solution: Add more tests, especially for failures. (Yegappan Lakshmanan, closes #5843)
author Bram Moolenaar <Bram@vim.org>
date Wed, 25 Mar 2020 22:30:04 +0100
parents 5cda6165a5c1
children 08940efa6b4e
line wrap: on
line source

" test 'tagcase' option

func Test_tagcase()
  call writefile(["Bar\tXtext\t3", "Foo\tXtext\t2", "foo\tXtext\t4"], 'Xtags')
  set tags=Xtags
  e Xtext

  for &ic in [0, 1]
    for &scs in [0, 1]
      for &g:tc in ["followic", "ignore", "match", "followscs", "smart"]
	for &l:tc in ["", "followic", "ignore", "match", "followscs", "smart"]
	  let smart = 0
	  if &l:tc != ''
	    let tc = &l:tc
	  else
	    let tc = &g:tc
	  endif
	  if tc == 'followic'
	    let ic = &ic
	  elseif tc == 'ignore'
	    let ic = 1
	  elseif tc == 'followscs'
	    let ic = &ic
	    let smart = &scs
	  elseif tc == 'smart'
	    let ic = 1
	    let smart = 1
	  else
	    let ic = 0
	  endif
	  if ic && smart
	    call assert_equal(['foo', 'Foo'], map(taglist("^foo$"), {i, v -> v.name}))
	    call assert_equal(['Foo'], map(taglist("^Foo$"), {i, v -> v.name}))
	  elseif ic
	    call assert_equal(['foo', 'Foo'], map(taglist("^foo$"), {i, v -> v.name}))
	    call assert_equal(['Foo', 'foo'], map(taglist("^Foo$"), {i, v -> v.name}))
	  else
	    call assert_equal(['foo'], map(taglist("^foo$"), {i, v -> v.name}))
	    call assert_equal(['Foo'], map(taglist("^Foo$"), {i, v -> v.name}))
	  endif
	endfor
      endfor
    endfor
  endfor

  call delete('Xtags')
  set tags&
  set ic&
  setg tc&
  setl tc&
  set scs&
endfunc

func Test_set_tagcase()
  " Verify default values.
  set ic&
  setg tc&
  setl tc&
  call assert_equal(0, &ic)
  call assert_equal('followic', &g:tc)
  call assert_equal('followic', &l:tc)
  call assert_equal('followic', &tc)

  " Verify that the local setting accepts <empty> but that the global setting
  " does not.  The first of these (setting the local value to <empty>) should
  " succeed; the other two should fail.
  setl tc=
  call assert_fails('setg tc=', 'E474:')
  call assert_fails('set tc=', 'E474:')

  set ic&
  setg tc&
  setl tc&
endfunc