test_source_utf8.vim 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. " Test the :source! command
  2. source check.vim
  3. func Test_source_utf8()
  4. " check that sourcing a script with 0x80 as second byte works
  5. new
  6. call setline(1, [':%s/àx/--à1234--/g', ':%s/Àx/--À1234--/g'])
  7. write! Xscript
  8. bwipe!
  9. new
  10. call setline(1, [' àx ', ' Àx '])
  11. source! Xscript | echo
  12. call assert_equal(' --à1234-- ', getline(1))
  13. call assert_equal(' --À1234-- ', getline(2))
  14. bwipe!
  15. call delete('Xscript')
  16. endfunc
  17. func Test_source_latin()
  18. " check that sourcing a latin1 script with a 0xc0 byte works
  19. new
  20. call setline(1, ["call feedkeys('r')", "call feedkeys('\xc0', 'xt')"])
  21. write! Xscript
  22. bwipe!
  23. new
  24. call setline(1, ['xxx'])
  25. source Xscript
  26. call assert_equal("\u00c0xx", getline(1))
  27. bwipe!
  28. call delete('Xscript')
  29. endfunc
  30. " Test for sourcing a file with CTRL-V's at the end of the line
  31. func Test_source_ctrl_v()
  32. call writefile(['map __1 afirst',
  33. \ 'map __2 asecond',
  34. \ 'map __3 athird',
  35. \ 'map __4 afourth',
  36. \ 'map __5 afifth',
  37. \ "map __1 asd\<C-V>",
  38. \ "map __2 asd\<C-V>\<C-V>",
  39. \ "map __3 asd\<C-V>\<C-V>",
  40. \ "map __4 asd\<C-V>\<C-V>\<C-V>",
  41. \ "map __5 asd\<C-V>\<C-V>\<C-V>",
  42. \ ], 'Xtestfile', 'D')
  43. source Xtestfile
  44. enew!
  45. exe "normal __1\<Esc>\<Esc>__2\<Esc>__3\<Esc>\<Esc>__4\<Esc>__5\<Esc>"
  46. exe "%s/\<C-J>/0/g"
  47. call assert_equal(['sd',
  48. \ "map __2 asd\<Esc>secondsd\<Esc>sd0map __5 asd0fifth"],
  49. \ getline(1, 2))
  50. enew!
  51. unmap __1
  52. unmap __2
  53. unmap __3
  54. unmap __4
  55. unmap __5
  56. endfunc