Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
24971:f06b8d3bda25 | 24972:b11f38f77006 |
---|---|
320 assert_false(executable("")) | 320 assert_false(executable("")) |
321 assert_false(executable(test_null_string())) | 321 assert_false(executable(test_null_string())) |
322 | 322 |
323 CheckDefExecFailure(['echo executable(123)'], 'E1174:') | 323 CheckDefExecFailure(['echo executable(123)'], 'E1174:') |
324 CheckDefExecFailure(['echo executable(true)'], 'E1174:') | 324 CheckDefExecFailure(['echo executable(true)'], 'E1174:') |
325 enddef | |
326 | |
327 def Test_execute() | |
328 var res = execute("echo 'hello'") | |
329 assert_equal("\nhello", res) | |
330 res = execute(["echo 'here'", "echo 'there'"]) | |
331 assert_equal("\nhere\nthere", res) | |
332 | |
333 CheckDefFailure(['echo execute(123)'], 'E1013: Argument 1: type mismatch, expected string but got number') | |
334 CheckDefFailure(['echo execute([123])'], 'E1013: Argument 1: type mismatch, expected list<string> but got list<number>') | |
335 CheckDefExecFailure(['echo execute(["xx", 123])'], 'E492') | |
336 CheckDefFailure(['echo execute("xx", 123)'], 'E1013: Argument 2: type mismatch, expected string but got number') | |
325 enddef | 337 enddef |
326 | 338 |
327 def Test_exepath() | 339 def Test_exepath() |
328 CheckDefExecFailure(['echo exepath(true)'], 'E1174:') | 340 CheckDefExecFailure(['echo exepath(true)'], 'E1174:') |
329 CheckDefExecFailure(['echo exepath(v:null)'], 'E1174:') | 341 CheckDefExecFailure(['echo exepath(v:null)'], 'E1174:') |