diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-07-01 15:12:05 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-07-01 15:12:05 +0200 |
commit | ca06da92432a57e5dcf3e0eebd322fae80941a6b (patch) | |
tree | 3618c893dc8c4111e0d1e77a1cefadd90133815a /src/testdir/test_lua.vim | |
parent | ffd112edc6a8f72b66c06207bff4431f6aec7b6f (diff) | |
download | vim-git-ca06da92432a57e5dcf3e0eebd322fae80941a6b.tar.gz |
patch 8.1.0134: Lua interface does not support funcrefv8.1.0134
Problem: Lua interface does not support funcref.
Solution: Add funcref support. (Luis Carvalho)
Diffstat (limited to 'src/testdir/test_lua.vim')
-rw-r--r-- | src/testdir/test_lua.vim | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/testdir/test_lua.vim b/src/testdir/test_lua.vim index 840466aff..30ce48e2e 100644 --- a/src/testdir/test_lua.vim +++ b/src/testdir/test_lua.vim @@ -397,6 +397,29 @@ func Test_dict_iter() lua str, k, v, d = nil, nil, nil, nil endfunc +func Test_funcref() + function I(x) + return a:x + endfunction + let R = function('I') + lua i1 = vim.funcref"I" + lua i2 = vim.eval"R" + lua msg = "funcref|test|" .. (#i2(i1) == #i1(i2) and "OK" or "FAIL") + lua msg = vim.funcref"tr"(msg, "|", " ") + call assert_equal("funcref test OK", luaeval('msg')) + + " dict funcref + function Mylen() dict + return len(self.data) + endfunction + let l = [0, 1, 2, 3] + let mydict = {'data': l} + lua d = vim.eval"mydict" + lua d.len = vim.funcref"Mylen" -- assign d as 'self' + lua res = (d.len() == vim.funcref"len"(vim.eval"l")) and "OK" or "FAIL" + call assert_equal("OK", luaeval('res')) +endfunc + " Test vim.type() func Test_type() " The following values are identical to Lua's type function. @@ -414,6 +437,7 @@ func Test_type() call assert_equal('buffer', luaeval('vim.type(vim.buffer())')) call assert_equal('list', luaeval('vim.type(vim.list())')) call assert_equal('dict', luaeval('vim.type(vim.dict())')) + call assert_equal('funcref', luaeval('vim.type(vim.funcref("Test_type"))')) endfunc " Test vim.open() |