aboutsummaryrefslogtreecommitdiff
path: root/test/functional/provider/define_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/provider/define_spec.lua')
-rw-r--r--test/functional/provider/define_spec.lua92
1 files changed, 47 insertions, 45 deletions
diff --git a/test/functional/provider/define_spec.lua b/test/functional/provider/define_spec.lua
index 12efbec326..657f1a0d8a 100644
--- a/test/functional/provider/define_spec.lua
+++ b/test/functional/provider/define_spec.lua
@@ -1,7 +1,8 @@
local helpers = require('test.functional.helpers')(after_each)
-local eval, command, nvim = helpers.eval, helpers.command, helpers.nvim
+local eval, command = helpers.eval, helpers.command
local eq, run, stop = helpers.eq, helpers.run, helpers.stop
local clear = helpers.clear
+local api = helpers.api
local function get_prefix(sync)
if sync then
@@ -11,7 +12,7 @@ local function get_prefix(sync)
end
local function call(fn, arguments)
- command('call '..fn..'('..arguments..')')
+ command('call ' .. fn .. '(' .. arguments .. ')')
end
local function clear_and_init(init)
@@ -44,24 +45,24 @@ end
local function command_specs_for(fn, sync, first_arg_factory, init)
local prefix = get_prefix(sync)
- describe(prefix..' command created by', function()
+ describe(prefix .. ' command created by', function()
before_each(clear_and_init(init))
describe(fn, function()
local args
before_each(function()
- args = first_arg_factory()..', "test-handler", '
+ args = first_arg_factory() .. ', "test-handler", '
if sync then
args = args .. '1'
else
args = args .. '0'
end
- args = args..', "RpcCommand"'
+ args = args .. ', "RpcCommand"'
end)
it('without options', function()
- call(fn, args..', {}')
+ call(fn, args .. ', {}')
local function on_setup()
command('RpcCommand')
end
@@ -75,14 +76,14 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
end)
it('with nargs', function()
- call(fn, args..', {"nargs": "*"}')
+ call(fn, args .. ', {"nargs": "*"}')
local function on_setup()
command('RpcCommand arg1 arg2 arg3')
end
local function handler(method, arguments)
eq('test-handler', method)
- eq({'arg1', 'arg2', 'arg3'}, arguments[1])
+ eq({ 'arg1', 'arg2', 'arg3' }, arguments[1])
return ''
end
@@ -90,14 +91,14 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
end)
it('with nargs/double-quote', function()
- call(fn, args..', {"nargs": "*"}')
+ call(fn, args .. ', {"nargs": "*"}')
local function on_setup()
command('RpcCommand "arg1" "arg2" "arg3"')
end
local function handler(method, arguments)
eq('test-handler', method)
- eq({'"arg1"', '"arg2"', '"arg3"'}, arguments[1])
+ eq({ '"arg1"', '"arg2"', '"arg3"' }, arguments[1])
return ''
end
@@ -105,14 +106,14 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
end)
it('with range', function()
- call(fn,args..', {"range": ""}')
+ call(fn, args .. ', {"range": ""}')
local function on_setup()
command('1,1RpcCommand')
end
local function handler(method, arguments)
eq('test-handler', method)
- eq({1, 1}, arguments[1])
+ eq({ 1, 1 }, arguments[1])
return ''
end
@@ -120,15 +121,15 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
end)
it('with nargs/range', function()
- call(fn, args..', {"nargs": "1", "range": ""}')
+ call(fn, args .. ', {"nargs": "1", "range": ""}')
local function on_setup()
command('1,1RpcCommand arg')
end
local function handler(method, arguments)
eq('test-handler', method)
- eq({'arg'}, arguments[1])
- eq({1, 1}, arguments[2])
+ eq({ 'arg' }, arguments[1])
+ eq({ 1, 1 }, arguments[2])
return ''
end
@@ -136,14 +137,14 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
end)
it('with nargs/count', function()
- call(fn, args..', {"nargs": "1", "count": "5"}')
+ call(fn, args .. ', {"nargs": "1", "count": "5"}')
local function on_setup()
command('5RpcCommand arg')
end
local function handler(method, arguments)
eq('test-handler', method)
- eq({'arg'}, arguments[1])
+ eq({ 'arg' }, arguments[1])
eq(5, arguments[2])
return ''
end
@@ -152,14 +153,14 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
end)
it('with nargs/count/bang', function()
- call(fn, args..', {"nargs": "1", "count": "5", "bang": ""}')
+ call(fn, args .. ', {"nargs": "1", "count": "5", "bang": ""}')
local function on_setup()
command('5RpcCommand! arg')
end
local function handler(method, arguments)
eq('test-handler', method)
- eq({'arg'}, arguments[1])
+ eq({ 'arg' }, arguments[1])
eq(5, arguments[2])
eq(1, arguments[3])
return ''
@@ -169,15 +170,14 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
end)
it('with nargs/count/bang/register', function()
- call(fn, args..', {"nargs": "1", "count": "5", "bang": "",'..
- ' "register": ""}')
+ call(fn, args .. ', {"nargs": "1", "count": "5", "bang": "",' .. ' "register": ""}')
local function on_setup()
command('5RpcCommand! b arg')
end
local function handler(method, arguments)
eq('test-handler', method)
- eq({'arg'}, arguments[1])
+ eq({ 'arg' }, arguments[1])
eq(5, arguments[2])
eq(1, arguments[3])
eq('b', arguments[4])
@@ -188,8 +188,12 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
end)
it('with nargs/count/bang/register/eval', function()
- call(fn, args..', {"nargs": "1", "count": "5", "bang": "",'..
- ' "register": "", "eval": "@<reg>"}')
+ call(
+ fn,
+ args
+ .. ', {"nargs": "1", "count": "5", "bang": "",'
+ .. ' "register": "", "eval": "@<reg>"}'
+ )
local function on_setup()
command('let @b = "regb"')
command('5RpcCommand! b arg')
@@ -197,7 +201,7 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
local function handler(method, arguments)
eq('test-handler', method)
- eq({'arg'}, arguments[1])
+ eq({ 'arg' }, arguments[1])
eq(5, arguments[2])
eq(1, arguments[3])
eq('b', arguments[4])
@@ -211,28 +215,27 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
end)
end
-
local function autocmd_specs_for(fn, sync, first_arg_factory, init)
local prefix = get_prefix(sync)
- describe(prefix..' autocmd created by', function()
+ describe(prefix .. ' autocmd created by', function()
before_each(clear_and_init(init))
describe(fn, function()
local args
before_each(function()
- args = first_arg_factory()..', "test-handler", '
+ args = first_arg_factory() .. ', "test-handler", '
if sync then
args = args .. '1'
else
args = args .. '0'
end
- args = args..', "BufEnter"'
+ args = args .. ', "BufEnter"'
end)
it('without options', function()
- call(fn, args..', {}')
+ call(fn, args .. ', {}')
local function on_setup()
command('doautocmd BufEnter x.c')
end
@@ -246,7 +249,7 @@ local function autocmd_specs_for(fn, sync, first_arg_factory, init)
end)
it('with eval', function()
- call(fn, args..[[, {'eval': 'expand("<afile>")'}]])
+ call(fn, args .. [[, {'eval': 'expand("<afile>")'}]])
local function on_setup()
command('doautocmd BufEnter x.c')
end
@@ -263,28 +266,27 @@ local function autocmd_specs_for(fn, sync, first_arg_factory, init)
end)
end
-
local function function_specs_for(fn, sync, first_arg_factory, init)
local prefix = get_prefix(sync)
- describe(prefix..' function created by', function()
+ describe(prefix .. ' function created by', function()
before_each(clear_and_init(init))
describe(fn, function()
local args
before_each(function()
- args = first_arg_factory()..', "test-handler", '
+ args = first_arg_factory() .. ', "test-handler", '
if sync then
args = args .. '1'
else
args = args .. '0'
end
- args = args..', "TestFunction"'
+ args = args .. ', "TestFunction"'
end)
it('without options', function()
- call(fn, args..', {}')
+ call(fn, args .. ', {}')
local function on_setup()
if sync then
eq('rv', eval('TestFunction(1, "a", ["b", "c"])'))
@@ -295,7 +297,7 @@ local function function_specs_for(fn, sync, first_arg_factory, init)
local function handler(method, arguments)
eq('test-handler', method)
- eq({{1, 'a', {'b', 'c'}}}, arguments)
+ eq({ { 1, 'a', { 'b', 'c' } } }, arguments)
return 'rv'
end
@@ -303,7 +305,7 @@ local function function_specs_for(fn, sync, first_arg_factory, init)
end)
it('with eval', function()
- call(fn, args..[[, {'eval': '2 + 2'}]])
+ call(fn, args .. [[, {'eval': '2 + 2'}]])
local function on_setup()
if sync then
eq('rv', eval('TestFunction(1, "a", ["b", "c"])'))
@@ -314,7 +316,7 @@ local function function_specs_for(fn, sync, first_arg_factory, init)
local function handler(method, arguments)
eq('test-handler', method)
- eq({{1, 'a', {'b', 'c'}}, 4}, arguments)
+ eq({ { 1, 'a', { 'b', 'c' } }, 4 }, arguments)
return 'rv'
end
@@ -327,14 +329,14 @@ local function function_specs_for(fn, sync, first_arg_factory, init)
bar
baz
zub]])
- call(fn, args..[[, {'range': ''}]])
+ call(fn, args .. [[, {'range': ''}]])
local function on_setup()
command('2,3call TestFunction(1, "a", ["b", "c"])')
end
local function handler(method, arguments)
eq('test-handler', method)
- eq({{1, 'a', {'b', 'c'}}, {2, 3}}, arguments)
+ eq({ { 1, 'a', { 'b', 'c' } }, { 2, 3 } }, arguments)
return 'rv'
end
@@ -342,14 +344,14 @@ local function function_specs_for(fn, sync, first_arg_factory, init)
end)
it('with eval/range', function()
- call(fn, args..[[, {'eval': '4', 'range': ''}]])
+ 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)
+ eq({ { 1, 'a', { 'b', 'c' } }, { 1, 1 }, 4 }, arguments)
return 'rv'
end
@@ -360,7 +362,7 @@ local function function_specs_for(fn, sync, first_arg_factory, init)
end
local function channel()
- return nvim('get_api_info')[1]
+ return api.nvim_get_chan_info(0).id
end
local function host()
@@ -368,7 +370,7 @@ local function host()
end
local function register()
- eval('remote#host#Register("busted", "busted", '..channel()..')')
+ eval('remote#host#Register("busted", "busted", ' .. channel() .. ')')
end
command_specs_for('remote#define#CommandOnChannel', true, channel)