diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-12-09 12:41:50 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-12-09 12:41:50 +0100 |
commit | 7bb4e74c38642682cfdd0cb4052adfa5efdd7dd1 (patch) | |
tree | 87b6644c08d544bae227365d78c1a7c11c611a6d /src/testdir/test_vim9_builtin.vim | |
parent | 2c78a772fdb5f6a16d16a47e7f218051c4dcb845 (diff) |
patch 8.2.2117: some functions use any value as a stringv8.2.2117
Problem: Some functions use any value as a string.
Solution: Check that the value is a non-empty string.
Diffstat (limited to 'src/testdir/test_vim9_builtin.vim')
-rw-r--r-- | src/testdir/test_vim9_builtin.vim | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index 50b711f8db..927a01fe4f 100644 --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -185,6 +185,18 @@ def Test_count() count('ABC ABC ABC', 'b', false)->assert_equal(0) enddef +def Test_executable() + CheckDefExecFailure(['echo executable(true)'], 'E928:') + CheckDefExecFailure(['echo executable(v:null)'], 'E928:') + CheckDefExecFailure(['echo executable("")'], 'E928:') +enddef + +def Test_exepath() + CheckDefExecFailure(['echo exepath(true)'], 'E928:') + CheckDefExecFailure(['echo exepath(v:null)'], 'E928:') + CheckDefExecFailure(['echo exepath("")'], 'E928:') +enddef + def Test_expand() split SomeFile expand('%', true, true)->assert_equal(['SomeFile']) @@ -241,6 +253,39 @@ def Test_map_function_arg() CheckDefAndScriptSuccess(lines) enddef +def Test_filereadable() + CheckDefExecFailure(['echo filereadable(true)'], 'E928:') + CheckDefExecFailure(['echo filereadable(v:null)'], 'E928:') + CheckDefExecFailure(['echo filereadable("")'], 'E928:') +enddef + +def Test_filewritable() + CheckDefExecFailure(['echo filewritable(true)'], 'E928:') + CheckDefExecFailure(['echo filewritable(v:null)'], 'E928:') + CheckDefExecFailure(['echo filewritable("")'], 'E928:') +enddef + +def Test_finddir() + CheckDefExecFailure(['echo finddir(true)'], 'E928:') + CheckDefExecFailure(['echo finddir(v:null)'], 'E928:') + CheckDefExecFailure(['echo finddir("")'], 'E928:') +enddef + +def Test_findfile() + CheckDefExecFailure(['echo findfile(true)'], 'E928:') + CheckDefExecFailure(['echo findfile(v:null)'], 'E928:') + CheckDefExecFailure(['echo findfile("")'], 'E928:') +enddef + +def Test_fnamemodify() + CheckDefExecFailure(['echo fnamemodify(true, ":p")'], 'E928:') + CheckDefExecFailure(['echo fnamemodify(v:null, ":p")'], 'E928:') + CheckDefExecFailure(['echo fnamemodify("", ":p")'], 'E928:') + CheckDefExecFailure(['echo fnamemodify("file", true)'], 'E928:') + CheckDefExecFailure(['echo fnamemodify("file", v:null)'], 'E928:') + CheckDefExecFailure(['echo fnamemodify("file", "")'], 'E928:') +enddef + def Test_filter_wrong_dict_key_type() assert_fails('Wrong_dict_key_type([1, 2, 3])', 'E1012:') enddef @@ -313,6 +358,30 @@ def Test_getloclist_return_type() d->assert_equal({items: []}) enddef +def Test_getfperm() + CheckDefExecFailure(['echo getfperm(true)'], 'E928:') + CheckDefExecFailure(['echo getfperm(v:null)'], 'E928:') + CheckDefExecFailure(['echo getfperm("")'], 'E928:') +enddef + +def Test_getfsize() + CheckDefExecFailure(['echo getfsize(true)'], 'E928:') + CheckDefExecFailure(['echo getfsize(v:null)'], 'E928:') + CheckDefExecFailure(['echo getfsize("")'], 'E928:') +enddef + +def Test_getftime() + CheckDefExecFailure(['echo getftime(true)'], 'E928:') + CheckDefExecFailure(['echo getftime(v:null)'], 'E928:') + CheckDefExecFailure(['echo getftime("")'], 'E928:') +enddef + +def Test_getftype() + CheckDefExecFailure(['echo getftype(true)'], 'E928:') + CheckDefExecFailure(['echo getftype(v:null)'], 'E928:') + CheckDefExecFailure(['echo getftype("")'], 'E928:') +enddef + def Test_getqflist_return_type() var l = getqflist() l->assert_equal([]) |