neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

test_source_utf8.vim (1551B)


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