comparison src/testdir/test_vim9_script.vim @ 19787:906269bf83d5 v8.2.0450

patch 8.2.0450: not enough testing for restricted mode and function calls Commit: https://github.com/vim/vim/commit/7d941ee032c02a4b682201881eb5c1f1958f17ee Author: Bram Moolenaar <Bram@vim.org> Date: Thu Mar 26 14:11:58 2020 +0100 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 https://github.com/vim/vim/issues/5847)
author Bram Moolenaar <Bram@vim.org>
date Thu, 26 Mar 2020 14:15:04 +0100
parents 99248f0ff29d
children c1c88b333481
comparison
equal deleted inserted replaced
19786:ae9edaa6f0f5 19787:906269bf83d5
1002 delfunc! Func0 1002 delfunc! Func0
1003 delfunc! Func1 1003 delfunc! Func1
1004 delfunc! Func2 1004 delfunc! Func2
1005 enddef 1005 enddef
1006 1006
1007 " Test for internal functions returning different types
1008 func Test_InternalFuncRetType()
1009 let lines =<< trim END
1010 def RetFloat(): float
1011 return ceil(1.456)
1012 enddef
1013
1014 def RetListAny(): list<any>
1015 return items({'k' : 'v'})
1016 enddef
1017
1018 def RetListString(): list<string>
1019 return split('a:b:c', ':')
1020 enddef
1021
1022 def RetListDictAny(): list<dict<any>>
1023 return getbufinfo()
1024 enddef
1025
1026 def RetDictNumber(): dict<number>
1027 return wordcount()
1028 enddef
1029
1030 def RetDictString(): dict<string>
1031 return environ()
1032 enddef
1033 END
1034 call writefile(lines, 'Xscript')
1035 source Xscript
1036
1037 call assert_equal(2.0, RetFloat())
1038 call assert_equal([['k', 'v']], RetListAny())
1039 call assert_equal(['a', 'b', 'c'], RetListString())
1040 call assert_notequal([], RetListDictAny())
1041 call assert_notequal({}, RetDictNumber())
1042 call assert_notequal({}, RetDictString())
1043 call delete('Xscript')
1044 endfunc
1045
1046 " Test for passing too many or too few arguments to internal functions
1047 func Test_internalfunc_arg_error()
1048 let l =<< trim END
1049 def! FArgErr(): float
1050 return ceil(1.1, 2)
1051 enddef
1052 END
1053 call writefile(l, 'Xinvalidarg')
1054 call assert_fails('so Xinvalidarg', 'E118:')
1055 let l =<< trim END
1056 def! FArgErr(): float
1057 return ceil()
1058 enddef
1059 END
1060 call writefile(l, 'Xinvalidarg')
1061 call assert_fails('so Xinvalidarg', 'E119:')
1062 call delete('Xinvalidarg')
1063 endfunc
1064
1007 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker 1065 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker