1" Test the :source! command
2source check.vim
3
4func 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')
17endfunc
18
19func 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')
31endfunc
32
33" Test for sourcing a file with CTRL-V's at the end of the line
34func 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')
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  call delete('Xtestfile')
56  unmap __1
57  unmap __2
58  unmap __3
59  unmap __4
60  unmap __5
61endfunc
62