Skip to content

Commit 1b04ce2

Browse files
committed
patch 8.2.1505: not all file read and writecode is tested
Problem: Not all file read and writecode is tested. Solution: Add a few tests. (Dominique Pellé, closes #6764)
1 parent 7cb6fc2 commit 1b04ce2

4 files changed

Lines changed: 40 additions & 6 deletions

File tree

src/testdir/test_eval_stuff.vim

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,31 @@ func Test_readfile_binary()
7474
new
7575
call setline(1, ['one', 'two', 'three'])
7676
setlocal ff=dos
77-
silent write XReadfile
78-
let lines = 'XReadfile'->readfile()
77+
silent write XReadfile_bin
78+
let lines = 'XReadfile_bin'->readfile()
7979
call assert_equal(['one', 'two', 'three'], lines)
80-
let lines = readfile('XReadfile', '', 2)
80+
let lines = readfile('XReadfile_bin', '', 2)
8181
call assert_equal(['one', 'two'], lines)
82-
let lines = readfile('XReadfile', 'b')
82+
let lines = readfile('XReadfile_bin', 'b')
8383
call assert_equal(["one\r", "two\r", "three\r", ""], lines)
84-
let lines = readfile('XReadfile', 'b', 2)
84+
let lines = readfile('XReadfile_bin', 'b', 2)
8585
call assert_equal(["one\r", "two\r"], lines)
8686

8787
bwipe!
88-
call delete('XReadfile')
88+
call delete('XReadfile_bin')
89+
endfunc
90+
91+
func Test_readfile_bom()
92+
call writefile(["\ufeffFOO", "FOO\ufeffBAR"], 'XReadfile_bom')
93+
call assert_equal(['FOO', 'FOOBAR'], readfile('XReadfile_bom'))
94+
call delete('XReadfile_bom')
95+
endfunc
96+
97+
func Test_readfile_max()
98+
call writefile(range(1, 4), 'XReadfile_max')
99+
call assert_equal(['1', '2'], readfile('XReadfile_max', '', 2))
100+
call assert_equal(['3', '4'], readfile('XReadfile_max', '', -2))
101+
call delete('XReadfile_max')
89102
endfunc
90103

91104
func Test_let_errmsg()

src/testdir/test_fnamemodify.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ func Test_fnamemodify()
1111
call assert_equal('/', fnamemodify('.', ':p')[-1:])
1212
call assert_equal('r', fnamemodify('.', ':p:h')[-1:])
1313
call assert_equal('t', fnamemodify('test.out', ':p')[-1:])
14+
call assert_equal($HOME .. "/foo" , fnamemodify('~/foo', ':p'))
1415
call assert_equal('test.out', fnamemodify('test.out', ':.'))
1516
call assert_equal('a', fnamemodify('../testdir/a', ':.'))
1617
call assert_equal('~/testdir/test.out', fnamemodify('test.out', ':~'))
@@ -93,4 +94,9 @@ func Test_fnamemodify_er()
9394
call assert_equal('', fnamemodify(test_null_string(), test_null_string()))
9495
endfunc
9596

97+
func Test_fnamemodify_fail()
98+
call assert_fails('call fnamemodify({}, ":p")', 'E731:')
99+
call assert_fails('call fnamemodify("x", {})', 'E731:')
100+
endfunc
101+
96102
" vim: shiftwidth=2 sts=2 expandtab

src/testdir/test_functions.vim

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2516,6 +2516,19 @@ endfunc
25162516
func Test_glob()
25172517
call assert_equal('', glob(test_null_string()))
25182518
call assert_equal('', globpath(test_null_string(), test_null_string()))
2519+
2520+
call writefile([], 'Xglob1')
2521+
call writefile([], 'XGLOB2')
2522+
set wildignorecase
2523+
" Sort output of glob() otherwise we end up with different
2524+
" ordering depending on whether file system is case-sensitive.
2525+
call assert_equal(['XGLOB2', 'Xglob1'], sort(glob('Xglob[12]', 0, 1)))
2526+
set wildignorecase&
2527+
2528+
call delete('Xglob1')
2529+
call delete('XGLOB2')
2530+
2531+
call assert_fails("call glob('*', 0, {})", 'E728:')
25192532
endfunc
25202533

25212534
" Test for browse()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ static char *(features[]) =
754754

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
1505,
757759
/**/
758760
1504,
759761
/**/

0 commit comments

Comments
 (0)