count_spec.lua 1016 B

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