blob: e93ea29dff7cf22bc8c183cdb5020f18246729eb [file] [log] [blame]
Bram Moolenaard3c907b2016-08-17 21:32:09 +02001" Test the :source! command
Bram Moolenaard3c907b2016-08-17 21:32:09 +02002
3func 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')
16endfunc
17
18func Test_source_latin()
19 " check that sourcing a latin1 script with a 0xc0 byte works
20 new
21 call setline(1, ["call feedkeys('r')", "call feedkeys('\xc0', 'xt')"])
22 write! Xscript
23 bwipe!
24 new
25 call setline(1, ['xxx'])
26 source Xscript
27 call assert_equal("\u00c0xx", getline(1))
28 bwipe!
29 call delete('Xscript')
30endfunc
Bram Moolenaar15993ce2017-10-26 20:21:44 +020031
32" Test for sourcing a file with CTRL-V's at the end of the line
33func Test_source_ctrl_v()
34 call writefile(['map __1 afirst',
35 \ 'map __2 asecond',
36 \ 'map __3 athird',
37 \ 'map __4 afourth',
38 \ 'map __5 afifth',
39 \ "map __1 asd\<C-V>",
40 \ "map __2 asd\<C-V>\<C-V>",
41 \ "map __3 asd\<C-V>\<C-V>",
42 \ "map __4 asd\<C-V>\<C-V>\<C-V>",
43 \ "map __5 asd\<C-V>\<C-V>\<C-V>",
44 \ ], 'Xtestfile')
45 source Xtestfile
46 enew!
47 exe "normal __1\<Esc>\<Esc>__2\<Esc>__3\<Esc>\<Esc>__4\<Esc>__5\<Esc>"
48 exe "%s/\<C-J>/0/g"
49 call assert_equal(['sd',
50 \ "map __2 asd\<Esc>secondsd\<Esc>sd0map __5 asd0fifth"],
51 \ getline(1, 2))
52
53 enew!
54 call delete('Xtestfile')
55 unmap __1
56 unmap __2
57 unmap __3
58 unmap __4
59 unmap __5
60endfunc