lang_spec.lua 1.6 KB

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