xref: /vim-8.2.3635/src/testdir/test_tagcase.vim (revision 6d91bcb4)
1" test 'tagcase' option
2
3func Test_tagcase()
4  call writefile(["Bar\tXtext\t3", "Foo\tXtext\t2", "foo\tXtext\t4"], 'Xtags')
5  set tags=Xtags
6  e Xtext
7
8  for &ic in [0, 1]
9    for &scs in [0, 1]
10      for &g:tc in ["followic", "ignore", "match", "followscs", "smart"]
11	for &l:tc in ["", "followic", "ignore", "match", "followscs", "smart"]
12	  let smart = 0
13	  if &l:tc != ''
14	    let tc = &l:tc
15	  else
16	    let tc = &g:tc
17	  endif
18	  if tc == 'followic'
19	    let ic = &ic
20	  elseif tc == 'ignore'
21	    let ic = 1
22	  elseif tc == 'followscs'
23	    let ic = &ic
24	    let smart = &scs
25	  elseif tc == 'smart'
26	    let ic = 1
27	    let smart = 1
28	  else
29	    let ic = 0
30	  endif
31	  if ic && smart
32	    call assert_equal(['foo', 'Foo'], map(taglist("^foo$"), {i, v -> v.name}))
33	    call assert_equal(['Foo'], map(taglist("^Foo$"), {i, v -> v.name}))
34	  elseif ic
35	    call assert_equal(['foo', 'Foo'], map(taglist("^foo$"), {i, v -> v.name}))
36	    call assert_equal(['Foo', 'foo'], map(taglist("^Foo$"), {i, v -> v.name}))
37	  else
38	    call assert_equal(['foo'], map(taglist("^foo$"), {i, v -> v.name}))
39	    call assert_equal(['Foo'], map(taglist("^Foo$"), {i, v -> v.name}))
40	  endif
41	endfor
42      endfor
43    endfor
44  endfor
45
46  call delete('Xtags')
47  set tags&
48  set ic&
49  setg tc&
50  setl tc&
51  set scs&
52endfunc
53
54func Test_set_tagcase()
55  " Verify default values.
56  set ic&
57  setg tc&
58  setl tc&
59  call assert_equal(0, &ic)
60  call assert_equal('followic', &g:tc)
61  call assert_equal('followic', &l:tc)
62  call assert_equal('followic', &tc)
63
64  " Verify that the local setting accepts <empty> but that the global setting
65  " does not.  The first of these (setting the local value to <empty>) should
66  " succeed; the other two should fail.
67  setl tc=
68  call assert_fails('setg tc=', 'E474:')
69  call assert_fails('set tc=', 'E474:')
70
71  set ic&
72  setg tc&
73  setl tc&
74endfunc
75
76" vim: shiftwidth=2 sts=2 expandtab
77