neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

tagcase_spec.lua (3491B)


      1 local t = require('test.testutil')
      2 local n = require('test.functional.testnvim')()
      3 
      4 local clear = n.clear
      5 local eq = t.eq
      6 local eval = n.eval
      7 local exc_exec = n.exc_exec
      8 local expect = n.expect
      9 local insert = n.insert
     10 local source = n.source
     11 local write_file = t.write_file
     12 
     13 describe("'tagcase' option", function()
     14  setup(function()
     15    write_file(
     16      'Xtags',
     17      [[
     18      Bar	Xtext	3
     19      Foo	Xtext	2
     20      foo	Xtext	4]]
     21    )
     22  end)
     23 
     24  before_each(function()
     25    clear()
     26    source([[
     27      lang mess C
     28      set tags=Xtags]])
     29  end)
     30 
     31  teardown(function()
     32    os.remove('Xtags')
     33  end)
     34 
     35  it('should have correct default values', function()
     36    source([[
     37      set ic&
     38      setg tc&
     39      setl tc&
     40      ]])
     41 
     42    eq(0, eval('&ic'))
     43    eq('followic', eval('&g:tc'))
     44    eq('followic', eval('&l:tc'))
     45    eq('followic', eval('&tc'))
     46  end)
     47 
     48  it('should accept <empty> only for setlocal', function()
     49    -- Verify that the local setting accepts <empty> but that the global setting
     50    -- does not.  The first of these (setting the local value to <empty>) should
     51    -- succeed; the other two should fail.
     52    eq(0, exc_exec('setl tc='))
     53    eq('Vim(setglobal):E474: Invalid argument: tc=', exc_exec('setg tc='))
     54    eq('Vim(set):E474: Invalid argument: tc=', exc_exec('set tc='))
     55  end)
     56 
     57  it("should work with 'ignorecase' correctly in all combinations", function()
     58    -- Verify that the correct number of matching tags is found for all values of
     59    -- 'ignorecase' and global and local values 'tagcase', in all combinations.
     60    insert([[
     61 
     62      Foo
     63      Bar
     64      foo
     65 
     66      end text]])
     67 
     68    source([[
     69      for &ic in [0, 1]
     70        for &g:tc in ["followic", "ignore", "match"]
     71          for &l:tc in ["", "followic", "ignore", "match"]
     72            call append('$', "ic=".&ic." g:tc=".&g:tc." l:tc=".&l:tc." tc=".&tc)
     73            call append('$', len(taglist("^foo$")))
     74            call append('$', len(taglist("^Foo$")))
     75          endfor
     76        endfor
     77      endfor
     78 
     79      1,/^end text$/d]])
     80 
     81    expect([[
     82      ic=0 g:tc=followic l:tc= tc=followic
     83      1
     84      1
     85      ic=0 g:tc=followic l:tc=followic tc=followic
     86      1
     87      1
     88      ic=0 g:tc=followic l:tc=ignore tc=ignore
     89      2
     90      2
     91      ic=0 g:tc=followic l:tc=match tc=match
     92      1
     93      1
     94      ic=0 g:tc=ignore l:tc= tc=ignore
     95      2
     96      2
     97      ic=0 g:tc=ignore l:tc=followic tc=followic
     98      1
     99      1
    100      ic=0 g:tc=ignore l:tc=ignore tc=ignore
    101      2
    102      2
    103      ic=0 g:tc=ignore l:tc=match tc=match
    104      1
    105      1
    106      ic=0 g:tc=match l:tc= tc=match
    107      1
    108      1
    109      ic=0 g:tc=match l:tc=followic tc=followic
    110      1
    111      1
    112      ic=0 g:tc=match l:tc=ignore tc=ignore
    113      2
    114      2
    115      ic=0 g:tc=match l:tc=match tc=match
    116      1
    117      1
    118      ic=1 g:tc=followic l:tc= tc=followic
    119      2
    120      2
    121      ic=1 g:tc=followic l:tc=followic tc=followic
    122      2
    123      2
    124      ic=1 g:tc=followic l:tc=ignore tc=ignore
    125      2
    126      2
    127      ic=1 g:tc=followic l:tc=match tc=match
    128      1
    129      1
    130      ic=1 g:tc=ignore l:tc= tc=ignore
    131      2
    132      2
    133      ic=1 g:tc=ignore l:tc=followic tc=followic
    134      2
    135      2
    136      ic=1 g:tc=ignore l:tc=ignore tc=ignore
    137      2
    138      2
    139      ic=1 g:tc=ignore l:tc=match tc=match
    140      1
    141      1
    142      ic=1 g:tc=match l:tc= tc=match
    143      1
    144      1
    145      ic=1 g:tc=match l:tc=followic tc=followic
    146      2
    147      2
    148      ic=1 g:tc=match l:tc=ignore tc=ignore
    149      2
    150      2
    151      ic=1 g:tc=match l:tc=match tc=match
    152      1
    153      1]])
    154  end)
    155 end)