Mercurial > vim
diff src/testdir/test_vim9_builtin.vim @ 24972:b11f38f77006 v8.2.3023
patch 8.2.3023: Vim9: arguments for execute() not checked at compile time
Commit: https://github.com/vim/vim/commit/ca81f0e834640cf3465b3b742e60c12e8a0956f2
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jun 20 14:41:01 2021 +0200
patch 8.2.3023: Vim9: arguments for execute() not checked at compile time
Problem: Vim9: arguments for execute() not checked at compile time.
Solution: Add a function to check the argument types.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 20 Jun 2021 14:45:03 +0200 |
parents | 8fdf839af1f4 |
children | 3b1770226f85 |
line wrap: on
line diff
--- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -324,6 +324,18 @@ def Test_executable() CheckDefExecFailure(['echo executable(true)'], 'E1174:') enddef +def Test_execute() + var res = execute("echo 'hello'") + assert_equal("\nhello", res) + res = execute(["echo 'here'", "echo 'there'"]) + assert_equal("\nhere\nthere", res) + + CheckDefFailure(['echo execute(123)'], 'E1013: Argument 1: type mismatch, expected string but got number') + CheckDefFailure(['echo execute([123])'], 'E1013: Argument 1: type mismatch, expected list<string> but got list<number>') + CheckDefExecFailure(['echo execute(["xx", 123])'], 'E492') + CheckDefFailure(['echo execute("xx", 123)'], 'E1013: Argument 2: type mismatch, expected string but got number') +enddef + def Test_exepath() CheckDefExecFailure(['echo exepath(true)'], 'E1174:') CheckDefExecFailure(['echo exepath(v:null)'], 'E1174:')