075_maparg_spec.lua 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. -- Tests for maparg().
  2. -- Also test utf8 map with a 0x80 byte.
  3. local helpers = require('test.functional.helpers')(after_each)
  4. local clear, feed = helpers.clear, helpers.feed
  5. local command, expect = helpers.command, helpers.expect
  6. local poke_eventloop = helpers.poke_eventloop
  7. describe('maparg()', function()
  8. setup(clear)
  9. it('is working', function()
  10. command('set cpo-=<')
  11. -- Test maparg() with a string result
  12. command('map foo<C-V> is<F4>foo')
  13. command('vnoremap <script> <buffer> <expr> <silent> bar isbar')
  14. command([[call append('$', maparg('foo<C-V>'))]])
  15. command([[call append('$', string(maparg('foo<C-V>', '', 0, 1)))]])
  16. command([[call append('$', string(maparg('bar', '', 0, 1)))]])
  17. command('map <buffer> <nowait> foo bar')
  18. command([[call append('$', string(maparg('foo', '', 0, 1)))]])
  19. command('map abc x<char-114>x')
  20. command([[call append('$', maparg('abc'))]])
  21. command('map abc y<S-char-114>y')
  22. command([[call append('$', maparg('abc'))]])
  23. feed('Go<esc>:<cr>')
  24. poke_eventloop()
  25. -- Outside of the range, minimum
  26. command('inoremap <Char-0x1040> a')
  27. command([[execute "normal a\u1040\<Esc>"]])
  28. -- Inside of the range, minimum
  29. command('inoremap <Char-0x103f> b')
  30. command([[execute "normal a\u103f\<Esc>"]])
  31. -- Inside of the range, maximum
  32. command('inoremap <Char-0xf03f> c')
  33. command([[execute "normal a\uf03f\<Esc>"]])
  34. -- Outside of the range, maximum
  35. command('inoremap <Char-0xf040> d')
  36. command([[execute "normal a\uf040\<Esc>"]])
  37. -- Remove empty line
  38. command('1d')
  39. -- Assert buffer contents.
  40. expect([[
  41. is<F4>foo
  42. {'lnum': 0, 'script': 0, 'silent': 0, 'noremap': 0, 'lhs': 'foo<C-V>', 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': 0, 'rhs': 'is<F4>foo', 'buffer': 0}
  43. {'lnum': 0, 'script': 1, 'silent': 1, 'noremap': 1, 'lhs': 'bar', 'mode': 'v', 'nowait': 0, 'expr': 1, 'sid': 0, 'rhs': 'isbar', 'buffer': 1}
  44. {'lnum': 0, 'script': 0, 'silent': 0, 'noremap': 0, 'lhs': 'foo', 'mode': ' ', 'nowait': 1, 'expr': 0, 'sid': 0, 'rhs': 'bar', 'buffer': 1}
  45. xrx
  46. yRy
  47. abcd]])
  48. end)
  49. end)