diff options
author | Sean Dewar <seandewar@users.noreply.github.com> | 2021-08-11 13:47:33 +0100 |
---|---|---|
committer | Sean Dewar <seandewar@users.noreply.github.com> | 2021-08-13 01:11:36 +0100 |
commit | b2994e35c9357a8144beaf27e1a8ea4dd133f5d4 (patch) | |
tree | 8c8f5b17fc75ae51c55aae8d247462e49426678c /test/functional/lua/luaeval_spec.lua | |
parent | da9005af792f7a7eaae98ee9f6499af9a97fd095 (diff) | |
download | rneovim-b2994e35c9357a8144beaf27e1a8ea4dd133f5d4.tar.gz rneovim-b2994e35c9357a8144beaf27e1a8ea4dd133f5d4.tar.bz2 rneovim-b2994e35c9357a8144beaf27e1a8ea4dd133f5d4.zip |
feat(v:lua): support calling v:lua as a method
Diffstat (limited to 'test/functional/lua/luaeval_spec.lua')
-rw-r--r-- | test/functional/lua/luaeval_spec.lua | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/functional/lua/luaeval_spec.lua b/test/functional/lua/luaeval_spec.lua index 263408ad33..8ef77faa0f 100644 --- a/test/functional/lua/luaeval_spec.lua +++ b/test/functional/lua/luaeval_spec.lua @@ -481,6 +481,21 @@ describe('v:lua', function() pcall_err(eval, 'v:lua.mymod.crashy()')) end) + it('works when called as a method', function() + eq(123, eval('110->v:lua.foo(13)')) + eq(true, exec_lua([[return _G.val == nil]])) + + eq(321, eval('300->v:lua.foo(21, "boop")')) + eq("boop", exec_lua([[return _G.val]])) + + eq(NIL, eval('"there"->v:lua.mymod.noisy()')) + eq("hey there", meths.get_current_line()) + eq({5, 10, 15, 20}, eval('[[1], [2, 3], [4]]->v:lua.vim.tbl_flatten()->map({_, v -> v * 5})')) + + eq("Vim:E5108: Error executing lua [string \"<nvim>\"]:0: attempt to call global 'nonexistent' (a nil value)", + pcall_err(eval, '"huh?"->v:lua.mymod.crashy()')) + end) + it('works in :call', function() command(":call v:lua.mymod.noisy('command')") eq("hey command", meths.get_current_line()) @@ -522,5 +537,11 @@ describe('v:lua', function() eq("Vim(let):E46: Cannot change read-only variable \"v:['lua']\"", pcall_err(command, "let v:['lua'] = 'xx'")) eq("Vim(let):E46: Cannot change read-only variable \"v:lua\"", pcall_err(command, "let v:lua = 'xx'")) + + eq("Vim:E107: Missing parentheses: v:lua.func", pcall_err(eval, "'bad'->v:lua.func")) + eq("Vim:E274: No white space allowed before parenthesis", pcall_err(eval, "'bad'->v:lua.func ()")) + eq("Vim:E107: Missing parentheses: v:lua", pcall_err(eval, "'bad'->v:lua")) + eq("Vim:E117: Unknown function: v:lua", pcall_err(eval, "'bad'->v:lua()")) + eq("Vim:E15: Invalid expression: v:lua.()", pcall_err(eval, "'bad'->v:lua.()")) end) end) |