aboutsummaryrefslogtreecommitdiff
path: root/test/functional/provider
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/provider')
-rw-r--r--test/functional/provider/clipboard_spec.lua222
-rw-r--r--test/functional/provider/define_spec.lua92
-rw-r--r--test/functional/provider/nodejs_spec.lua33
-rw-r--r--test/functional/provider/perl_spec.lua41
-rw-r--r--test/functional/provider/provider_spec.lua13
-rw-r--r--test/functional/provider/python3_spec.lua54
-rw-r--r--test/functional/provider/ruby_spec.lua18
7 files changed, 265 insertions, 208 deletions
diff --git a/test/functional/provider/clipboard_spec.lua b/test/functional/provider/clipboard_spec.lua
index 0099183302..0c4fd7aaa0 100644
--- a/test/functional/provider/clipboard_spec.lua
+++ b/test/functional/provider/clipboard_spec.lua
@@ -3,12 +3,13 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
-local feed_command, expect, eq, eval, source = helpers.feed_command, helpers.expect, helpers.eq, helpers.eval, helpers.source
+local feed_command, expect, eq, eval, source =
+ helpers.feed_command, helpers.expect, helpers.eq, helpers.eval, helpers.source
local command = helpers.command
-local meths = helpers.meths
+local api = helpers.api
local function basic_register_test(noblock)
- insert("some words")
+ insert('some words')
feed('^dwP')
expect('some words')
@@ -81,9 +82,9 @@ local function basic_register_test(noblock)
-- pasting in visual does unnamed delete of visual selection
feed('ggdG')
- insert("one and two and three")
+ insert('one and two and three')
feed('"ayiwbbviw"ap^viwp$viw"-p')
- expect("two and three and one")
+ expect('two and three and one')
end
describe('clipboard', function()
@@ -93,10 +94,10 @@ describe('clipboard', function()
clear()
screen = Screen.new(72, 4)
screen:set_default_attr_ids({
- [0] = {bold = true, foreground = Screen.colors.Blue},
- [1] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
- [2] = {bold = true, foreground = Screen.colors.SeaGreen4},
- [3] = {bold = true, reverse = true};
+ [0] = { bold = true, foreground = Screen.colors.Blue },
+ [1] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
+ [2] = { bold = true, foreground = Screen.colors.SeaGreen4 },
+ [3] = { bold = true, reverse = true },
})
screen:attach()
end)
@@ -112,15 +113,13 @@ describe('clipboard', function()
feed('"+yl')
screen:expect([[
^a |
- {0:~ }|
- {0:~ }|
+ {0:~ }|*2
clipboard: No provider. Try ":checkhealth" or ":h clipboard". |
]])
feed('"+p')
screen:expect([[
a^a |
- {0:~ }|
- {0:~ }|
+ {0:~ }|*2
clipboard: No provider. Try ":checkhealth" or ":h clipboard". |
]])
end)
@@ -132,22 +131,19 @@ describe('clipboard', function()
feed('yl')
screen:expect([[
^a |
- {0:~ }|
- {0:~ }|
+ {0:~ }|*2
clipboard: No provider. Try ":checkhealth" or ":h clipboard". |
]])
feed(':<CR>')
screen:expect([[
^a |
- {0:~ }|
- {0:~ }|
+ {0:~ }|*2
: |
]])
feed('p')
screen:expect([[
a^a |
- {0:~ }|
- {0:~ }|
+ {0:~ }|*2
: |
]])
end)
@@ -157,8 +153,7 @@ describe('clipboard', function()
feed_command('redir @+> | :silent echo system("cat CONTRIBUTING.md") | redir END')
screen:expect([[
^ |
- {0:~ }|
- {0:~ }|
+ {0:~ }|*2
clipboard: No provider. Try ":checkhealth" or ":h clipboard". |
]])
end)
@@ -166,12 +161,14 @@ describe('clipboard', function()
it('`:redir @+>|bogus_cmd|redir END` + invalid g:clipboard must not recurse #7184', function()
command("let g:clipboard = 'bogus'")
feed_command('redir @+> | bogus_cmd | redir END')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{3: }|
clipboard: No provider. Try ":checkhealth" or ":h clipboard". |
{1:E492: Not an editor command: bogus_cmd | redir END} |
{2:Press ENTER or type command to continue}^ |
- ]]}
+ ]],
+ }
end)
it('invalid g:clipboard shows hint if :redir is not active', function()
@@ -184,15 +181,14 @@ describe('clipboard', function()
feed_command('let @+="foo"')
screen:expect([[
^ |
- {0:~ }|
- {0:~ }|
+ {0:~ }|*2
clipboard: No provider. Try ":checkhealth" or ":h clipboard". |
]])
end)
it('valid g:clipboard', function()
-- provider#clipboard#Executable() only checks the structure.
- meths.set_var('clipboard', {
+ api.nvim_set_var('clipboard', {
['name'] = 'clippy!',
['copy'] = { ['+'] = 'any command', ['*'] = 'some other' },
['paste'] = { ['+'] = 'any command', ['*'] = 'some other' },
@@ -238,11 +234,11 @@ describe('clipboard', function()
eq('plus', eval("getreg('+')"))
command('call setreg("*", "star", "v")')
- eq({{'star'}, 'v'}, eval("g:dummy_clipboard_star"))
+ eq({ { 'star' }, 'v' }, eval('g:dummy_clipboard_star'))
command('call setreg("*", "star", "V")')
- eq({{'star', ''}, 'V'}, eval("g:dummy_clipboard_star"))
+ eq({ { 'star', '' }, 'V' }, eval('g:dummy_clipboard_star'))
command('call setreg("*", "star", "b")')
- eq({{'star', ''}, 'b'}, eval("g:dummy_clipboard_star"))
+ eq({ { 'star', '' }, 'b' }, eval('g:dummy_clipboard_star'))
end)
describe('g:clipboard[paste] Vimscript function', function()
@@ -310,43 +306,41 @@ describe('clipboard (with fake clipboard.vim)', function()
end)
it('`:redir @+>` invokes clipboard once-per-message', function()
- eq(0, eval("g:clip_called_set"))
+ eq(0, eval('g:clip_called_set'))
feed_command('redir @+> | :silent echo system("cat CONTRIBUTING.md") | redir END')
-- Assuming CONTRIBUTING.md has >100 lines.
- assert(eval("g:clip_called_set") > 100)
+ assert(eval('g:clip_called_set') > 100)
end)
it('`:redir @">` does NOT invoke clipboard', function()
-- :redir to a non-clipboard register, with `:set clipboard=unnamed` does
-- NOT propagate to the clipboard. This is consistent with Vim.
- command("set clipboard=unnamedplus")
- eq(0, eval("g:clip_called_set"))
+ command('set clipboard=unnamedplus')
+ eq(0, eval('g:clip_called_set'))
feed_command('redir @"> | :silent echo system("cat CONTRIBUTING.md") | redir END')
- eq(0, eval("g:clip_called_set"))
+ eq(0, eval('g:clip_called_set'))
end)
- it('`:redir @+>|bogus_cmd|redir END` must not recurse #7184',
- function()
+ it('`:redir @+>|bogus_cmd|redir END` must not recurse #7184', function()
local screen = Screen.new(72, 4)
screen:attach()
screen:set_default_attr_ids({
- [0] = {bold = true, foreground = Screen.colors.Blue},
- [1] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
+ [0] = { bold = true, foreground = Screen.colors.Blue },
+ [1] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
})
feed_command('redir @+> | bogus_cmd | redir END')
screen:expect([[
^ |
- {0:~ }|
- {0:~ }|
+ {0:~ }|*2
{1:E492: Not an editor command: bogus_cmd | redir END} |
]])
end)
it('has independent "* and unnamed registers by default', function()
- insert("some words")
+ insert('some words')
feed('^"*dwdw"*P')
expect('some ')
- eq({{'some '}, 'v'}, eval("g:test_clip['*']"))
+ eq({ { 'some ' }, 'v' }, eval("g:test_clip['*']"))
eq('words', eval("getreg('\"', 1)"))
end)
@@ -364,31 +358,31 @@ describe('clipboard (with fake clipboard.vim)', function()
second line
first line]])
-- linewise selection should be encoded as an extra newline
- eq({{'third line', ''}, 'V'}, eval("g:test_clip['+']"))
- eq({{'second line', ''}, 'V'}, eval("g:test_clip['*']"))
+ eq({ { 'third line', '' }, 'V' }, eval("g:test_clip['+']"))
+ eq({ { 'second line', '' }, 'V' }, eval("g:test_clip['*']"))
end)
it('handles null bytes when pasting and in getreg', function()
- insert("some\022000text\n\022000very binary\022000")
+ insert('some\022000text\n\022000very binary\022000')
feed('"*y-+"*p')
- eq({{'some\ntext', '\nvery binary\n',''}, 'V'}, eval("g:test_clip['*']"))
- expect("some\00text\n\00very binary\00\nsome\00text\n\00very binary\00")
+ eq({ { 'some\ntext', '\nvery binary\n', '' }, 'V' }, eval("g:test_clip['*']"))
+ expect('some\00text\n\00very binary\00\nsome\00text\n\00very binary\00')
-- test getreg/getregtype
eq('some\ntext\n\nvery binary\n\n', eval("getreg('*', 1)"))
- eq("V", eval("getregtype('*')"))
+ eq('V', eval("getregtype('*')"))
-- getreg supports three arguments
eq('some\ntext\n\nvery binary\n\n', eval("getreg('*', 1, 0)"))
- eq({'some\ntext', '\nvery binary\n'}, eval("getreg('*', 1, 1)"))
+ eq({ 'some\ntext', '\nvery binary\n' }, eval("getreg('*', 1, 1)"))
end)
it('autodetects regtype', function()
feed_command("let g:test_clip['*'] = ['linewise stuff','']")
feed_command("let g:test_clip['+'] = ['charwise','stuff']")
- eq("V", eval("getregtype('*')"))
- eq("v", eval("getregtype('+')"))
- insert("just some text")
+ eq('V', eval("getregtype('*')"))
+ eq('v', eval("getregtype('+')"))
+ insert('just some text')
feed('"*p"+p')
expect([[
just some text
@@ -405,12 +399,12 @@ describe('clipboard (with fake clipboard.vim)', function()
expect([[
very much
blocktext]])
- eq("\0225", eval("getregtype('*')"))
+ eq('\0225', eval("getregtype('*')"))
feed('gg4l<c-v>j4l"+ygg"+P')
expect([[
muchvery much
ktextblocktext]])
- eq({{' much', 'ktext', ''}, 'b'}, eval("g:test_clip['+']"))
+ eq({ { ' much', 'ktext', '' }, 'b' }, eval("g:test_clip['+']"))
end)
it('supports setreg()', function()
@@ -434,8 +428,8 @@ describe('clipboard (with fake clipboard.vim)', function()
it('supports :let @+ (issue #1427)', function()
feed_command("let @+ = 'some'")
feed_command("let @* = ' other stuff'")
- eq({{'some'}, 'v'}, eval("g:test_clip['+']"))
- eq({{' other stuff'}, 'v'}, eval("g:test_clip['*']"))
+ eq({ { 'some' }, 'v' }, eval("g:test_clip['+']"))
+ eq({ { ' other stuff' }, 'v' }, eval("g:test_clip['*']"))
feed('"+p"*p')
expect('some other stuff')
feed_command("let @+ .= ' more'")
@@ -446,14 +440,13 @@ describe('clipboard (with fake clipboard.vim)', function()
it('pastes unnamed register if the provider fails', function()
insert('the text')
feed('yy')
- feed_command("let g:cliperror = 1")
+ feed_command('let g:cliperror = 1')
feed('"*p')
expect([[
the text
the text]])
end)
-
describe('with clipboard=unnamed', function()
-- the basic behavior of unnamed register should be the same
-- even when handled by clipboard provider
@@ -466,20 +459,20 @@ describe('clipboard (with fake clipboard.vim)', function()
end)
it('works with pure text clipboard', function()
- feed_command("let g:cliplossy = 1")
+ feed_command('let g:cliplossy = 1')
-- expect failure for block mode
basic_register_test(true)
end)
it('links the "* and unnamed registers', function()
-- with cb=unnamed, "* and unnamed will be the same register
- insert("some words")
+ insert('some words')
feed('^"*dwdw"*P')
expect('words')
- eq({{'words'}, 'v'}, eval("g:test_clip['*']"))
+ eq({ { 'words' }, 'v' }, eval("g:test_clip['*']"))
-- "+ shouldn't have changed
- eq({''}, eval("g:test_clip['+']"))
+ eq({ '' }, eval("g:test_clip['+']"))
feed_command("let g:test_clip['*'] = ['linewise stuff','']")
feed('p')
@@ -508,23 +501,23 @@ describe('clipboard (with fake clipboard.vim)', function()
end)
it('yanks visual selection when pasting', function()
- insert("indeed visual")
+ insert('indeed visual')
feed_command("let g:test_clip['*'] = [['clipboard'], 'c']")
- feed("viwp")
- eq({{'visual'}, 'v'}, eval("g:test_clip['*']"))
- expect("indeed clipboard")
+ feed('viwp')
+ eq({ { 'visual' }, 'v' }, eval("g:test_clip['*']"))
+ expect('indeed clipboard')
-- explicit "* should do the same
feed_command("let g:test_clip['*'] = [['star'], 'c']")
feed('viw"*p')
- eq({{'clipboard'}, 'v'}, eval("g:test_clip['*']"))
- expect("indeed star")
+ eq({ { 'clipboard' }, 'v' }, eval("g:test_clip['*']"))
+ expect('indeed star')
end)
it('unnamed operations work even if the provider fails', function()
insert('the text')
feed('yy')
- feed_command("let g:cliperror = 1")
+ feed_command('let g:cliperror = 1')
feed('p')
expect([[
the text
@@ -549,10 +542,10 @@ describe('clipboard (with fake clipboard.vim)', function()
it('works in the cmdline window', function()
feed('q:itext<esc>yy')
- eq({{'text', ''}, 'V'}, eval("g:test_clip['*']"))
+ eq({ { 'text', '' }, 'V' }, eval("g:test_clip['*']"))
command("let g:test_clip['*'] = [['star'], 'c']")
feed('p')
- eq('textstar', meths.get_current_line())
+ eq('textstar', api.nvim_get_current_line())
end)
it('Block paste works correctly', function()
@@ -577,13 +570,13 @@ describe('clipboard (with fake clipboard.vim)', function()
it('links the "+ and unnamed registers', function()
eq('+', eval('v:register'))
- insert("one two")
+ insert('one two')
feed('^"+dwdw"+P')
expect('two')
- eq({{'two'}, 'v'}, eval("g:test_clip['+']"))
+ eq({ { 'two' }, 'v' }, eval("g:test_clip['+']"))
-- "* shouldn't have changed
- eq({''}, eval("g:test_clip['*']"))
+ eq({ '' }, eval("g:test_clip['*']"))
feed_command("let g:test_clip['+'] = ['three']")
feed('p')
@@ -600,14 +593,14 @@ describe('clipboard (with fake clipboard.vim)', function()
text
really unnamed
really unnamed]])
- eq({{'really unnamed', ''}, 'V'}, eval("g:test_clip['+']"))
- eq({{'really unnamed', ''}, 'V'}, eval("g:test_clip['*']"))
+ eq({ { 'really unnamed', '' }, 'V' }, eval("g:test_clip['+']"))
+ eq({ { 'really unnamed', '' }, 'V' }, eval("g:test_clip['*']"))
-- unnamedplus takes precedence when pasting
eq('+', eval('v:register'))
feed_command("let g:test_clip['+'] = ['the plus','']")
feed_command("let g:test_clip['*'] = ['the star','']")
- feed("p")
+ feed('p')
expect([[
text
really unnamed
@@ -640,14 +633,14 @@ describe('clipboard (with fake clipboard.vim)', function()
end)
it('supports :put', function()
- insert("a line")
+ insert('a line')
feed_command("let g:test_clip['*'] = ['some text']")
feed_command("let g:test_clip['+'] = ['more', 'text', '']")
- feed_command(":put *")
+ feed_command(':put *')
expect([[
a line
some text]])
- feed_command(":put +")
+ feed_command(':put +')
expect([[
a line
some text
@@ -660,11 +653,11 @@ describe('clipboard (with fake clipboard.vim)', function()
screen:attach()
feed_command("let g:test_clip['*'] = ['some', 'star data','']")
feed_command("let g:test_clip['+'] = ['such', 'plus', 'stuff']")
- feed_command("registers")
- screen:expect([[
+ feed_command('registers')
+ screen:expect(
+ [[
|
- {0:~ }|
- {0:~ }|
+ {0:~ }|*2
{4: }|
:registers |
{1:Type Name Content} |
@@ -672,12 +665,15 @@ describe('clipboard (with fake clipboard.vim)', function()
c "+ such{2:^J}plus{2:^J}stuff |
c ": let g:test_clip['+'] = ['such', 'plus', 'stuff'] |
{3:Press ENTER or type command to continue}^ |
- ]], {
- [0] = {bold = true, foreground = Screen.colors.Blue},
- [1] = {bold = true, foreground = Screen.colors.Fuchsia},
- [2] = {foreground = Screen.colors.Blue},
- [3] = {bold = true, foreground = Screen.colors.SeaGreen},
- [4] = {bold = true, reverse = true}})
+ ]],
+ {
+ [0] = { bold = true, foreground = Screen.colors.Blue },
+ [1] = { bold = true, foreground = Screen.colors.Fuchsia },
+ [2] = { foreground = Screen.colors.Blue },
+ [3] = { bold = true, foreground = Screen.colors.SeaGreen },
+ [4] = { bold = true, reverse = true },
+ }
+ )
feed('<cr>') -- clear out of Press ENTER screen
end)
@@ -694,22 +690,28 @@ describe('clipboard (with fake clipboard.vim)', function()
feed_command("let g:test_clip['*'] = ['stuff']")
feed_command('redir @*>')
-- it is made empty
- eq({{''}, 'v'}, eval("g:test_clip['*']"))
+ eq({ { '' }, 'v' }, eval("g:test_clip['*']"))
feed_command('let g:test = doesnotexist')
feed('<cr>')
- eq({{
- '',
- '',
- 'E121: Undefined variable: doesnotexist',
- }, 'v'}, eval("g:test_clip['*']"))
+ eq(
+ { {
+ '',
+ '',
+ 'E121: Undefined variable: doesnotexist',
+ }, 'v' },
+ eval("g:test_clip['*']")
+ )
feed_command(':echo "Howdy!"')
- eq({{
- '',
- '',
- 'E121: Undefined variable: doesnotexist',
- '',
- 'Howdy!',
- }, 'v'}, eval("g:test_clip['*']"))
+ eq({
+ {
+ '',
+ '',
+ 'E121: Undefined variable: doesnotexist',
+ '',
+ 'Howdy!',
+ },
+ 'v',
+ }, eval("g:test_clip['*']"))
end)
it('handles middleclick correctly', function()
@@ -717,7 +719,7 @@ describe('clipboard (with fake clipboard.vim)', function()
local screen = Screen.new(30, 5)
screen:set_default_attr_ids({
- [0] = {bold = true, foreground = Screen.colors.Blue},
+ [0] = { bold = true, foreground = Screen.colors.Blue },
})
screen:attach()
insert([[
@@ -728,8 +730,7 @@ describe('clipboard (with fake clipboard.vim)', function()
screen:expect([[
the ^source |
a target |
- {0:~ }|
- {0:~ }|
+ {0:~ }|*2
|
]])
@@ -739,7 +740,7 @@ describe('clipboard (with fake clipboard.vim)', function()
the a target]])
-- on error, fall back to unnamed register
- feed_command("let g:cliperror = 1")
+ feed_command('let g:cliperror = 1')
feed('<MiddleMouse><6,1>')
expect([[
the source
@@ -762,4 +763,11 @@ describe('clipboard (with fake clipboard.vim)', function()
expect('some some')
eq('some', eval('getreg("*")'))
end)
+
+ it('does not fall back to unnamed register with getreg() #24257', function()
+ eval('setreg("", "wrong")')
+ command('let g:cliperror = 1')
+ eq('', eval('getreg("*")'))
+ eq('', eval('getreg("+")'))
+ end)
end)
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)
diff --git a/test/functional/provider/nodejs_spec.lua b/test/functional/provider/nodejs_spec.lua
index 187f1c0412..1769239cb0 100644
--- a/test/functional/provider/nodejs_spec.lua
+++ b/test/functional/provider/nodejs_spec.lua
@@ -10,7 +10,10 @@ do
clear()
local reason = missing_provider('node')
if reason then
- pending(string.format("Missing nodejs host, or nodejs version is too old (%s)", reason), function() end)
+ pending(
+ string.format('Missing nodejs host, or nodejs version is too old (%s)', reason),
+ function() end
+ )
return
end
end
@@ -20,24 +23,31 @@ before_each(function()
end)
describe('nodejs host', function()
- teardown(function ()
+ teardown(function()
os.remove('Xtest-nodejs-hello.js')
os.remove('Xtest-nodejs-hello-plugin.js')
end)
it('works', function()
local fname = 'Xtest-nodejs-hello.js'
- write_file(fname, [[
+ write_file(
+ fname,
+ [[
const neovim = require('neovim');
const nvim = neovim.attach({socket: process.env.NVIM});
nvim.command('let g:job_out = "hello"');
- ]])
- command('let g:job_id = jobstart(["node", "'..fname..'"])')
- retry(nil, 3000, function() eq('hello', eval('g:job_out')) end)
+ ]]
+ )
+ command('let g:job_id = jobstart(["node", "' .. fname .. '"])')
+ retry(nil, 3000, function()
+ eq('hello', eval('g:job_out'))
+ end)
end)
it('plugin works', function()
local fname = 'Xtest-nodejs-hello-plugin.js'
- write_file(fname, [[
+ write_file(
+ fname,
+ [[
const neovim = require('neovim');
const nvim = neovim.attach({socket: process.env.NVIM});
@@ -49,8 +59,11 @@ describe('nodejs host', function()
const PluginClass = neovim.Plugin(TestPlugin);
const plugin = new neovim.NvimPlugin(null, PluginClass, nvim);
plugin.instance.hello();
- ]])
- command('let g:job_id = jobstart(["node", "'..fname..'"])')
- retry(nil, 3000, function() eq('hello-plugin', eval('g:job_out')) end)
+ ]]
+ )
+ command('let g:job_id = jobstart(["node", "' .. fname .. '"])')
+ retry(nil, 3000, function()
+ eq('hello-plugin', eval('g:job_out'))
+ end)
end)
end)
diff --git a/test/functional/provider/perl_spec.lua b/test/functional/provider/perl_spec.lua
index 8049f0f3e2..e9a031eb07 100644
--- a/test/functional/provider/perl_spec.lua
+++ b/test/functional/provider/perl_spec.lua
@@ -5,7 +5,7 @@ local command = helpers.command
local write_file = helpers.write_file
local eval = helpers.eval
local retry = helpers.retry
-local meths = helpers.meths
+local api = helpers.api
local insert = helpers.insert
local expect = helpers.expect
local feed = helpers.feed
@@ -14,7 +14,10 @@ do
clear()
local reason = missing_provider('perl')
if reason then
- pending(string.format("Missing perl host, or perl version is too old (%s)", reason), function() end)
+ pending(
+ string.format('Missing perl host, or perl version is too old (%s)', reason),
+ function() end
+ )
return
end
end
@@ -30,7 +33,7 @@ describe('legacy perl provider', function()
it(':perl command', function()
command('perl $vim->vars->{set_by_perl} = [100, 0];')
- eq({100, 0}, eval('g:set_by_perl'))
+ eq({ 100, 0 }, eval('g:set_by_perl'))
end)
it(':perlfile command', function()
@@ -45,7 +48,7 @@ describe('legacy perl provider', function()
-- :perldo 1; doesn't change $_,
-- the buffer should not be changed
command('normal :perldo 1;')
- eq(false, meths.get_option_value('modified', {}))
+ eq(false, api.nvim_get_option_value('modified', {}))
-- insert some text
insert('abc\ndef\nghi')
expect([[
@@ -61,19 +64,21 @@ describe('legacy perl provider', function()
end)
it('perleval()', function()
- eq({1, 2, {['key'] = 'val'}}, eval([[perleval('[1, 2, {"key" => "val"}]')]]))
+ eq({ 1, 2, { ['key'] = 'val' } }, eval([[perleval('[1, 2, {"key" => "val"}]')]]))
end)
end)
describe('perl provider', function()
- teardown(function ()
+ teardown(function()
os.remove('Xtest-perl-hello.pl')
os.remove('Xtest-perl-hello-plugin.pl')
end)
it('works', function()
local fname = 'Xtest-perl-hello.pl'
- write_file(fname, [[
+ write_file(
+ fname,
+ [[
package main;
use strict;
use warnings;
@@ -84,14 +89,19 @@ describe('perl provider', function()
my $nvim = Neovim::Ext::from_session($session);
$nvim->command('let g:job_out = "hello"');
1;
- ]])
- command('let g:job_id = jobstart(["perl", "'..fname..'"])')
- retry(nil, 3000, function() eq('hello', eval('g:job_out')) end)
+ ]]
+ )
+ command('let g:job_id = jobstart(["perl", "' .. fname .. '"])')
+ retry(nil, 3000, function()
+ eq('hello', eval('g:job_out'))
+ end)
end)
it('plugin works', function()
local fname = 'Xtest-perl-hello-plugin.pl'
- write_file(fname, [[
+ write_file(
+ fname,
+ [[
package TestPlugin;
use strict;
use warnings;
@@ -118,8 +128,11 @@ describe('perl provider', function()
my $plugin = TestPlugin->new($nvim);
$plugin->test_command();
1;
- ]])
- command('let g:job_id = jobstart(["perl", "'..fname..'"])')
- retry(nil, 3000, function() eq('hello-plugin', eval('g:job_out')) end)
+ ]]
+ )
+ command('let g:job_id = jobstart(["perl", "' .. fname .. '"])')
+ retry(nil, 3000, function()
+ eq('hello-plugin', eval('g:job_out'))
+ end)
end)
end)
diff --git a/test/functional/provider/provider_spec.lua b/test/functional/provider/provider_spec.lua
index b1c326d04c..cccd1a1184 100644
--- a/test/functional/provider/provider_spec.lua
+++ b/test/functional/provider/provider_spec.lua
@@ -1,4 +1,3 @@
-
local helpers = require('test.functional.helpers')(after_each)
local clear, eval = helpers.clear, helpers.eval
local command = helpers.command
@@ -14,14 +13,18 @@ describe('providers', function()
command('set loadplugins')
-- Using test-fixture with broken impl:
-- test/functional/fixtures/autoload/provider/python.vim
- eq('Vim:provider: python3: missing required variable g:loaded_python3_provider',
- pcall_err(eval, "has('python3')"))
+ eq(
+ 'Vim:provider: python3: missing required variable g:loaded_python3_provider',
+ pcall_err(eval, "has('python3')")
+ )
end)
it('with g:loaded_xx_provider, missing #Call()', function()
-- Using test-fixture with broken impl:
-- test/functional/fixtures/autoload/provider/ruby.vim
- eq('Vim:provider: ruby: g:loaded_ruby_provider=2 but provider#ruby#Call is not defined',
- pcall_err(eval, "has('ruby')"))
+ eq(
+ 'Vim:provider: ruby: g:loaded_ruby_provider=2 but provider#ruby#Call is not defined',
+ pcall_err(eval, "has('ruby')")
+ )
end)
end)
diff --git a/test/functional/provider/python3_spec.lua b/test/functional/provider/python3_spec.lua
index d9c44c3315..80b3552e82 100644
--- a/test/functional/provider/python3_spec.lua
+++ b/test/functional/provider/python3_spec.lua
@@ -8,19 +8,28 @@ local source = helpers.source
local missing_provider = helpers.missing_provider
local matches = helpers.matches
local pcall_err = helpers.pcall_err
-local funcs = helpers.funcs
+local fn = helpers.fn
local dedent = helpers.dedent
do
clear()
- local reason = missing_provider('python3')
+ local reason = missing_provider('python')
if reason then
it(':python3 reports E319 if provider is missing', function()
local expected = [[Vim%(py3.*%):E319: No "python3" provider found.*]]
matches(expected, pcall_err(command, 'py3 print("foo")'))
matches(expected, pcall_err(command, 'py3file foo'))
end)
- pending(string.format('Python 3 (or the pynvim module) is broken/missing (%s)', reason), function() end)
+ it('feature test when Python 3 provider is missing', function()
+ eq(0, eval('has("python3")'))
+ eq(0, eval('has("python3_compiled")'))
+ eq(0, eval('has("python3_dynamic")'))
+ eq(0, eval('has("pythonx")'))
+ end)
+ pending(
+ string.format('Python 3 (or the pynvim module) is broken/missing (%s)', reason),
+ function() end
+ )
return
end
end
@@ -35,31 +44,40 @@ describe('python3 provider', function()
eq(1, eval('has("python3")'))
eq(1, eval('has("python3_compiled")'))
eq(1, eval('has("python3_dynamic")'))
+ eq(1, eval('has("pythonx")'))
eq(0, eval('has("python3_dynamic_")'))
eq(0, eval('has("python3_")'))
end)
it('python3_execute', function()
command('python3 vim.vars["set_by_python3"] = [100, 0]')
- eq({100, 0}, eval('g:set_by_python3'))
+ eq({ 100, 0 }, eval('g:set_by_python3'))
end)
it('does not truncate error message <1 MB', function()
-- XXX: Python limits the error name to 200 chars, so this test is
-- mostly bogus.
local very_long_symbol = string.rep('a', 1200)
- feed_command(':silent! py3 print('..very_long_symbol..' b)')
+ feed_command(':silent! py3 print(' .. very_long_symbol .. ' b)')
-- Error message will contain this (last) line.
- matches(string.format(dedent([[
+ matches(
+ string.format(
+ dedent([[
^Error invoking 'python_execute' on channel 3 %%(python3%%-script%%-host%%):
File "<string>", line 1
print%%(%s b%%)
%%C*
- SyntaxError: invalid syntax%%C*$]]), very_long_symbol), eval('v:errmsg'))
+ SyntaxError: invalid syntax%%C*$]]),
+ very_long_symbol
+ ),
+ eval('v:errmsg')
+ )
end)
it('python3_execute with nested commands', function()
- command([[python3 vim.command('python3 vim.command("python3 vim.command(\'let set_by_nested_python3 = 555\')")')]])
+ command(
+ [[python3 vim.command('python3 vim.command("python3 vim.command(\'let set_by_nested_python3 = 555\')")')]]
+ )
eq(555, eval('g:set_by_nested_python3'))
end)
@@ -70,7 +88,7 @@ describe('python3 provider', function()
line3
line4]])
feed('ggjvj:python3 vim.vars["range"] = vim.current.range[:]<CR>')
- eq({'line2', 'line3'}, eval('g:range'))
+ eq({ 'line2', 'line3' }, eval('g:range'))
end)
it('py3file', function()
@@ -102,7 +120,7 @@ describe('python3 provider', function()
describe('py3eval()', function()
it('works', function()
- eq({1, 2, {['key'] = 'val'}}, funcs.py3eval('[1, 2, {"key": "val"}]'))
+ eq({ 1, 2, { ['key'] = 'val' } }, fn.py3eval('[1, 2, {"key": "val"}]'))
end)
it('errors out when given non-string', function()
@@ -131,7 +149,7 @@ describe('python3 provider', function()
command 'set pyxversion=3' -- no error
eq('Vim(set):E474: Invalid argument: pyxversion=2', pcall_err(command, 'set pyxversion=2'))
command 'set pyxversion=0' -- allowed, but equivalent to pyxversion=3
- eq(3, eval'&pyxversion')
+ eq(3, eval '&pyxversion')
end)
it('RPC call to expand("<afile>") during BufDelete #5245 #5617', function()
@@ -146,7 +164,7 @@ describe('python3 provider', function()
autocmd BufDelete * python3 foo()
autocmd BufUnload * python3 foo()]=])
feed_command("exe 'split' tempname()")
- feed_command("bwipeout!")
+ feed_command('bwipeout!')
feed_command('help help')
assert_alive()
end)
@@ -155,11 +173,11 @@ end)
describe('python2 feature test', function()
-- python2 is not supported, so correct behaviour is to return 0
it('works', function()
- eq(0, funcs.has('python2'))
- eq(0, funcs.has('python'))
- eq(0, funcs.has('python_compiled'))
- eq(0, funcs.has('python_dynamic'))
- eq(0, funcs.has('python_dynamic_'))
- eq(0, funcs.has('python_'))
+ eq(0, fn.has('python2'))
+ eq(0, fn.has('python'))
+ eq(0, fn.has('python_compiled'))
+ eq(0, fn.has('python_dynamic'))
+ eq(0, fn.has('python_dynamic_'))
+ eq(0, fn.has('python_'))
end)
end)
diff --git a/test/functional/provider/ruby_spec.lua b/test/functional/provider/ruby_spec.lua
index d3b967dfbe..9b2531a23c 100644
--- a/test/functional/provider/ruby_spec.lua
+++ b/test/functional/provider/ruby_spec.lua
@@ -8,9 +8,9 @@ local exc_exec = helpers.exc_exec
local expect = helpers.expect
local feed = helpers.feed
local feed_command = helpers.feed_command
-local funcs = helpers.funcs
+local fn = helpers.fn
local insert = helpers.insert
-local meths = helpers.meths
+local api = helpers.api
local missing_provider = helpers.missing_provider
local matches = helpers.matches
local write_file = helpers.write_file
@@ -36,19 +36,19 @@ end)
describe('ruby feature test', function()
it('works', function()
- eq(1, funcs.has('ruby'))
+ eq(1, fn.has('ruby'))
end)
end)
describe(':ruby command', function()
it('evaluates ruby', function()
command('ruby VIM.command("let g:set_by_ruby = [100, 0]")')
- eq({100, 0}, meths.get_var('set_by_ruby'))
+ eq({ 100, 0 }, api.nvim_get_var('set_by_ruby'))
end)
it('supports nesting', function()
command([[ruby VIM.command('ruby VIM.command("let set_by_nested_ruby = 555")')]])
- eq(555, meths.get_var('set_by_nested_ruby'))
+ eq(555, api.nvim_get_var('set_by_nested_ruby'))
end)
end)
@@ -57,7 +57,7 @@ describe(':rubyfile command', function()
local fname = 'rubyfile.rb'
write_file(fname, 'VIM.command("let set_by_rubyfile = 123")')
command('rubyfile rubyfile.rb')
- eq(123, meths.get_var('set_by_rubyfile'))
+ eq(123, api.nvim_get_var('set_by_rubyfile'))
os.remove(fname)
end)
end)
@@ -97,7 +97,7 @@ describe(':rubydo command', function()
it('does not modify the buffer if no changes are made', function()
command('normal :rubydo 42')
- eq(false, meths.get_option_value('modified', {}))
+ eq(false, api.nvim_get_option_value('modified', {}))
end)
end)
@@ -112,11 +112,11 @@ end)
describe('rubyeval()', function()
it('evaluates ruby objects', function()
- eq({1, 2, {['key'] = 'val'}}, funcs.rubyeval('[1, 2, {key: "val"}]'))
+ eq({ 1, 2, { ['key'] = 'val' } }, fn.rubyeval('[1, 2, {key: "val"}]'))
end)
it('returns nil for empty strings', function()
- eq(helpers.NIL, funcs.rubyeval(''))
+ eq(vim.NIL, fn.rubyeval(''))
end)
it('errors out when given non-string', function()