blob: 66fabe04420f59c222c55ce1526226f2166ac0e1 [file] [log] [blame]
Bram Moolenaard3c907b2016-08-17 21:32:09 +02001" Test the :source! command
Bram Moolenaar9134f1e2019-11-29 20:26:13 +01002source check.vim
Bram Moolenaard3c907b2016-08-17 21:32:09 +02003
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
Bram Moolenaar15993ce2017-10-26 20:21:44 +020032
33" Test for sourcing a file with CTRL-V's at the end of the line
34func Test_source_ctrl_v()
Bram Moolenaar36ddf932020-03-03 23:06:48 +010035 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')
Bram Moolenaar15993ce2017-10-26 20:21:44 +020046 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',
Bram Moolenaar36ddf932020-03-03 23:06:48 +010051 \ "map __2 asd\<Esc>secondsd\<Esc>sd0map __5 asd0fifth"],
52 \ getline(1, 2))
Bram Moolenaar15993ce2017-10-26 20:21:44 +020053
54 enew!
55 call delete('Xtestfile')
56 unmap __1
57 unmap __2
58 unmap __3
59 unmap __4
60 unmap __5
61endfunc