aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/plugin')
-rw-r--r--test/functional/plugin/health_spec.lua154
-rw-r--r--test/functional/plugin/helpers.lua8
-rw-r--r--test/functional/plugin/man_spec.lua135
-rw-r--r--test/functional/plugin/matchparen_spec.lua13
-rw-r--r--test/functional/plugin/msgpack_spec.lua26
-rw-r--r--test/functional/plugin/shada_spec.lua111
6 files changed, 412 insertions, 35 deletions
diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua
new file mode 100644
index 0000000000..f2d5e433db
--- /dev/null
+++ b/test/functional/plugin/health_spec.lua
@@ -0,0 +1,154 @@
+local helpers = require('test.functional.helpers')(after_each)
+local Screen = require('test.functional.ui.screen')
+local plugin_helpers = require('test.functional.plugin.helpers')
+
+local clear = helpers.clear
+local curbuf_contents = helpers.curbuf_contents
+local command = helpers.command
+local eq = helpers.eq
+local getcompletion = helpers.funcs.getcompletion
+
+describe(':checkhealth', function()
+ it("detects invalid $VIMRUNTIME", function()
+ clear({
+ env={ VIMRUNTIME='bogus', },
+ })
+ local status, err = pcall(command, 'checkhealth')
+ eq(false, status)
+ eq('Invalid $VIMRUNTIME: bogus', string.match(err, 'Invalid.*'))
+ end)
+ it("detects invalid 'runtimepath'", function()
+ clear()
+ command('set runtimepath=bogus')
+ local status, err = pcall(command, 'checkhealth')
+ eq(false, status)
+ eq("Invalid 'runtimepath'", string.match(err, 'Invalid.*'))
+ end)
+ it("detects invalid $VIM", function()
+ clear()
+ -- Do this after startup, otherwise it just breaks $VIMRUNTIME.
+ command("let $VIM='zub'")
+ command("checkhealth nvim")
+ eq("ERROR: $VIM is invalid: zub",
+ string.match(curbuf_contents(), "ERROR: $VIM .* zub"))
+ end)
+ it('completions can be listed via getcompletion()', function()
+ clear()
+ eq('nvim', getcompletion('nvim', 'checkhealth')[1])
+ eq('provider', getcompletion('prov', 'checkhealth')[1])
+ end)
+end)
+
+describe('health.vim', function()
+ before_each(function()
+ plugin_helpers.reset()
+ -- Provides functions:
+ -- health#broken#check()
+ -- health#success1#check()
+ -- health#success2#check()
+ command("set runtimepath+=test/functional/fixtures")
+ end)
+
+ it("health#report_*()", function()
+ helpers.source([[
+ let g:health_report = execute([
+ \ "call health#report_start('Check Bar')",
+ \ "call health#report_ok('Bar status')",
+ \ "call health#report_ok('Other Bar status')",
+ \ "call health#report_warn('Zub')",
+ \ "call health#report_start('Baz')",
+ \ "call health#report_warn('Zim', ['suggestion 1', 'suggestion 2'])"
+ \ ])
+ ]])
+ local result = helpers.eval("g:health_report")
+
+ helpers.eq(helpers.dedent([[
+
+
+ ## Check Bar
+ - OK: Bar status
+ - OK: Other Bar status
+ - WARNING: Zub
+
+ ## Baz
+ - WARNING: Zim
+ - ADVICE:
+ - suggestion 1
+ - suggestion 2]]),
+ result)
+ end)
+
+
+ describe(":checkhealth", function()
+ it("concatenates multiple reports", function()
+ command("checkhealth success1 success2")
+ helpers.expect([[
+
+ health#success1#check
+ ========================================================================
+ ## report 1
+ - OK: everything is fine
+
+ ## report 2
+ - OK: nothing to see here
+
+ health#success2#check
+ ========================================================================
+ ## another 1
+ - OK: ok
+ ]])
+ end)
+
+ it("gracefully handles broken healthcheck", function()
+ command("checkhealth broken")
+ helpers.expect([[
+
+ health#broken#check
+ ========================================================================
+ - ERROR: Failed to run healthcheck for "broken" plugin. Exception:
+ function health#check[21]..health#broken#check, line 1
+ caused an error
+ ]])
+ end)
+
+ it("highlights OK, ERROR", function()
+ local screen = Screen.new(72, 10)
+ screen:attach()
+ screen:set_default_attr_ids({
+ Ok = { foreground = Screen.colors.Grey3, background = 6291200 },
+ Error = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
+ })
+ screen:set_default_attr_ignore({
+ Heading = { bold=true, foreground=Screen.colors.Magenta },
+ Heading2 = { foreground = Screen.colors.SlateBlue },
+ Bar = { foreground=Screen.colors.Purple },
+ Bullet = { bold=true, foreground=Screen.colors.Brown },
+ })
+ command("checkhealth foo success1")
+ command("1tabclose")
+ command("set laststatus=0")
+ screen:expect([[
+ ^ |
+ health#foo#check |
+ ========================================================================|
+ - {Error:ERROR:} No healthcheck found for "foo" plugin. |
+ |
+ health#success1#check |
+ ========================================================================|
+ ## report 1 |
+ - {Ok:OK:} everything is fine |
+ |
+ ]])
+ end)
+
+ it("gracefully handles invalid healthcheck", function()
+ command("checkhealth non_existent_healthcheck")
+ helpers.expect([[
+
+ health#non_existent_healthcheck#check
+ ========================================================================
+ - ERROR: No healthcheck found for "non_existent_healthcheck" plugin.
+ ]])
+ end)
+ end)
+end)
diff --git a/test/functional/plugin/helpers.lua b/test/functional/plugin/helpers.lua
index 7580670149..4359380bd7 100644
--- a/test/functional/plugin/helpers.lua
+++ b/test/functional/plugin/helpers.lua
@@ -10,10 +10,10 @@ local function nvim_argv(shada_file)
local rtp_value = ('\'%s/runtime\''):format(
paths.test_source_path:gsub('\'', '\'\''))
local nvim_args = {nvim_prog, '-u', 'NORC', '-i', shada_file or 'NONE', '-N',
- '--cmd', 'set shortmess+=I background=light noswapfile',
+ '--cmd', 'set shortmess+=I background=light noswapfile belloff= noshowcmd noruler',
'--cmd', 'let &runtimepath=' .. rtp_value,
'--cmd', additional_cmd,
- '--embed'}
+ '--embed', '--headless'}
if helpers.prepend_argv then
return merge_args(helpers.prepend_argv, nvim_args)
else
@@ -23,7 +23,7 @@ end
local session = nil
-local reset = function(...)
+local function reset(...)
if session then
session:close()
end
@@ -31,7 +31,7 @@ local reset = function(...)
set_session(session)
end
-local set_additional_cmd = function(s)
+local function set_additional_cmd(s)
additional_cmd = s
end
diff --git a/test/functional/plugin/man_spec.lua b/test/functional/plugin/man_spec.lua
new file mode 100644
index 0000000000..e5da7932a5
--- /dev/null
+++ b/test/functional/plugin/man_spec.lua
@@ -0,0 +1,135 @@
+local helpers = require('test.functional.helpers')(after_each)
+local plugin_helpers = require('test.functional.plugin.helpers')
+
+local Screen = require('test.functional.ui.screen')
+
+local command, eval, rawfeed = helpers.command, helpers.eval, helpers.rawfeed
+
+before_each(function()
+ plugin_helpers.reset()
+ helpers.clear()
+ command('syntax on')
+ command('set filetype=man')
+end)
+
+describe(':Man', function()
+ describe('man.lua: highlight_line()', function()
+ local screen
+
+ before_each(function()
+ command('syntax off') -- Ignore syntax groups
+ screen = Screen.new(52, 5)
+ screen:set_default_attr_ids({
+ b = { bold = true },
+ i = { italic = true },
+ u = { underline = true },
+ bi = { bold = true, italic = true },
+ biu = { bold = true, italic = true, underline = true },
+ })
+ screen:set_default_attr_ignore({
+ { foreground = Screen.colors.Blue }, -- control chars
+ { bold = true, foreground = Screen.colors.Blue } -- empty line '~'s
+ })
+ screen:attach()
+ end)
+
+ after_each(function()
+ screen:detach()
+ end)
+
+ it('clears backspaces from text and adds highlights', function()
+ rawfeed([[
+ ithis i<C-v><C-h>is<C-v><C-h>s a<C-v><C-h>a test
+ with _<C-v><C-h>o_<C-v><C-h>v_<C-v><C-h>e_<C-v><C-h>r_<C-v><C-h>s_<C-v><C-h>t_<C-v><C-h>r_<C-v><C-h>u_<C-v><C-h>c_<C-v><C-h>k text<ESC>]])
+
+ screen:expect([[
+ this i^His^Hs a^Ha test |
+ with _^Ho_^Hv_^He_^Hr_^Hs_^Ht_^Hr_^Hu_^Hc_^Hk tex^t |
+ ~ |
+ ~ |
+ |
+ ]])
+
+ eval('man#init_pager()')
+
+ screen:expect([[
+ ^this {b:is} {b:a} test |
+ with {u:overstruck} text |
+ ~ |
+ ~ |
+ |
+ ]])
+ end)
+
+ it('clears escape sequences from text and adds highlights', function()
+ rawfeed([[
+ ithis <C-v><ESC>[1mis <C-v><ESC>[3ma <C-v><ESC>[4mtest<C-v><ESC>[0m
+ <C-v><ESC>[4mwith<C-v><ESC>[24m <C-v><ESC>[4mescaped<C-v><ESC>[24m <C-v><ESC>[4mtext<C-v><ESC>[24m<ESC>]])
+
+ screen:expect([=[
+ this ^[[1mis ^[[3ma ^[[4mtest^[[0m |
+ ^[[4mwith^[[24m ^[[4mescaped^[[24m ^[[4mtext^[[24^m |
+ ~ |
+ ~ |
+ |
+ ]=])
+
+ eval('man#init_pager()')
+
+ screen:expect([[
+ ^this {b:is }{bi:a }{biu:test} |
+ {u:with} {u:escaped} {u:text} |
+ ~ |
+ ~ |
+ |
+ ]])
+ end)
+
+ it('highlights multibyte text', function()
+ rawfeed([[
+ ithis i<C-v><C-h>is<C-v><C-h>s あ<C-v><C-h>あ test
+ with _<C-v><C-h>ö_<C-v><C-h>v_<C-v><C-h>e_<C-v><C-h>r_<C-v><C-h>s_<C-v><C-h>t_<C-v><C-h>r_<C-v><C-h>u_<C-v><C-h>̃_<C-v><C-h>c_<C-v><C-h>k te<C-v><ESC>[3mxt¶<C-v><ESC>[0m<ESC>]])
+ eval('man#init_pager()')
+
+ screen:expect([[
+ ^this {b:is} {b:あ} test |
+ with {u:överstrũck} te{i:xt¶} |
+ ~ |
+ ~ |
+ |
+ ]])
+ end)
+
+ it('highlights underscores based on context', function()
+ rawfeed([[
+ i_<C-v><C-h>_b<C-v><C-h>be<C-v><C-h>eg<C-v><C-h>gi<C-v><C-h>in<C-v><C-h>ns<C-v><C-h>s
+ m<C-v><C-h>mi<C-v><C-h>id<C-v><C-h>d_<C-v><C-h>_d<C-v><C-h>dl<C-v><C-h>le<C-v><C-h>e
+ _<C-v><C-h>m_<C-v><C-h>i_<C-v><C-h>d_<C-v><C-h>__<C-v><C-h>d_<C-v><C-h>l_<C-v><C-h>e<ESC>]])
+ eval('man#init_pager()')
+
+ screen:expect([[
+ {b:^_begins} |
+ {b:mid_dle} |
+ {u:mid_dle} |
+ ~ |
+ |
+ ]])
+ end)
+
+ it('highlights various bullet formats', function()
+ rawfeed([[
+ i· ·<C-v><C-h>·
+ +<C-v><C-h>o
+ +<C-v><C-h>+<C-v><C-h>o<C-v><C-h>o double<ESC>]])
+ eval('man#init_pager()')
+
+ screen:expect([[
+ ^· {b:·} |
+ {b:·} |
+ {b:·} double |
+ ~ |
+ |
+ ]])
+ end)
+ end)
+end)
diff --git a/test/functional/plugin/matchparen_spec.lua b/test/functional/plugin/matchparen_spec.lua
index 4181f69263..51ec7e4870 100644
--- a/test/functional/plugin/matchparen_spec.lua
+++ b/test/functional/plugin/matchparen_spec.lua
@@ -2,25 +2,28 @@ local helpers = require('test.functional.helpers')(after_each)
local plugin_helpers = require('test.functional.plugin.helpers')
local Screen = require('test.functional.ui.screen')
-local execute = helpers.execute
+local command = helpers.command
local meths = helpers.meths
local feed = helpers.feed
local eq = helpers.eq
local reset = plugin_helpers.reset
-describe('matchparen', function()
+describe('matchparen', function()
local screen
before_each(function()
reset()
screen = Screen.new(20,5)
screen:attach()
- screen:set_default_attr_ignore( {{bold=true, foreground=Screen.colors.Blue}} )
+ screen:set_default_attr_ids( {
+ [0] = {bold=true, foreground=255},
+ [1] = {bold=true},
+ } )
end)
it('uses correct column after i_<Up>. Vim patch 7.4.1296', function()
- execute('set noautoindent nosmartindent nocindent laststatus=0')
+ command('set noautoindent nosmartindent nocindent laststatus=0')
eq(1, meths.get_var('loaded_matchparen'))
feed('ivoid f_test()<cr>')
feed('{<cr>')
@@ -37,7 +40,7 @@ describe('matchparen', function()
^ |
} |
{1:-- INSERT --} |
- ]], {[1] = {bold = true}})
+ ]])
end)
end)
diff --git a/test/functional/plugin/msgpack_spec.lua b/test/functional/plugin/msgpack_spec.lua
index c8da8e8f6c..2ce9974812 100644
--- a/test/functional/plugin/msgpack_spec.lua
+++ b/test/functional/plugin/msgpack_spec.lua
@@ -8,7 +8,7 @@ local NIL = helpers.NIL
local plugin_helpers = require('test.functional.plugin.helpers')
local reset = plugin_helpers.reset
-describe('In autoload/msgpack.vim', function()
+describe('autoload/msgpack.vim', function()
before_each(reset)
local sp = function(typ, val)
@@ -581,6 +581,8 @@ describe('In autoload/msgpack.vim', function()
eval_eq('binary', {'', 'abc', '', '', 'def'}, '"\\nabc\\n\\n\\ndef"')
eval_eq('binary', {''}, '""')
eval_eq('binary', {'"'}, '"\\""')
+ eval_eq('binary', {'py3 print(sys.version_info)'},
+ '"py3 print(sys.version_info)"')
end)
it('correctly loads strings', function()
@@ -595,6 +597,8 @@ describe('In autoload/msgpack.vim', function()
eval_eq('string', {'', 'abc', '', '', 'def'}, '="\\nabc\\n\\n\\ndef"')
eval_eq('string', {''}, '=""')
eval_eq('string', {'"'}, '="\\""')
+ eval_eq('string', {'py3 print(sys.version_info)'},
+ '="py3 print(sys.version_info)"')
end)
it('correctly loads ext values', function()
@@ -625,6 +629,9 @@ describe('In autoload/msgpack.vim', function()
'+(-1)"\\nabc\\n\\n\\ndef"')
eval_eq('ext', {-1, {''}}, '+(-1)""')
eval_eq('ext', {-1, {'"'}}, '+(-1)"\\""')
+
+ eval_eq('ext', {42, {'py3 print(sys.version_info)'}},
+ '+(42)"py3 print(sys.version_info)"')
end)
it('correctly loads floats', function()
@@ -652,6 +659,8 @@ describe('In autoload/msgpack.vim', function()
eval_eq('integer', ('a'):byte(), '\'a\'')
eval_eq('integer', 0xAB, '\'«\'')
+ eval_eq('integer', 0, '\'\\0\'')
+ eval_eq('integer', 10246567, '\'\\10246567\'')
end)
it('correctly loads constants', function()
@@ -674,6 +683,13 @@ describe('In autoload/msgpack.vim', function()
eval_eq('map', {{{_TYPE={}, _VAL={{1, 2}}}, {_TYPE={}, _VAL={{3, 4}}}},
{1, 2}},
'{{1: 2}: {3: 4}, 1: 2}')
+
+ eval_eq('map', {{{_TYPE={}, _VAL={
+ {{_TYPE={}, _VAL={'py3 print(sys.version_info)'}},
+ 2}}},
+ {_TYPE={}, _VAL={{3, 4}}}},
+ {1, 2}},
+ '{{"py3 print(sys.version_info)": 2}: {3: 4}, 1: 2}')
end)
it('correctly loads arrays', function()
@@ -682,6 +698,9 @@ describe('In autoload/msgpack.vim', function()
eval_eq('array', {{_TYPE={}, _VAL=1}}, '[TRUE]')
eval_eq('array', {{{_TYPE={}, _VAL={{1, 2}}}}, {_TYPE={}, _VAL={{3, 4}}}},
'[[{1: 2}], {3: 4}]')
+
+ eval_eq('array', {{_TYPE={}, _VAL={'py3 print(sys.version_info)'}}},
+ '["py3 print(sys.version_info)"]')
end)
it('errors out when needed', function()
@@ -709,6 +728,11 @@ describe('In autoload/msgpack.vim', function()
exc_exec('call msgpack#eval("0x", {})'))
eq('name-unknown:Unknown name FOO: FOO',
exc_exec('call msgpack#eval("FOO", {})'))
+
+ eq('name-unknown:Unknown name py3: py3 print(sys.version_info)',
+ exc_exec('call msgpack#eval("py3 print(sys.version_info)", {})'))
+ eq('name-unknown:Unknown name o: o',
+ exc_exec('call msgpack#eval("-info", {})'))
end)
end)
end)
diff --git a/test/functional/plugin/shada_spec.lua b/test/functional/plugin/shada_spec.lua
index e18e9ef428..1482d83ee6 100644
--- a/test/functional/plugin/shada_spec.lua
+++ b/test/functional/plugin/shada_spec.lua
@@ -3,6 +3,7 @@ local eq, nvim_eval, nvim_command, nvim, exc_exec, funcs, nvim_feed, curbuf =
helpers.eq, helpers.eval, helpers.command, helpers.nvim, helpers.exc_exec,
helpers.funcs, helpers.feed, helpers.curbuf
local neq = helpers.neq
+local read_file = helpers.read_file
local mpack = require('mpack')
@@ -43,7 +44,7 @@ local wshada, _, fname = get_shada_rw('Xtest-functional-plugin-shada.shada')
local wshada_tmp, _, fname_tmp =
get_shada_rw('Xtest-functional-plugin-shada.shada.tmp.f')
-describe('In autoload/shada.vim', function()
+describe('autoload/shada.vim', function()
local epoch = os.date('%Y-%m-%dT%H:%M:%S', 0)
before_each(function()
reset()
@@ -177,6 +178,7 @@ describe('In autoload/shada.vim', function()
' + n name \'@\'',
' + rc contents ["abc", "def"]',
' + rt type CHARACTERWISE',
+ ' + ru is_unnamed FALSE',
' + rw block width 10',
' + sb search backward TRUE',
' + sc smartcase value FALSE',
@@ -202,6 +204,7 @@ describe('In autoload/shada.vim', function()
'rt': 0,
'rw': 10,
'rc': ['abc', 'def'],
+ 'ru': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0},
'n': 0x40,
'l': 10,
'c': 0,
@@ -224,6 +227,8 @@ describe('In autoload/shada.vim', function()
.. '0 (CHARACTERWISE), 1 (LINEWISE), 2 (BLOCKWISE)',
' + rt type 10',
' # Expected boolean',
+ ' + ru is_unnamed 10',
+ ' # Expected boolean',
' + sc smartcase value NIL',
' # Expected boolean',
' + sm magic value "TRUE"',
@@ -238,6 +243,7 @@ describe('In autoload/shada.vim', function()
'sp': {'_TYPE': v:msgpack_types.string, '_VAL': ["abc"]},
'rt': 10,
'rc': '10',
+ 'ru': 10,
'n': -0x40,
'l': -10,
'c': 'abc',
@@ -607,6 +613,18 @@ describe('In autoload/shada.vim', function()
'abc',
-1,
]}] ]]):gsub('\n', ''))
+ -- Regression: NUL separator must be properly supported
+ sd2strings_eq({
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type SEARCH',
+ ' - contents ""',
+ ' - separator \'\\0\'',
+ }, ([[ [{'type': 4, 'timestamp': 0, 'data': [
+ 1,
+ '',
+ 0x0
+ ]}] ]]):gsub('\n', ''))
end)
it('works with register items', function()
@@ -622,6 +640,7 @@ describe('In autoload/shada.vim', function()
' # Required key missing: rc',
' + rw block width 0',
' + rt type CHARACTERWISE',
+ ' + ru is_unnamed FALSE',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': {
}}] ]]):gsub('\n', ''))
sd2strings_eq({
@@ -631,6 +650,7 @@ describe('In autoload/shada.vim', function()
' # Required key missing: rc',
' + rw block width 0',
' + rt type CHARACTERWISE',
+ ' + ru is_unnamed FALSE',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': {
'n': 0x20,
}}] ]]):gsub('\n', ''))
@@ -641,9 +661,11 @@ describe('In autoload/shada.vim', function()
' + rc contents ["abc", "def"]',
' + rw block width 0',
' + rt type CHARACTERWISE',
+ ' + ru is_unnamed FALSE',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': {
'n': 0x20,
'rc': ["abc", "def"],
+ 'ru': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0},
}}] ]]):gsub('\n', ''))
sd2strings_eq({
'Register with timestamp ' .. epoch .. ':',
@@ -654,9 +676,11 @@ describe('In autoload/shada.vim', function()
' | - "abcdefghijklmnopqrstuvwxyz"',
' + rw block width 0',
' + rt type CHARACTERWISE',
+ ' + ru is_unnamed TRUE',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': {
'n': 0x20,
'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],
+ 'ru': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1},
}}] ]]):gsub('\n', ''))
sd2strings_eq({
'Register with timestamp ' .. epoch .. ':',
@@ -667,6 +691,7 @@ describe('In autoload/shada.vim', function()
' | - "abcdefghijklmnopqrstuvwxyz"',
' + rw block width 0',
' + rt type CHARACTERWISE',
+ ' + ru is_unnamed FALSE',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': {
'n': 0x20,
'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],
@@ -682,6 +707,7 @@ describe('In autoload/shada.vim', function()
' | - "abcdefghijklmnopqrstuvwxyz"',
' + rw block width 5',
' + rt type LINEWISE',
+ ' + ru is_unnamed FALSE',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': {
'n': 0x20,
'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],
@@ -698,11 +724,14 @@ describe('In autoload/shada.vim', function()
' # Expected integer',
' + rw block width ""',
' + rt type BLOCKWISE',
+ ' # Expected boolean',
+ ' + ru is_unnamed ""',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': {
'n': 0x20,
'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],
'rw': "",
'rt': 2,
+ 'ru': ""
}}] ]]):gsub('\n', ''))
sd2strings_eq({
'Register with timestamp ' .. epoch .. ':',
@@ -715,11 +744,32 @@ describe('In autoload/shada.vim', function()
' # Unexpected enum value: expected one of 0 (CHARACTERWISE), '
.. '1 (LINEWISE), 2 (BLOCKWISE)',
' + rt type 10',
+ ' # Expected boolean',
+ ' + ru is_unnamed ["abc", "def"]',
}, ([[ [{'type': 5, 'timestamp': 0, 'data': {
'n': 0x20,
'rc': 0,
'rw': -1,
'rt': 10,
+ 'ru': ['abc', 'def'],
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Register with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + n name \' \'',
+ ' + rc contents @',
+ ' | - "abcdefghijklmnopqrstuvwxyz"',
+ ' | - "abcdefghijklmnopqrstuvwxyz"',
+ ' + rw block width 5',
+ ' + rt type LINEWISE',
+ ' # Expected boolean',
+ ' + ru is_unnamed 0',
+ }, ([[ [{'type': 5, 'timestamp': 0, 'data': {
+ 'n': 0x20,
+ 'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],
+ 'rw': 5,
+ 'rt': 1,
+ 'ru': 0,
}}] ]]):gsub('\n', ''))
end)
@@ -835,7 +885,7 @@ describe('In autoload/shada.vim', function()
sd2strings_eq({
'Global mark with timestamp ' .. epoch .. ':',
' % Key Description Value',
- ' + n name 20',
+ ' + n name \'\\20\'',
' + f file name "foo"',
' # Value is negative',
' + l line number -10',
@@ -850,7 +900,18 @@ describe('In autoload/shada.vim', function()
sd2strings_eq({
'Global mark with timestamp ' .. epoch .. ':',
' % Key Description Value',
- ' + n name 20',
+ ' + n name 128',
+ ' + f file name "foo"',
+ ' + l line number 1',
+ ' + c column 0',
+ }, ([[ [{'type': 7, 'timestamp': 0, 'data': {
+ 'n': 128,
+ 'f': 'foo',
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Global mark with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + n name \'\\20\'',
' + f file name "foo"',
' # Expected integer',
' + l line number "FOO"',
@@ -1121,7 +1182,7 @@ describe('In autoload/shada.vim', function()
'Local mark with timestamp ' .. epoch .. ':',
' % Key Description Value',
' + f file name "foo"',
- ' + n name 20',
+ ' + n name \'\\20\'',
' # Value is negative',
' + l line number -10',
' # Value is negative',
@@ -1136,7 +1197,7 @@ describe('In autoload/shada.vim', function()
'Local mark with timestamp ' .. epoch .. ':',
' % Key Description Value',
' + f file name "foo"',
- ' + n name 20',
+ ' + n name \'\\20\'',
' # Expected integer',
' + l line number "FOO"',
' # Expected integer',
@@ -1930,13 +1991,13 @@ describe('In autoload/shada.vim', function()
'Buffer list with timestamp ' .. epoch .. ':',
' % Key Description Value',
' # Expected binary string',
- ' + f file name 10',
+ ' + f file name \'\\10\'',
' + l line number 1',
' + c column 0',
'',
' % Key Description Value',
' # Expected binary string',
- ' + f file name 20',
+ ' + f file name \'\\20\'',
' + l line number 1',
' + c column 0',
})
@@ -1946,7 +2007,7 @@ describe('In autoload/shada.vim', function()
'Buffer list with timestamp ' .. epoch .. ':',
' % Key Description Value',
' # Expected binary string',
- ' + f file name 10',
+ ' + f file name \'\\10\'',
' + l line number 1',
' + c column 0',
'',
@@ -2014,13 +2075,14 @@ describe('In autoload/shada.vim', function()
end
it('works', function()
+ local version = nvim('get_vvar', 'version')
getbstrings_eq({{timestamp='current', type=1, value={
generator='shada.vim',
- version=704,
+ version=version,
}}}, {})
getbstrings_eq({
{timestamp='current', type=1, value={
- generator='shada.vim', version=704
+ generator='shada.vim', version=version
}},
{timestamp=0, type=1, value={generator='test'}}
}, {
@@ -2031,11 +2093,11 @@ describe('In autoload/shada.vim', function()
nvim('set_var', 'shada#add_own_header', 1)
getbstrings_eq({{timestamp='current', type=1, value={
generator='shada.vim',
- version=704,
+ version=version,
}}}, {})
getbstrings_eq({
{timestamp='current', type=1, value={
- generator='shada.vim', version=704
+ generator='shada.vim', version=version
}},
{timestamp=0, type=1, value={generator='test'}}
}, {
@@ -2075,8 +2137,9 @@ describe('In autoload/shada.vim', function()
end)
end)
-describe('In plugin/shada.vim', function()
+describe('plugin/shada.vim', function()
local epoch = os.date('%Y-%m-%dT%H:%M:%S', 0)
+ local eol = helpers.iswin() and '\r\n' or '\n'
before_each(function()
reset()
os.remove(fname)
@@ -2090,9 +2153,7 @@ describe('In plugin/shada.vim', function()
end)
local shada_eq = function(expected, fname_)
- local fd = io.open(fname_)
- local mpack_result = fd:read('*a')
- fd:close()
+ local mpack_result = read_file(fname_)
mpack_eq(expected, mpack_result)
end
@@ -2216,7 +2277,7 @@ describe('In plugin/shada.vim', function()
' + f file name ["foo"]',
' + l line number 2',
' + c column -200',
- }, '\n') .. '\n', io.open(fname .. '.tst'):read('*a'))
+ }, eol) .. eol, read_file(fname .. '.tst'))
shada_eq({{
timestamp=0,
type=8,
@@ -2263,7 +2324,7 @@ describe('In plugin/shada.vim', function()
'Jump with timestamp ' .. epoch .. ':',
' % Key________ Description Value',
' + n name \'A\'',
- }, '\n') .. '\n', io.open(fname .. '.tst'):read('*a'))
+ }, eol) .. eol, read_file(fname .. '.tst'))
shada_eq({{
timestamp=0,
type=8,
@@ -2320,7 +2381,7 @@ describe('In plugin/shada.vim', function()
' + f file name ["foo"]',
' + l line number 2',
' + c column -200',
- }, '\n') .. '\n', io.open(fname .. '.tst'):read('*a'))
+ }, eol) .. eol, read_file(fname .. '.tst'))
shada_eq({{
timestamp=0,
type=8,
@@ -2461,17 +2522,17 @@ describe('ftplugin/shada.vim', function()
nvim_command('setlocal filetype=shada')
funcs.setline(1, ' Replacement with timestamp ' .. epoch)
nvim_feed('ggA:\027')
- eq('Replacement with timestamp ' .. epoch .. ':', curbuf('get_line', 0))
+ eq('Replacement with timestamp ' .. epoch .. ':', curbuf('get_lines', 0, 1, true)[1])
nvim_feed('o-\027')
- eq(' -', curbuf('get_line', 1))
+ eq({' -'}, curbuf('get_lines', 1, 2, true))
nvim_feed('ggO+\027')
- eq('+', curbuf('get_line', 0))
+ eq({'+'}, curbuf('get_lines', 0, 1, true))
nvim_feed('GO*\027')
- eq(' *', curbuf('get_line', 2))
+ eq({' *'}, curbuf('get_lines', 2, 3, true))
nvim_feed('ggO /\027')
- eq(' /', curbuf('get_line', 0))
+ eq({' /'}, curbuf('get_lines', 0, 1, true))
nvim_feed('ggOx\027')
- eq('x', curbuf('get_line', 0))
+ eq({'x'}, curbuf('get_lines', 0, 1, true))
end)
end)