lang_spec.lua 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. local t = require('test.testutil')
  2. local n = require('test.functional.testnvim')()
  3. local clear, insert, eq = n.clear, n.insert, t.eq
  4. local command, expect = n.command, n.expect
  5. local feed, eval = n.feed, n.eval
  6. local exc_exec = n.exc_exec
  7. describe('gu and gU', function()
  8. before_each(clear)
  9. it('works in any locale with default casemap', function()
  10. eq('internal,keepascii', eval('&casemap'))
  11. insert('iI')
  12. feed('VgU')
  13. expect('II')
  14. feed('Vgu')
  15. expect('ii')
  16. end)
  17. describe('works in Turkish locale', function()
  18. clear()
  19. local err = exc_exec('lang ctype tr_TR.UTF-8')
  20. if err ~= 0 then
  21. pending('Locale tr_TR.UTF-8 not supported', function() end)
  22. return
  23. end
  24. before_each(function()
  25. command('lang ctype tr_TR.UTF-8')
  26. end)
  27. it('with default casemap', function()
  28. eq('internal,keepascii', eval('&casemap'))
  29. -- expect ASCII behavior
  30. insert('iI')
  31. feed('VgU')
  32. expect('II')
  33. feed('Vgu')
  34. expect('ii')
  35. end)
  36. it('with casemap=""', function()
  37. command('set casemap=')
  38. -- expect either Turkish locale behavior or ASCII behavior
  39. local iupper = eval("toupper('i')")
  40. if iupper == 'İ' then
  41. insert('iI')
  42. feed('VgU')
  43. expect('İI')
  44. feed('Vgu')
  45. expect('iı')
  46. elseif iupper == 'I' then
  47. insert('iI')
  48. feed('VgU')
  49. expect('II')
  50. feed('Vgu')
  51. expect('ii')
  52. else
  53. error("expected toupper('i') to be either 'I' or 'İ'")
  54. end
  55. end)
  56. end)
  57. end)