aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/tagcase_spec.lua
blob: e5bdd4658a7f0d65f7988c9047542b1aebf294a4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
local t = require('test.testutil')
local n = require('test.functional.testnvim')()

local clear = n.clear
local eq = t.eq
local eval = n.eval
local exc_exec = n.exc_exec
local expect = n.expect
local insert = n.insert
local source = n.source
local write_file = t.write_file

describe("'tagcase' option", function()
  setup(function()
    write_file(
      'Xtags',
      [[
      Bar	Xtext	3
      Foo	Xtext	2
      foo	Xtext	4]]
    )
  end)

  before_each(function()
    clear()
    source([[
      lang mess C
      set tags=Xtags]])
  end)

  teardown(function()
    os.remove('Xtags')
  end)

  it('should have correct default values', function()
    source([[
      set ic&
      setg tc&
      setl tc&
      ]])

    eq(0, eval('&ic'))
    eq('followic', eval('&g:tc'))
    eq('followic', eval('&l:tc'))
    eq('followic', eval('&tc'))
  end)

  it('should accept <empty> only for setlocal', function()
    -- 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.
    eq(0, exc_exec('setl tc='))
    eq('Vim(setglobal):E474: Invalid argument: tc=', exc_exec('setg tc='))
    eq('Vim(set):E474: Invalid argument: tc=', exc_exec('set tc='))
  end)

  it("should work with 'ignorecase' correctly in all combinations", function()
    -- Verify that the correct number of matching tags is found for all values of
    -- 'ignorecase' and global and local values 'tagcase', in all combinations.
    insert([[

      Foo
      Bar
      foo

      end text]])

    source([[
      for &ic in [0, 1]
        for &g:tc in ["followic", "ignore", "match"]
          for &l:tc in ["", "followic", "ignore", "match"]
            call append('$', "ic=".&ic." g:tc=".&g:tc." l:tc=".&l:tc." tc=".&tc)
            call append('$', len(taglist("^foo$")))
            call append('$', len(taglist("^Foo$")))
          endfor
        endfor
      endfor

      1,/^end text$/d]])

    expect([[
      ic=0 g:tc=followic l:tc= tc=followic
      1
      1
      ic=0 g:tc=followic l:tc=followic tc=followic
      1
      1
      ic=0 g:tc=followic l:tc=ignore tc=ignore
      2
      2
      ic=0 g:tc=followic l:tc=match tc=match
      1
      1
      ic=0 g:tc=ignore l:tc= tc=ignore
      2
      2
      ic=0 g:tc=ignore l:tc=followic tc=followic
      1
      1
      ic=0 g:tc=ignore l:tc=ignore tc=ignore
      2
      2
      ic=0 g:tc=ignore l:tc=match tc=match
      1
      1
      ic=0 g:tc=match l:tc= tc=match
      1
      1
      ic=0 g:tc=match l:tc=followic tc=followic
      1
      1
      ic=0 g:tc=match l:tc=ignore tc=ignore
      2
      2
      ic=0 g:tc=match l:tc=match tc=match
      1
      1
      ic=1 g:tc=followic l:tc= tc=followic
      2
      2
      ic=1 g:tc=followic l:tc=followic tc=followic
      2
      2
      ic=1 g:tc=followic l:tc=ignore tc=ignore
      2
      2
      ic=1 g:tc=followic l:tc=match tc=match
      1
      1
      ic=1 g:tc=ignore l:tc= tc=ignore
      2
      2
      ic=1 g:tc=ignore l:tc=followic tc=followic
      2
      2
      ic=1 g:tc=ignore l:tc=ignore tc=ignore
      2
      2
      ic=1 g:tc=ignore l:tc=match tc=match
      1
      1
      ic=1 g:tc=match l:tc= tc=match
      1
      1
      ic=1 g:tc=match l:tc=followic tc=followic
      2
      2
      ic=1 g:tc=match l:tc=ignore tc=ignore
      2
      2
      ic=1 g:tc=match l:tc=match tc=match
      1
      1]])
  end)
end)