diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-05-16 22:24:55 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-05-16 22:24:55 +0200 |
commit | 17aca707f92235b6f962e637e8073162d18e6de2 (patch) | |
tree | 35b570117e4f60a922adbdac39fc5fa5dc0857fb /src/testdir | |
parent | dda4144d39a9d685b8dda830978e7410bd372c40 (diff) |
patch 8.1.1336: some eval functionality is not covered by testsv8.1.1336
Problem: Some eval functionality is not covered by tests.
Solution: Add a few more test cases. (Masato Nishihata, closes #4374)
Diffstat (limited to 'src/testdir')
-rw-r--r-- | src/testdir/test_bufline.vim | 6 | ||||
-rw-r--r-- | src/testdir/test_cindent.vim | 10 | ||||
-rw-r--r-- | src/testdir/test_cursor_func.vim | 6 | ||||
-rw-r--r-- | src/testdir/test_delete.vim | 5 | ||||
-rw-r--r-- | src/testdir/test_expand_func.vim | 9 | ||||
-rw-r--r-- | src/testdir/test_float_func.vim | 1 | ||||
-rw-r--r-- | src/testdir/test_fnamemodify.vim | 6 | ||||
-rw-r--r-- | src/testdir/test_functions.vim | 24 |
8 files changed, 60 insertions, 7 deletions
diff --git a/src/testdir/test_bufline.vim b/src/testdir/test_bufline.vim index d2d692922c..9c29a05e70 100644 --- a/src/testdir/test_bufline.vim +++ b/src/testdir/test_bufline.vim @@ -8,7 +8,7 @@ func Test_setbufline_getbufline() hide call assert_equal(0, setbufline(b, 1, ['foo', 'bar'])) call assert_equal(['foo'], getbufline(b, 1)) - call assert_equal(['bar'], getbufline(b, 2)) + call assert_equal(['bar'], getbufline(b, '$')) call assert_equal(['foo', 'bar'], getbufline(b, 1, 2)) exe "bd!" b call assert_equal([], getbufline(b, 1, 2)) @@ -81,6 +81,7 @@ func Test_appendbufline() call setline(1, ['a', 'b', 'c']) let b = bufnr('%') wincmd w + call assert_equal(1, appendbufline(b, -1, ['x'])) call assert_equal(1, appendbufline(b, 4, ['x'])) call assert_equal(1, appendbufline(1234, 1, ['x'])) call assert_equal(0, appendbufline(b, 3, ['d', 'e'])) @@ -130,8 +131,11 @@ func Test_deletebufline() exe "bd!" b call assert_equal(1, deletebufline(b, 1)) + call assert_equal(1, deletebufline(-1, 1)) + split Xtest call setline(1, ['a', 'b', 'c']) + call cursor(line('$'), 1) let b = bufnr('%') wincmd w call assert_equal(1, deletebufline(b, 4)) diff --git a/src/testdir/test_cindent.vim b/src/testdir/test_cindent.vim index 7c2c5e341c..3b57360ace 100644 --- a/src/testdir/test_cindent.vim +++ b/src/testdir/test_cindent.vim @@ -102,4 +102,14 @@ func Test_cindent_expr() bw! endfunc +func Test_cindent_func() + new + setlocal cindent + call setline(1, ['int main(void)', '{', 'return 0;', '}']) + call assert_equal(cindent(0), -1) + call assert_equal(cindent(3), &sw) + call assert_equal(cindent(line('$')+1), -1) + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_cursor_func.vim b/src/testdir/test_cursor_func.vim index a41cc7d005..12319577c6 100644 --- a/src/testdir/test_cursor_func.vim +++ b/src/testdir/test_cursor_func.vim @@ -25,6 +25,12 @@ func Test_move_cursor() call cursor(9, 1) call assert_equal([4, 1, 0, 1], getcurpos()[1:]) + call setline(1, ["\<TAB>"]) + call cursor(1, 1, 1) + call assert_equal([1, 1, 1], getcurpos()[1:3]) + + call assert_equal(-1, cursor(-1, -1)) + quit! endfunc diff --git a/src/testdir/test_delete.vim b/src/testdir/test_delete.vim index 4686a0dc97..b3e153e5b7 100644 --- a/src/testdir/test_delete.vim +++ b/src/testdir/test_delete.vim @@ -105,3 +105,8 @@ func Test_symlink_recursive_delete() bwipe Xdir3/subdir/Xfile bwipe Xdir4/Xfile endfunc + +func Test_delete_errors() + call assert_fails('call delete('''')', 'E474:') + call assert_fails('call delete(''foo'', 0)', 'E15:') +endfunc diff --git a/src/testdir/test_expand_func.vim b/src/testdir/test_expand_func.vim index fb29c3eb7a..f6e5293635 100644 --- a/src/testdir/test_expand_func.vim +++ b/src/testdir/test_expand_func.vim @@ -64,3 +64,12 @@ func Test_expand_sflnum() call assert_equal(64, str2nr(trim(execute('Flnum')))) delcommand Flnum endfunc + +func Test_expand() + new + call assert_equal("", expand('%:S')) + call assert_equal('3', expand('<slnum>')) + call assert_equal(['4'], expand('<slnum>', v:false, v:true)) + " Don't add any line above this, otherwise <slnum> will change. + quit +endfunc diff --git a/src/testdir/test_float_func.vim b/src/testdir/test_float_func.vim index 48fae74012..29bfc9e2d0 100644 --- a/src/testdir/test_float_func.vim +++ b/src/testdir/test_float_func.vim @@ -13,6 +13,7 @@ func Test_abs() call assert_equal('inf', string(abs(1.0/0.0))) call assert_equal('inf', string(abs(-1.0/0.0))) call assert_equal('nan', string(abs(0.0/0.0))) + call assert_equal('12', string(abs('12abc'))) call assert_equal('12', string(abs('-12abc'))) call assert_fails("call abs([])", 'E745:') call assert_fails("call abs({})", 'E728:') diff --git a/src/testdir/test_fnamemodify.vim b/src/testdir/test_fnamemodify.vim index 768d31192a..63f273677d 100644 --- a/src/testdir/test_fnamemodify.vim +++ b/src/testdir/test_fnamemodify.vim @@ -45,9 +45,3 @@ func Test_fnamemodify() let $HOME = save_home let &shell = save_shell endfunc - -func Test_expand() - new - call assert_equal("", expand('%:S')) - quit -endfunc diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim index 7bd3ef488e..b9520c7ee6 100644 --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -52,6 +52,7 @@ func Test_empty() endif call assert_equal(0, empty(function('Test_empty'))) + call assert_equal(0, empty(function('Test_empty', [0]))) endfunc func Test_len() @@ -869,6 +870,7 @@ func Test_count() call assert_equal(1, count(l, 'a', 0, 1)) call assert_equal(2, count(l, 'a', 1, 1)) call assert_fails('call count(l, "a", 0, 10)', 'E684:') + call assert_fails('call count(l, "a", [])', 'E745:') let d = {1: 'a', 2: 'a', 3: 'A', 4: 'b'} call assert_equal(2, count(d, 'a')) @@ -896,6 +898,8 @@ func Test_count() call assert_equal(2, count("foo", "O", 1)) call assert_equal(2, count("fooooo", "oo")) call assert_equal(0, count("foo", "")) + + call assert_fails('call count(0, 0)', 'E712:') endfunc func Test_changenr() @@ -1431,3 +1435,23 @@ func Test_readdir() call delete('Xdir', 'rf') endfunc + +func Test_call() + call assert_equal(3, call('len', [123])) + call assert_fails("call call('len', 123)", 'E714:') + call assert_equal(0, call('', [])) + + function Mylen() dict + return len(self.data) + endfunction + let mydict = {'data': [0, 1, 2, 3], 'len': function("Mylen")} + call assert_fails("call call('Mylen', [], 0)", 'E715:') +endfunc + +func Test_char2nr() + call assert_equal(12354, char2nr('あ', 1)) +endfunc + +func Test_eventhandler() + call assert_equal(0, eventhandler()) +endfunc |