excmd_spec.lua 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. local t = require('test.testutil')
  2. local n = require('test.functional.testnvim')()
  3. local command = n.command
  4. local eq = t.eq
  5. local clear = n.clear
  6. local fn = n.fn
  7. local pcall_err = t.pcall_err
  8. local assert_alive = n.assert_alive
  9. describe('Ex cmds', function()
  10. before_each(function()
  11. clear()
  12. end)
  13. local function check_excmd_err(cmd, err)
  14. eq(err .. ': ' .. cmd, pcall_err(command, cmd))
  15. end
  16. it('handle integer overflow from user-input #5555', function()
  17. command(':9999999999999999999999999999999999999999')
  18. command(':later 9999999999999999999999999999999999999999')
  19. command(':echo expand("#<9999999999999999999999999999999999999999")')
  20. command(':lockvar 9999999999999999999999999999999999999999')
  21. command(
  22. ':winsize 9999999999999999999999999999999999999999 9999999999999999999999999999999999999999'
  23. )
  24. check_excmd_err(
  25. ':tabnext 9999999999999999999999999999999999999999',
  26. 'Vim(tabnext):E475: Invalid argument: 9999999999999999999999999999999999999999'
  27. )
  28. eq(
  29. 'Vim(Next):E163: There is only one file to edit',
  30. pcall_err(command, ':N 9999999999999999999999999999999999999999')
  31. )
  32. check_excmd_err(
  33. ':bdelete 9999999999999999999999999999999999999999',
  34. 'Vim(bdelete):E516: No buffers were deleted'
  35. )
  36. eq(
  37. 'Vim(menu):E329: No menu "9999999999999999999999999999999999999999"',
  38. pcall_err(command, ':menu 9999999999999999999999999999999999999999')
  39. )
  40. assert_alive()
  41. end)
  42. it('listing long user command does not crash', function()
  43. command('execute "command" repeat("T", 255) ":"')
  44. command('command')
  45. end)
  46. it(':def is an unknown command #23149', function()
  47. eq('Vim:E492: Not an editor command: def', pcall_err(command, 'def'))
  48. eq(1, fn.exists(':d'))
  49. eq('delete', fn.fullcommand('d'))
  50. eq(1, fn.exists(':de'))
  51. eq('delete', fn.fullcommand('de'))
  52. eq(0, fn.exists(':def'))
  53. eq('', fn.fullcommand('def'))
  54. eq(1, fn.exists(':defe'))
  55. eq('defer', fn.fullcommand('defe'))
  56. eq(2, fn.exists(':defer'))
  57. eq('defer', fn.fullcommand('defer'))
  58. end)
  59. end)