blob: d22ce8f66d7b7ca1c2e079baca9820b8e1556433 [file] [log] [blame]
Bram Moolenaard3c907b2016-08-17 21:32:09 +02001" Test the :source! command
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +02002
Bram Moolenaar9134f1e2019-11-29 20:26:13 +01003source check.vim
Bram Moolenaard3c907b2016-08-17 21:32:09 +02004
5func Test_source_utf8()
6 " check that sourcing a script with 0x80 as second byte works
7 new
8 call setline(1, [':%s/àx/--à1234--/g', ':%s/Àx/--À1234--/g'])
9 write! Xscript
10 bwipe!
11 new
12 call setline(1, [' àx ', ' Àx '])
13 source! Xscript | echo
14 call assert_equal(' --à1234-- ', getline(1))
15 call assert_equal(' --À1234-- ', getline(2))
16 bwipe!
17 call delete('Xscript')
18endfunc
19
20func Test_source_latin()
21 " check that sourcing a latin1 script with a 0xc0 byte works
22 new
23 call setline(1, ["call feedkeys('r')", "call feedkeys('\xc0', 'xt')"])
24 write! Xscript
25 bwipe!
26 new
27 call setline(1, ['xxx'])
28 source Xscript
29 call assert_equal("\u00c0xx", getline(1))
30 bwipe!
31 call delete('Xscript')
32endfunc
Bram Moolenaar15993ce2017-10-26 20:21:44 +020033
34" Test for sourcing a file with CTRL-V's at the end of the line
35func Test_source_ctrl_v()
Bram Moolenaar36ddf932020-03-03 23:06:48 +010036 call writefile(['map __1 afirst',
37 \ 'map __2 asecond',
38 \ 'map __3 athird',
39 \ 'map __4 afourth',
40 \ 'map __5 afifth',
41 \ "map __1 asd\<C-V>",
42 \ "map __2 asd\<C-V>\<C-V>",
43 \ "map __3 asd\<C-V>\<C-V>",
44 \ "map __4 asd\<C-V>\<C-V>\<C-V>",
45 \ "map __5 asd\<C-V>\<C-V>\<C-V>",
46 \ ], 'Xtestfile')
Bram Moolenaar15993ce2017-10-26 20:21:44 +020047 source Xtestfile
48 enew!
49 exe "normal __1\<Esc>\<Esc>__2\<Esc>__3\<Esc>\<Esc>__4\<Esc>__5\<Esc>"
50 exe "%s/\<C-J>/0/g"
51 call assert_equal(['sd',
Bram Moolenaar36ddf932020-03-03 23:06:48 +010052 \ "map __2 asd\<Esc>secondsd\<Esc>sd0map __5 asd0fifth"],
53 \ getline(1, 2))
Bram Moolenaar15993ce2017-10-26 20:21:44 +020054
55 enew!
56 call delete('Xtestfile')
57 unmap __1
58 unmap __2
59 unmap __3
60 unmap __4
61 unmap __5
62endfunc
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +020063
64" vim: shiftwidth=2 sts=2 expandtab