mirror of
https://github.com/neovim/neovim.git
synced 2025-10-02 07:58:35 +00:00
vim-patch:8.1.1336: some eval functionality is not covered by tests
Problem: Some eval functionality is not covered by tests.
Solution: Add a few more test cases. (Masato Nishihata, closes vim/vim#4374)
17aca707f9
Test_expand() changes are required for v8.1.1921.
Test_call() and Test_cindent_func() are already ported.
This commit is contained in:
@@ -9,7 +9,7 @@ func Test_setbufline_getbufline()
|
|||||||
hide
|
hide
|
||||||
call assert_equal(0, setbufline(b, 1, ['foo', 'bar']))
|
call assert_equal(0, setbufline(b, 1, ['foo', 'bar']))
|
||||||
call assert_equal(['foo'], getbufline(b, 1))
|
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))
|
call assert_equal(['foo', 'bar'], getbufline(b, 1, 2))
|
||||||
exe "bd!" b
|
exe "bd!" b
|
||||||
call assert_equal([], getbufline(b, 1, 2))
|
call assert_equal([], getbufline(b, 1, 2))
|
||||||
@@ -82,6 +82,7 @@ func Test_appendbufline()
|
|||||||
call setline(1, ['a', 'b', 'c'])
|
call setline(1, ['a', 'b', 'c'])
|
||||||
let b = bufnr('%')
|
let b = bufnr('%')
|
||||||
wincmd w
|
wincmd w
|
||||||
|
call assert_equal(1, appendbufline(b, -1, ['x']))
|
||||||
call assert_equal(1, appendbufline(b, 4, ['x']))
|
call assert_equal(1, appendbufline(b, 4, ['x']))
|
||||||
call assert_equal(1, appendbufline(1234, 1, ['x']))
|
call assert_equal(1, appendbufline(1234, 1, ['x']))
|
||||||
call assert_equal(0, appendbufline(b, 3, ['d', 'e']))
|
call assert_equal(0, appendbufline(b, 3, ['d', 'e']))
|
||||||
@@ -104,8 +105,11 @@ func Test_deletebufline()
|
|||||||
exe "bd!" b
|
exe "bd!" b
|
||||||
call assert_equal(1, b->deletebufline(1))
|
call assert_equal(1, b->deletebufline(1))
|
||||||
|
|
||||||
|
call assert_equal(1, deletebufline(-1, 1))
|
||||||
|
|
||||||
split Xtest
|
split Xtest
|
||||||
call setline(1, ['a', 'b', 'c'])
|
call setline(1, ['a', 'b', 'c'])
|
||||||
|
call cursor(line('$'), 1)
|
||||||
let b = bufnr('%')
|
let b = bufnr('%')
|
||||||
wincmd w
|
wincmd w
|
||||||
call assert_equal(1, deletebufline(b, 4))
|
call assert_equal(1, deletebufline(b, 4))
|
||||||
|
@@ -25,6 +25,12 @@ func Test_move_cursor()
|
|||||||
call cursor(9, 1)
|
call cursor(9, 1)
|
||||||
call assert_equal([4, 1, 0, 1], getcurpos()[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!
|
quit!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
@@ -37,6 +37,15 @@ func Test_expand_sflnum()
|
|||||||
delcommand Flnum
|
delcommand Flnum
|
||||||
endfunc
|
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
|
||||||
|
|
||||||
func Test_expand_sfile()
|
func Test_expand_sfile()
|
||||||
call assert_match('test_expand_func\.vim$', s:sfile)
|
call assert_match('test_expand_func\.vim$', s:sfile)
|
||||||
call assert_match('^function .*\.\.Test_expand_sfile$', expand('<sfile>'))
|
call assert_match('^function .*\.\.Test_expand_sfile$', expand('<sfile>'))
|
||||||
|
@@ -15,6 +15,7 @@ func Test_abs()
|
|||||||
call assert_equal("str2float('inf')", string(abs(1.0/0.0)))
|
call assert_equal("str2float('inf')", string(abs(1.0/0.0)))
|
||||||
call assert_equal("str2float('inf')", string(abs(-1.0/0.0)))
|
call assert_equal("str2float('inf')", string(abs(-1.0/0.0)))
|
||||||
call assert_equal("str2float('nan')", string(abs(0.0/0.0)))
|
call assert_equal("str2float('nan')", string(abs(0.0/0.0)))
|
||||||
|
call assert_equal('12', string(abs('12abc')))
|
||||||
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([])", 'E745:')
|
||||||
call assert_fails("call abs({})", 'E728:')
|
call assert_fails("call abs({})", 'E728:')
|
||||||
|
@@ -56,6 +56,7 @@ func Test_empty()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
call assert_equal(0, empty(function('Test_empty')))
|
call assert_equal(0, empty(function('Test_empty')))
|
||||||
|
call assert_equal(0, empty(function('Test_empty', [0])))
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_len()
|
func Test_len()
|
||||||
@@ -999,6 +1000,7 @@ func Test_count()
|
|||||||
call assert_equal(1, count(l, 'a', 0, 1))
|
call assert_equal(1, count(l, 'a', 0, 1))
|
||||||
call assert_equal(2, count(l, 'a', 1, 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", 0, 10)', 'E684:')
|
||||||
|
call assert_fails('call count(l, "a", [])', 'E745:')
|
||||||
|
|
||||||
let d = {1: 'a', 2: 'a', 3: 'A', 4: 'b'}
|
let d = {1: 'a', 2: 'a', 3: 'A', 4: 'b'}
|
||||||
call assert_equal(2, count(d, 'a'))
|
call assert_equal(2, count(d, 'a'))
|
||||||
@@ -1026,6 +1028,8 @@ func Test_count()
|
|||||||
call assert_equal(2, count("foo", "O", 1))
|
call assert_equal(2, count("foo", "O", 1))
|
||||||
call assert_equal(2, count("fooooo", "oo"))
|
call assert_equal(2, count("fooooo", "oo"))
|
||||||
call assert_equal(0, count("foo", ""))
|
call assert_equal(0, count("foo", ""))
|
||||||
|
|
||||||
|
call assert_fails('call count(0, 0)', 'E712:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_changenr()
|
func Test_changenr()
|
||||||
@@ -1589,6 +1593,14 @@ func Test_call()
|
|||||||
call assert_fails("call call('Mylen', [], 0)", 'E715:')
|
call assert_fails("call call('Mylen', [], 0)", 'E715:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_char2nr()
|
||||||
|
call assert_equal(12354, char2nr('あ', 1))
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_eventhandler()
|
||||||
|
call assert_equal(0, eventhandler())
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Test for the eval() function
|
" Test for the eval() function
|
||||||
func Test_eval()
|
func Test_eval()
|
||||||
call assert_fails("call eval('5 a')", 'E488:')
|
call assert_fails("call eval('5 a')", 'E488:')
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local clear, source = helpers.clear, helpers.source
|
local clear, source = helpers.clear, helpers.source
|
||||||
local eq, eval, command = helpers.eq, helpers.eval, helpers.command
|
local eq, eval, command = helpers.eq, helpers.eval, helpers.command
|
||||||
|
local exc_exec = helpers.exc_exec
|
||||||
|
|
||||||
describe('Test for delete()', function()
|
describe('Test for delete()', function()
|
||||||
before_each(clear)
|
before_each(clear)
|
||||||
@@ -114,4 +115,10 @@ describe('Test for delete()', function()
|
|||||||
eq(0, eval("delete('Xdir4/Xfile')"))
|
eq(0, eval("delete('Xdir4/Xfile')"))
|
||||||
eq(0, eval("delete('Xdir4', 'd')"))
|
eq(0, eval("delete('Xdir4', 'd')"))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('gives correct emsgs', function()
|
||||||
|
eq('Vim(call):E474: Invalid argument', exc_exec("call delete('')"))
|
||||||
|
eq('Vim(call):E15: Invalid expression: 0',
|
||||||
|
exc_exec("call delete('foo', 0)"))
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -60,12 +60,6 @@ describe('filename modifiers', function()
|
|||||||
call assert_equal("'abc\\\ndef'", fnamemodify("abc\ndef", ':S'))
|
call assert_equal("'abc\\\ndef'", fnamemodify("abc\ndef", ':S'))
|
||||||
endif
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_expand()
|
|
||||||
new
|
|
||||||
call assert_equal("", expand('%:S'))
|
|
||||||
quit
|
|
||||||
endfunc
|
|
||||||
]=])
|
]=])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -73,9 +67,4 @@ describe('filename modifiers', function()
|
|||||||
call('Test_fnamemodify')
|
call('Test_fnamemodify')
|
||||||
expected_empty()
|
expected_empty()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('works for :S in an unnamed buffer', function()
|
|
||||||
call('Test_expand')
|
|
||||||
expected_empty()
|
|
||||||
end)
|
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user