diff options
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/api/vim_spec.lua | 25 | ||||
-rw-r--r-- | test/functional/ex_cmds/source_spec.lua | 16 |
2 files changed, 38 insertions, 3 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 6b644ed519..f878a50a26 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -89,7 +89,7 @@ describe('API', function() it(':verbose set {option}?', function() nvim('exec', 'set nowrap', false) - eq('nowrap\n\tLast set from anonymous :source', + eq('nowrap\n\tLast set from anonymous :source (script id 1)', nvim('exec', 'verbose set wrap?', true)) end) @@ -132,6 +132,29 @@ describe('API', function() -- try no spaces before continuations to catch off-by-one error nvim('exec', 'let ab = #{\n\\a: 98,\n"\\ b: 2\n\\}', false) eq({a = 98}, request('nvim_eval', 'g:ab')) + + -- Script scope (s:) + eq('ahoy! script-scoped varrrrr', nvim('exec', [[ + let s:pirate = 'script-scoped varrrrr' + function! s:avast_ye_hades(s) abort + return a:s .. ' ' .. s:pirate + endfunction + echo <sid>avast_ye_hades('ahoy!') + ]], true)) + + eq('ahoy! script-scoped varrrrr', nvim('exec', [[ + let s:pirate = 'script-scoped varrrrr' + function! Avast_ye_hades(s) abort + return a:s .. ' ' .. s:pirate + endfunction + echo nvim_exec('echo Avast_ye_hades(''ahoy!'')', 1) + ]], true)) + + eq('Vim(call):E5555: API call: Vim(echo):E121: Undefined variable: s:pirate', + pcall_err(request, 'nvim_exec', [[ + let s:pirate = 'script-scoped varrrrr' + call nvim_exec('echo s:pirate', 1) + ]], false)) end) it('non-ASCII input', function() diff --git a/test/functional/ex_cmds/source_spec.lua b/test/functional/ex_cmds/source_spec.lua index bdf6ae76d1..8077b22e56 100644 --- a/test/functional/ex_cmds/source_spec.lua +++ b/test/functional/ex_cmds/source_spec.lua @@ -25,11 +25,14 @@ describe(':source', function() let b = #{ \ k: "v" "\ (o_o) - \ }]]) + \ } + let s:s = 0zbeef.cafe + let c = s:s]]) command('source') eq('2', meths.exec('echo a', true)) eq("{'k': 'v'}", meths.exec('echo b', true)) + eq("0zBEEFCAFE", meths.exec('echo c', true)) exec('set cpoptions+=C') eq('Vim(let):E15: Invalid expression: #{', exc_exec('source')) @@ -43,7 +46,11 @@ describe(':source', function() let b = #{ "\ (>_<) \ K: "V" - \ }]]) + \ } + function! s:C() abort + return expand("<SID>") .. "C()" + endfunction + let D = {-> s:C()}]]) -- Source the 2nd line only feed('ggjV') @@ -55,6 +62,11 @@ describe(':source', function() feed_command(':source') eq('4', meths.exec('echo a', true)) eq("{'K': 'V'}", meths.exec('echo b', true)) + eq("<SNR>3_C()", meths.exec('echo D()', true)) + + -- Source last line only + feed_command(':$source') + eq('Vim(echo):E117: Unknown function: s:C', exc_exec('echo D()')) exec('set cpoptions+=C') eq('Vim(let):E15: Invalid expression: #{', exc_exec("'<,'>source")) |