patch 9.1.1505: not possible to return completion type for :ex command

Problem:  not possible to return command-line completion type for :ex
          command
Solution: make getcmdcompltype() accept an optional and return the
          command-line completion for that arg (Shougo Matsushita).

closes: #17606

Signed-off-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index 59c25db..9ebeb0f 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -4589,4 +4589,14 @@
   set wildcharm=0
 endfunc
 
+func Test_getcmdcompltype_with_pat()
+  call assert_fails('call getcmdcompltype({})', 'E1174:')
+  call assert_equal(getcmdcompltype(''), 'command')
+  call assert_equal(getcmdcompltype('dummy '), '')
+  call assert_equal(getcmdcompltype('cd '), 'dir_in_path')
+  call assert_equal(getcmdcompltype('let v:n'), 'var')
+  call assert_equal(getcmdcompltype('call tag'), 'function')
+  call assert_equal(getcmdcompltype('help '), 'help')
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab