diff src/testdir/test_partial.vim @ 8599:ddb04cbe1e0c v7.4.1589

commit https://github.com/vim/vim/commit/9e63f61cb01c70fd71652f54b2d01ee27b2a3534 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Mar 17 23:13:28 2016 +0100 patch 7.4.1589 Problem: Combining dict and args with partial doesn't always work. Solution: Use the arguments from the partial.
author Christian Brabandt <cb@256bit.org>
date Thu, 17 Mar 2016 23:15:05 +0100
parents dc36cef103de
children ff41ece2e4b8
line wrap: on
line diff
--- a/src/testdir/test_partial.vim
+++ b/src/testdir/test_partial.vim
@@ -115,6 +115,36 @@ func Test_script_function_in_dict()
   call assert_equal('bar', B())
 endfunc
 
+function! s:cache_arg(arg) dict
+  let s:result = self.name . '/' . a:arg
+  return s:result
+endfunction
+
+func Test_script_function_in_dict_arg()
+  let s:obj = {'name': 'foo'}
+  let s:obj['clear'] = function('s:cache_arg')
+
+  call assert_equal('foo/bar', s:obj.clear('bar'))
+  let F = s:obj.clear
+  let s:result = ''
+  call assert_equal('foo/bar', F('bar'))
+  call assert_equal('foo/bar', s:result)
+
+  let s:obj['clear'] = function('s:cache_arg', ['bar'])
+  call assert_equal('foo/bar', s:obj.clear())
+  let s:result = ''
+  call s:obj.clear()
+  call assert_equal('foo/bar', s:result)
+
+  let F = s:obj.clear
+  call assert_equal('foo/bar', F())
+  let s:result = ''
+  call F()
+  call assert_equal('foo/bar', s:result)
+
+  call assert_equal('foo/bar', call(s:obj.clear, [], s:obj))
+endfunc
+
 func Test_partial_exists()
   let F = function('MyFunc')
   call assert_true(exists('*F'))