summaryrefslogtreecommitdiff
path: root/src/testdir/test_vim9_builtin.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-08-05 22:48:11 +0200
committerBram Moolenaar <Bram@vim.org>2021-08-05 22:48:11 +0200
commit5671f3f076573fa9133bc210d6580067698d9a1b (patch)
treef51db5d212f5b4391dace789663cf68d36d4c68c /src/testdir/test_vim9_builtin.vim
parent6f6d58c3809010b1386634c1aeec61f1a66e72c2 (diff)
downloadvim-git-5671f3f076573fa9133bc210d6580067698d9a1b.tar.gz
patch 8.2.3299: Vim9: exists() does not handle much at compile timev8.2.3299
Problem: Vim9: exists() does not handle much at compile time. Solution: Handle variable names. (closes #8688)
Diffstat (limited to 'src/testdir/test_vim9_builtin.vim')
-rw-r--r--src/testdir/test_vim9_builtin.vim24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim
index 19baada10..4fb1df342 100644
--- a/src/testdir/test_vim9_builtin.vim
+++ b/src/testdir/test_vim9_builtin.vim
@@ -787,6 +787,8 @@ def Test_exepath()
CheckDefExecFailure(['echo exepath("")'], 'E1175:')
enddef
+command DoSomeCommand let g:didSomeCommand = 4
+
def Test_exists()
CheckDefAndScriptFailure2(['exists(10)'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
call assert_equal(1, exists('&tabstop'))
@@ -809,6 +811,26 @@ def Test_exists()
else
assert_report('tabstop option not existing?')
endif
+
+ if exists(':DoSomeCommand') >= 2
+ DoSomeCommand
+ endif
+ assert_equal(4, g:didSomeCommand)
+ if exists(':NoSuchCommand') >= 2
+ NoSuchCommand
+ endif
+
+ var found = false
+ if exists('*CheckScriptSuccess')
+ found = true
+ endif
+ assert_true(found)
+ if exists('*NoSuchFunction')
+ NoSuchFunction()
+ endif
+ if exists('*no_such_function')
+ no_such_function()
+ endif
enddef
def Test_expand()
@@ -2948,7 +2970,7 @@ def Test_setreg()
assert_fails('setreg("ab", 0)', 'E1162:')
CheckDefAndScriptFailure2(['setreg(1, "b")'], 'E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1')
CheckDefAndScriptFailure2(['setreg("a", "b", 3)'], 'E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3')
-enddef
+enddef
def Test_settabvar()
CheckDefAndScriptFailure2(['settabvar("a", "b", 1)'], 'E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1')