summaryrefslogtreecommitdiff
path: root/src/testdir
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-05-24 15:44:17 +0200
committerBram Moolenaar <Bram@vim.org>2016-05-24 15:44:17 +0200
commit1d429610bf9e99a6252be8abbc910d6667e4d1da (patch)
tree348de7a5f9706f94ebcf03796263d5c743d6d0e3 /src/testdir
parent991dea3ab185fb35e577ab0bdfd443cd4b43ccc6 (diff)
downloadvim-git-1d429610bf9e99a6252be8abbc910d6667e4d1da.tar.gz
patch 7.4.1836v7.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.
Diffstat (limited to 'src/testdir')
-rw-r--r--src/testdir/test_partial.vim22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/testdir/test_partial.vim b/src/testdir/test_partial.vim
index 5f4a48faf..8b11200d2 100644
--- 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