aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin
diff options
context:
space:
mode:
authorb-r-o-c-k <brockmammen@gmail.com>2018-04-14 14:17:51 -0500
committerb-r-o-c-k <brockmammen@gmail.com>2018-04-14 14:17:51 -0500
commitad999eaa775d7d4b0cacedb30c6ea3a0ee699a6f (patch)
tree92de2079e80f5f289dd87a54af123cb7d90c3058 /test/functional/plugin
parent78bc52ea5397c092d01cd08296fe1dc85d998329 (diff)
parentef4feab0e75be19c5f41d70a001db980b72090f5 (diff)
downloadrneovim-ad999eaa775d7d4b0cacedb30c6ea3a0ee699a6f.tar.gz
rneovim-ad999eaa775d7d4b0cacedb30c6ea3a0ee699a6f.tar.bz2
rneovim-ad999eaa775d7d4b0cacedb30c6ea3a0ee699a6f.zip
Merge branch 'master' into s-dash-stdin
Diffstat (limited to 'test/functional/plugin')
-rw-r--r--test/functional/plugin/health_spec.lua6
-rw-r--r--test/functional/plugin/man_spec.lua135
-rw-r--r--test/functional/plugin/msgpack_spec.lua2
-rw-r--r--test/functional/plugin/shada_spec.lua19
4 files changed, 151 insertions, 11 deletions
diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua
index 8ee0f258d0..f2d5e433db 100644
--- a/test/functional/plugin/health_spec.lua
+++ b/test/functional/plugin/health_spec.lua
@@ -6,6 +6,7 @@ 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()
@@ -31,6 +32,11 @@ describe(':checkhealth', function()
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()
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/msgpack_spec.lua b/test/functional/plugin/msgpack_spec.lua
index 5ba19708cf..4b014cbc73 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)
diff --git a/test/functional/plugin/shada_spec.lua b/test/functional/plugin/shada_spec.lua
index dbc78e63f0..5a5b4df1ef 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,9 +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')
-if helpers.pending_win32(pending) then return end
-
-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()
@@ -2138,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)
@@ -2153,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
@@ -2279,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,
@@ -2303,6 +2301,7 @@ describe('In plugin/shada.vim', function()
describe('event FileWriteCmd', function()
it('works', function()
+ if helpers.pending_win32(pending) then return end
nvim('set_var', 'shada#add_own_header', 0)
curbuf('set_lines', 0, 1, true, {
'Jump with timestamp ' .. epoch .. ':',
@@ -2326,7 +2325,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,
@@ -2383,7 +2382,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,