count_spec.lua (1006B)
1 local t = require('test.testutil') 2 local n = require('test.functional.testnvim')() 3 4 local eq = t.eq 5 local eval = n.eval 6 local feed = n.feed 7 local clear = n.clear 8 local command = n.command 9 10 describe('v:count/v:count1', function() 11 before_each(function() 12 clear() 13 14 command('map <silent> _x :<C-u>let g:count = "v:count=". v:count .", v:count1=". v:count1<CR>') 15 end) 16 17 describe('in cmdwin', function() 18 it('equal 0/1 when no count is given', function() 19 feed('q:_x') 20 eq('v:count=0, v:count1=1', eval('g:count')) 21 end) 22 23 it('equal 2/2 when count of 2 is given', function() 24 feed('q:2_x') 25 eq('v:count=2, v:count1=2', eval('g:count')) 26 end) 27 end) 28 29 describe('in normal mode', function() 30 it('equal 0/1 when no count is given', function() 31 feed('_x') 32 eq('v:count=0, v:count1=1', eval('g:count')) 33 end) 34 35 it('equal 2/2 when count of 2 is given', function() 36 feed('2_x') 37 eq('v:count=2, v:count1=2', eval('g:count')) 38 end) 39 end) 40 end)