diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-12-06 15:03:19 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-12-06 15:03:19 +0100 |
commit | 67322bf74a106b6476b093e75da87d61e2181b76 (patch) | |
tree | 6b99bac57200921542860cb25ead34f5470969f7 /src/testdir/test_user_func.vim | |
parent | 918a4249176a8ccec3a34c9c7ef7bf4163676a63 (diff) | |
download | vim-git-67322bf74a106b6476b093e75da87d61e2181b76.tar.gz |
patch 8.2.2100: insufficient testing for function range and dictv8.2.2100
Problem: Insufficient testing for function range and dict.
Solution: Add a few tests. (Dominique Pellé, closes #7428)
Diffstat (limited to 'src/testdir/test_user_func.vim')
-rw-r--r-- | src/testdir/test_user_func.vim | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/testdir/test_user_func.vim b/src/testdir/test_user_func.vim index 2edaec87e..2db558931 100644 --- a/src/testdir/test_user_func.vim +++ b/src/testdir/test_user_func.vim @@ -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 |