count_spec.lua 1006 B

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