patch 8.2.0346: Vim9: finding common list type not tested
Problem: Vim9: finding common list type not tested.
Solution: Add more tests. Fix listing function. Fix overwriting type.
diff --git a/src/testdir/runtest.vim b/src/testdir/runtest.vim
index f0cc1ab..d8a1cf7 100644
--- a/src/testdir/runtest.vim
+++ b/src/testdir/runtest.vim
@@ -386,7 +386,7 @@
redir @q
silent function /^Test_
redir END
-let s:tests = split(substitute(@q, 'function \(\k*()\)', '\1', 'g'))
+let s:tests = split(substitute(@q, '\(function\|def\) \(\k*()\)', '\2', 'g'))
" If there is an extra argument filter the function names against it.
if argc() > 1
diff --git a/src/testdir/test_vim9_disassemble.vim b/src/testdir/test_vim9_disassemble.vim
index 7875e84..5ba18dd 100644
--- a/src/testdir/test_vim9_disassemble.vim
+++ b/src/testdir/test_vim9_disassemble.vim
@@ -814,4 +814,36 @@
\, res)
enddef
+def SomeStringArg(arg: string)
+ echo arg
+enddef
+
+def SomeAnyArg(arg: any)
+ echo arg
+enddef
+
+def SomeStringArgAndReturn(arg: string): string
+ return arg
+enddef
+
+def Test_display_func()
+ let res1 = execute('function SomeStringArg')
+ assert_match('.* def SomeStringArg(arg: string).*'
+ \ .. ' echo arg.*'
+ \ .. ' enddef'
+ \, res1)
+
+ let res2 = execute('function SomeAnyArg')
+ assert_match('.* def SomeAnyArg(arg: any).*'
+ \ .. ' echo arg.*'
+ \ .. ' enddef'
+ \, res2)
+
+ let res3 = execute('function SomeStringArgAndReturn')
+ assert_match('.* def SomeStringArgAndReturn(arg: string): string.*'
+ \ .. ' return arg.*'
+ \ .. ' enddef'
+ \, res3)
+enddef
+
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index c01ab83..d5e42e8 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -66,6 +66,9 @@
let party1: partial
let party2: partial = funcref('Test_syntax')
+ " type becomes list<any>
+ let somelist = rand() > 0 ? [1, 2, 3] : ['a', 'b', 'c']
+
g:newvar = 'new'
assert_equal('new', g:newvar)