mirror of
https://github.com/neovim/neovim.git
synced 2025-12-16 19:35:37 +00:00
test: remote/define.vim: range
This commit is contained in:
committed by
Justin M. Keyes
parent
d835c030f2
commit
4a200ceafa
@@ -157,7 +157,7 @@ endfunction
|
|||||||
|
|
||||||
function! remote#define#FunctionOnChannel(channel, method, sync, name, opts)
|
function! remote#define#FunctionOnChannel(channel, method, sync, name, opts)
|
||||||
let rpcargs = [a:channel, '"'.a:method.'"', 'a:000']
|
let rpcargs = [a:channel, '"'.a:method.'"', 'a:000']
|
||||||
if has_key(a:opts, 'range') && a:opts.range != '0'
|
if has_key(a:opts, 'range')
|
||||||
call add(rpcargs, '[a:firstline, a:lastline]')
|
call add(rpcargs, '[a:firstline, a:lastline]')
|
||||||
endif
|
endif
|
||||||
call s:AddEval(rpcargs, a:opts)
|
call s:AddEval(rpcargs, a:opts)
|
||||||
@@ -222,7 +222,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:GetFunctionPrefix(name, opts)
|
function! s:GetFunctionPrefix(name, opts)
|
||||||
let res = "function! ".a:name."(...)"
|
let res = "function! ".a:name."(...)"
|
||||||
if has_key(a:opts, 'range') && a:opts.range != '0'
|
if has_key(a:opts, 'range')
|
||||||
let res = res." range"
|
let res = res." range"
|
||||||
endif
|
endif
|
||||||
return res."\n"
|
return res."\n"
|
||||||
|
|||||||
@@ -333,6 +333,39 @@ local function function_specs_for(fn, sync, first_arg_factory, init)
|
|||||||
runx(sync, handler, on_setup)
|
runx(sync, handler, on_setup)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
describe('with range', function()
|
||||||
|
it('ok', function()
|
||||||
|
call(fn, args..[[, {'range': ''}]])
|
||||||
|
local function on_setup()
|
||||||
|
command('%call TestFunction(1, "a", ["b", "c"])')
|
||||||
|
end
|
||||||
|
|
||||||
|
local function handler(method, arguments)
|
||||||
|
eq('test-handler', method)
|
||||||
|
eq({{1, 'a', {'b', 'c'}}, {1, 1}}, arguments)
|
||||||
|
return 'rv'
|
||||||
|
end
|
||||||
|
|
||||||
|
runx(sync, handler, on_setup)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
describe('with eval/range', function()
|
||||||
|
it('ok', function()
|
||||||
|
call(fn, args..[[, {'eval': '4', 'range': ''}]])
|
||||||
|
local function on_setup()
|
||||||
|
command('%call TestFunction(1, "a", ["b", "c"])')
|
||||||
|
end
|
||||||
|
|
||||||
|
local function handler(method, arguments)
|
||||||
|
eq('test-handler', method)
|
||||||
|
eq({{1, 'a', {'b', 'c'}}, {1, 1}, 4}, arguments)
|
||||||
|
return 'rv'
|
||||||
|
end
|
||||||
|
|
||||||
|
runx(sync, handler, on_setup)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user