fillchars_spec.lua 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. local helpers = require('test.functional.helpers')(after_each)
  2. local Screen = require('test.functional.ui.screen')
  3. local clear, command = helpers.clear, helpers.command
  4. local eval = helpers.eval
  5. local eq = helpers.eq
  6. local exc_exec = helpers.exc_exec
  7. describe("'fillchars'", function()
  8. local screen
  9. before_each(function()
  10. clear()
  11. screen = Screen.new(25, 5)
  12. screen:attach()
  13. end)
  14. after_each(function()
  15. screen:detach()
  16. end)
  17. local function shouldfail(val,errval)
  18. errval = errval or val
  19. eq('Vim(set):E474: Invalid argument: fillchars='..errval,
  20. exc_exec('set fillchars='..val))
  21. end
  22. describe('"eob" flag', function()
  23. it("uses '~' by default", function()
  24. eq('', eval('&fillchars'))
  25. screen:expect([[
  26. ^ |
  27. ~ |
  28. ~ |
  29. ~ |
  30. |
  31. ]])
  32. end)
  33. it('supports whitespace', function()
  34. screen:expect([[
  35. ^ |
  36. ~ |
  37. ~ |
  38. ~ |
  39. |
  40. ]])
  41. command('set fillchars=eob:\\ ')
  42. screen:expect([[
  43. ^ |
  44. |
  45. |
  46. |
  47. |
  48. ]])
  49. end)
  50. it('supports multibyte char', function()
  51. command('set fillchars=eob:ñ')
  52. screen:expect([[
  53. ^ |
  54. ñ |
  55. ñ |
  56. ñ |
  57. |
  58. ]])
  59. end)
  60. it('handles invalid values', function()
  61. shouldfail('eob:') -- empty string
  62. shouldfail('eob:馬') -- doublewidth char
  63. shouldfail('eob:å̲') -- composing chars
  64. shouldfail('eob:xy') -- two ascii chars
  65. shouldfail('eob:\255', 'eob:<ff>') -- invalid UTF-8
  66. end)
  67. end)
  68. end)