diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-08-04 23:04:39 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-08-04 23:04:39 +0200 |
commit | fcfe1a9b8950b8b211ab3b24d84b17c6847ea43f (patch) | |
tree | daeeffb4dd96cdd7744597d9623d222404edd8e2 /src/testdir/test_user_func.vim | |
parent | 7a4ea1df2f85e00286c49db1145e3a38b35557f4 (diff) | |
download | vim-git-fcfe1a9b8950b8b211ab3b24d84b17c6847ea43f.tar.gz |
patch 8.1.1816: cannot use a user defined function as a methodv8.1.1816
Problem: Cannot use a user defined function as a method.
Solution: Pass the base as the first argument to the user defined function
after "->". (partly by FUJIWARA Takuya)
Diffstat (limited to 'src/testdir/test_user_func.vim')
-rw-r--r-- | src/testdir/test_user_func.vim | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/testdir/test_user_func.vim b/src/testdir/test_user_func.vim index 666c06c13..4b4a2766f 100644 --- a/src/testdir/test_user_func.vim +++ b/src/testdir/test_user_func.vim @@ -47,7 +47,7 @@ func FuncWithRef(a) endfunc func Test_user_func() - let g:FuncRef=function("FuncWithRef") + let g:FuncRef = function("FuncWithRef") let g:counter = 0 inoremap <expr> ( ListItem() inoremap <expr> [ ListReset() @@ -62,6 +62,14 @@ func Test_user_func() call assert_equal(9, g:retval) call assert_equal(333, g:FuncRef(333)) + let g:retval = "nop" + call assert_equal('xxx4asdf', "xxx"->Table(4, "asdf")) + call assert_equal('fail', 45->Compute(0, "retval")) + call assert_equal('nop', g:retval) + call assert_equal('ok', 45->Compute(5, "retval")) + call assert_equal(9, g:retval) + " call assert_equal(333, 333->g:FuncRef()) + enew normal oXX+-XX @@ -144,3 +152,11 @@ func Test_default_arg() \ .. " endfunction", \ execute('func Args2')) endfunc + +func s:addFoo(lead) + return a:lead .. 'foo' +endfunc + +func Test_user_method() + eval 'bar'->s:addFoo()->assert_equal('barfoo') +endfunc |