diff src/testdir/test_partial.vim @ 9104:2242a5766417 v7.4.1836

commit https://github.com/vim/vim/commit/1d429610bf9e99a6252be8abbc910d6667e4d1da Author: Bram Moolenaar <Bram@vim.org> Date: Tue May 24 15:44:17 2016 +0200 patch 7.4.1836 Problem: When using a partial on a dictionary it always gets bound to that dictionary. Solution: Make a difference between binding a function to a dictionary explicitly or automatically.
author Christian Brabandt <cb@256bit.org>
date Tue, 24 May 2016 15:45:06 +0200
parents be36707a661a
children 6d3888e2232c
line wrap: on
line diff
--- a/src/testdir/test_partial.vim
+++ b/src/testdir/test_partial.vim
@@ -257,3 +257,25 @@ func Test_ref_job_partial_dict()
     call job_setoptions(g:ref_job, {'exit_cb': function('string', [], d)})
   endif
 endfunc
+
+func Test_auto_partial_rebind()
+  let dict1 = {'name': 'dict1'}
+  func! dict1.f1()
+    return self.name
+  endfunc
+  let dict1.f2 = function(dict1.f1, dict1)
+
+  call assert_equal('dict1', dict1.f1())
+  call assert_equal('dict1', dict1['f1']())
+  call assert_equal('dict1', dict1.f2())
+  call assert_equal('dict1', dict1['f2']())
+
+  let dict2 = {'name': 'dict2'}
+  let dict2.f1 = dict1.f1
+  let dict2.f2 = dict1.f2
+
+  call assert_equal('dict2', dict2.f1())
+  call assert_equal('dict2', dict2['f1']())
+  call assert_equal('dict1', dict2.f2())
+  call assert_equal('dict1', dict2['f2']())
+endfunc