0
0
mirror of https://github.com/vim/vim.git synced 2025-10-01 04:54:07 -04:00

patch 8.2.0450: not enough testing for restricted mode and function calls

Problem:    Not enough testing for restricted mode and function calls.
Solution:   Add more tests. (Yegappan Lakshmanan, closes #5847)
This commit is contained in:
Bram Moolenaar
2020-03-26 14:11:58 +01:00
parent cf3f8bf4dd
commit 7d941ee032
4 changed files with 171 additions and 89 deletions

View File

@@ -1004,4 +1004,62 @@ def Test_redef_failure()
delfunc! Func2
enddef
" Test for internal functions returning different types
func Test_InternalFuncRetType()
let lines =<< trim END
def RetFloat(): float
return ceil(1.456)
enddef
def RetListAny(): list<any>
return items({'k' : 'v'})
enddef
def RetListString(): list<string>
return split('a:b:c', ':')
enddef
def RetListDictAny(): list<dict<any>>
return getbufinfo()
enddef
def RetDictNumber(): dict<number>
return wordcount()
enddef
def RetDictString(): dict<string>
return environ()
enddef
END
call writefile(lines, 'Xscript')
source Xscript
call assert_equal(2.0, RetFloat())
call assert_equal([['k', 'v']], RetListAny())
call assert_equal(['a', 'b', 'c'], RetListString())
call assert_notequal([], RetListDictAny())
call assert_notequal({}, RetDictNumber())
call assert_notequal({}, RetDictString())
call delete('Xscript')
endfunc
" Test for passing too many or too few arguments to internal functions
func Test_internalfunc_arg_error()
let l =<< trim END
def! FArgErr(): float
return ceil(1.1, 2)
enddef
END
call writefile(l, 'Xinvalidarg')
call assert_fails('so Xinvalidarg', 'E118:')
let l =<< trim END
def! FArgErr(): float
return ceil()
enddef
END
call writefile(l, 'Xinvalidarg')
call assert_fails('so Xinvalidarg', 'E119:')
call delete('Xinvalidarg')
endfunc
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker