aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir/test_user_func.vim
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-10-27 08:56:48 +0800
committerGitHub <noreply@github.com>2022-10-27 08:56:48 +0800
commitbce6891a69c6de3657173b880d3a800dc94cc651 (patch)
tree7622a4d9d73b918660bd9c8e762fd09790fae28e /src/nvim/testdir/test_user_func.vim
parent23204c83ed5333811192513ed9f61d70682fbee5 (diff)
parent905bef7bd9cd5d1751fc09aad3c6fb78e2c60ff8 (diff)
downloadrneovim-bce6891a69c6de3657173b880d3a800dc94cc651.tar.gz
rneovim-bce6891a69c6de3657173b880d3a800dc94cc651.tar.bz2
rneovim-bce6891a69c6de3657173b880d3a800dc94cc651.zip
Merge pull request #20823 from zeertzjq/vim-8.2.2100
vim-patch:8.2.{2100,2726,2727}
Diffstat (limited to 'src/nvim/testdir/test_user_func.vim')
-rw-r--r--src/nvim/testdir/test_user_func.vim36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/nvim/testdir/test_user_func.vim b/src/nvim/testdir/test_user_func.vim
index 8b5ee72bf1..01bf2e1d0f 100644
--- a/src/nvim/testdir/test_user_func.vim
+++ b/src/nvim/testdir/test_user_func.vim
@@ -149,8 +149,8 @@ func Test_default_arg()
call assert_equal(res.optional, 2)
call assert_equal(res['0'], 1)
- call assert_fails("call MakeBadFunc()", 'E989')
- call assert_fails("fu F(a=1 ,) | endf", 'E475')
+ call assert_fails("call MakeBadFunc()", 'E989:')
+ call assert_fails("fu F(a=1 ,) | endf", 'E1068:')
" Since neovim does not have v:none, the ability to use the default
" argument with the intermediate argument set to v:none has been omitted.
@@ -445,4 +445,36 @@ func Test_func_arg_error()
delfunc Xfunc
endfunc
+func Test_func_dict()
+ let mydict = {'a': 'b'}
+ function mydict.somefunc() dict
+ return len(self)
+ endfunc
+
+ call assert_equal("{'a': 'b', 'somefunc': function('2')}", string(mydict))
+ call assert_equal(2, mydict.somefunc())
+ call assert_match("^\n function \\d\\\+() dict"
+ \ .. "\n1 return len(self)"
+ \ .. "\n endfunction$", execute('func mydict.somefunc'))
+endfunc
+
+func Test_func_range()
+ new
+ call setline(1, range(1, 8))
+ func FuncRange() range
+ echo a:firstline
+ echo a:lastline
+ endfunc
+ 3
+ call assert_equal("\n3\n3", execute('call FuncRange()'))
+ call assert_equal("\n4\n6", execute('4,6 call FuncRange()'))
+ call assert_equal("\n function FuncRange() range"
+ \ .. "\n1 echo a:firstline"
+ \ .. "\n2 echo a:lastline"
+ \ .. "\n endfunction",
+ \ execute('function FuncRange'))
+
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab