035_increment_and_decrement_spec.lua 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. -- Test Ctrl-A and Ctrl-X, which increment and decrement decimal, hexadecimal,
  2. -- and octal numbers.
  3. local helpers = require('test.functional.helpers')(after_each)
  4. local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
  5. local feed_command, expect = helpers.feed_command, helpers.expect
  6. describe('increment and decrement commands', function()
  7. setup(clear)
  8. it('should work', function()
  9. -- Insert some numbers in various bases.
  10. insert([[
  11. 0b101 100 0x100 077 0
  12. 0b101 100 0x100 077
  13. 100 0x100 077 0xfF 0xFf
  14. 100 0x100 077
  15. 0x0b101 0b1101]])
  16. -- Increment and decrement numbers in the first row, interpreting the
  17. -- numbers as decimal, octal or hexadecimal.
  18. feed_command('set nrformats=bin,octal,hex', '1')
  19. feed('63l102ll64128$')
  20. -- For the second row, treat the numbers as decimal or octal.
  21. -- 0x100 should be interpreted as decimal 0, the character x, and decimal 100.
  22. feed_command('set nrformats=octal', '2')
  23. feed('0w102l2w65129blx6lD')
  24. -- For the third row, treat the numbers as decimal or hexadecimal.
  25. -- 077 should be interpreted as decimal 77.
  26. feed_command('set nrformats=hex', '3')
  27. feed('0101l257Txldt   ')
  28. -- For the fourth row, interpret all numbers as decimal.
  29. feed_command('set nrformats=', '4')
  30. feed('0200l100w78')
  31. -- For the last row, interpret as binary and hexadecimal.
  32. feed_command('set nrformats=bin,hex', '5')
  33. feed('010065l6432')
  34. expect([[
  35. 0b011 0 0x0ff 0000 -1
  36. 1b101 0 1x100 0777777
  37. -1 0x0 078 0xFE 0xfe
  38. -100 -100x100 000
  39. 0x0b0de 0b0101101]])
  40. end)
  41. end)