summaryrefslogtreecommitdiff
path: root/src/testdir
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-07-25 16:33:02 +0200
committerBram Moolenaar <Bram@vim.org>2020-07-25 16:33:02 +0200
commit24aa48b7a265c24e18f0f978dfe0255e138e2b90 (patch)
treee87777080018eb171aa4713cefa258e275f44c4f /src/testdir
parent925e9fd6339981c1015410e1b6a6dd19e34f36cc (diff)
downloadvim-git-24aa48b7a265c24e18f0f978dfe0255e138e2b90.tar.gz
patch 8.2.1291: Vim9: type of varargs items is not checkedv8.2.1291
Problem: Vim9: type of varargs items is not checked. Solution: Check the list item types. (closes #6523)
Diffstat (limited to 'src/testdir')
-rw-r--r--src/testdir/test_vim9_func.vim50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index ef98583fe..49be8f97a 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -164,7 +164,55 @@ def Test_call_def_varargs()
assert_equal('one,foo', MyDefVarargs('one'))
assert_equal('one,two', MyDefVarargs('one', 'two'))
assert_equal('one,two,three', MyDefVarargs('one', 'two', 'three'))
- call CheckDefFailure(['MyDefVarargs("one", 22)'], 'E1013: argument 2: type mismatch, expected string but got number')
+ CheckDefFailure(['MyDefVarargs("one", 22)'],
+ 'E1013: argument 2: type mismatch, expected string but got number')
+ CheckDefFailure(['MyDefVarargs("one", "two", 123)'],
+ 'E1013: argument 3: type mismatch, expected string but got number')
+
+ let lines =<< trim END
+ vim9script
+ def Func(...l: list<string>)
+ echo l
+ enddef
+ Func('a', 'b', 'c')
+ END
+ CheckScriptSuccess(lines)
+
+ lines =<< trim END
+ vim9script
+ def Func(...l: list<string>)
+ echo l
+ enddef
+ Func()
+ END
+ CheckScriptSuccess(lines)
+
+ lines =<< trim END
+ vim9script
+ def Func(...l: list<string>)
+ echo l
+ enddef
+ Func(1, 2, 3)
+ END
+ CheckScriptFailure(lines, 'E1013:')
+
+ lines =<< trim END
+ vim9script
+ def Func(...l: list<string>)
+ echo l
+ enddef
+ Func('a', 9)
+ END
+ CheckScriptFailure(lines, 'E1013:')
+
+ lines =<< trim END
+ vim9script
+ def Func(...l: list<string>)
+ echo l
+ enddef
+ Func(1, 'a')
+ END
+ CheckScriptFailure(lines, 'E1013:')
enddef
let s:value = ''