aboutsummaryrefslogtreecommitdiff
path: root/test/functional/eval
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/eval')
-rw-r--r--test/functional/eval/execute_spec.lua4
-rw-r--r--test/functional/eval/input_spec.lua24
-rw-r--r--test/functional/eval/special_vars_spec.lua12
-rw-r--r--test/functional/eval/system_spec.lua40
-rw-r--r--test/functional/eval/timer_spec.lua30
5 files changed, 83 insertions, 27 deletions
diff --git a/test/functional/eval/execute_spec.lua b/test/functional/eval/execute_spec.lua
index 925e311c7d..af37ab8d55 100644
--- a/test/functional/eval/execute_spec.lua
+++ b/test/functional/eval/execute_spec.lua
@@ -161,13 +161,13 @@ describe('execute()', function()
eq('42', eval('g:mes'))
command('let g:mes = execute("echon 13", "silent")')
- screen:expect([[
+ screen:expect{grid=[[
^ |
~ |
~ |
~ |
|
- ]])
+ ]], unchanged=true}
eq('13', eval('g:mes'))
end)
diff --git a/test/functional/eval/input_spec.lua b/test/functional/eval/input_spec.lua
index 777f49462d..8c65297ac6 100644
--- a/test/functional/eval/input_spec.lua
+++ b/test/functional/eval/input_spec.lua
@@ -149,14 +149,14 @@ describe('input()', function()
{EOB:~ }|
{T:Foo>}Bar^ |
]])
- command('redraw!')
- screen:expect([[
+ command('mode')
+ screen:expect{grid=[[
|
{EOB:~ }|
{EOB:~ }|
{EOB:~ }|
{T:Foo>}Bar^ |
- ]])
+ ]], reset=true}
feed('<BS>')
screen:expect([[
|
@@ -165,14 +165,14 @@ describe('input()', function()
{EOB:~ }|
{T:Foo>}Ba^ |
]])
- command('redraw!')
- screen:expect([[
+ command('mode')
+ screen:expect{grid=[[
|
{EOB:~ }|
{EOB:~ }|
{EOB:~ }|
{T:Foo>}Ba^ |
- ]])
+ ]], reset=true}
end)
it('allows omitting everything with dictionary argument', function()
command('echohl Test')
@@ -347,14 +347,14 @@ describe('inputdialog()', function()
{EOB:~ }|
{T:Foo>}Bar^ |
]])
- command('redraw!')
- screen:expect([[
+ command('mode')
+ screen:expect{grid=[[
|
{EOB:~ }|
{EOB:~ }|
{EOB:~ }|
{T:Foo>}Bar^ |
- ]])
+ ]], reset=true}
feed('<BS>')
screen:expect([[
|
@@ -363,14 +363,14 @@ describe('inputdialog()', function()
{EOB:~ }|
{T:Foo>}Ba^ |
]])
- command('redraw!')
- screen:expect([[
+ command('mode')
+ screen:expect{grid=[[
|
{EOB:~ }|
{EOB:~ }|
{EOB:~ }|
{T:Foo>}Ba^ |
- ]])
+ ]], reset=true}
end)
it('allows omitting everything with dictionary argument', function()
command('echohl Test')
diff --git a/test/functional/eval/special_vars_spec.lua b/test/functional/eval/special_vars_spec.lua
index b5773a5529..97a12d490d 100644
--- a/test/functional/eval/special_vars_spec.lua
+++ b/test/functional/eval/special_vars_spec.lua
@@ -174,5 +174,17 @@ describe('Special values', function()
command('let count = []') -- v:count is readonly
eq(1, eval('count is# g:["count"]'))
end)
+ it('v:errmsg is distinct from errmsg', function()
+ command('let errmsg = 1')
+ eq(1, eval('errmsg is# g:["errmsg"]'))
+ end)
+ it('v:shell_error is distinct from shell_error', function()
+ command('let shell_error = []') -- v:shell_error is readonly
+ eq(1, eval('shell_error is# g:["shell_error"]'))
+ end)
+ it('v:this_session is distinct from this_session', function()
+ command('let this_session = []')
+ eq(1, eval('this_session is# g:["this_session"]'))
+ end)
end)
end)
diff --git a/test/functional/eval/system_spec.lua b/test/functional/eval/system_spec.lua
index 5e12b6a6a4..5cbf34365b 100644
--- a/test/functional/eval/system_spec.lua
+++ b/test/functional/eval/system_spec.lua
@@ -124,7 +124,6 @@ describe('system()', function()
local screen
before_each(function()
- clear()
screen = Screen.new()
screen:attach()
end)
@@ -203,6 +202,38 @@ describe('system()', function()
]])
end)
+ it('prints verbose information', function()
+ screen:try_resize(72, 14)
+ feed(':4verbose echo system("echo hi")<cr>')
+ if iswin() then
+ screen:expect{any=[[Executing command: "'cmd.exe' '/s' '/c' '"echo hi"'"]]}
+ else
+ screen:expect{any=[[Executing command: "'/[^']*sh' '%-c' 'echo hi'"]]}
+ end
+ feed('<cr>')
+ end)
+
+ it('self and total time recorded separately', function()
+ local tempfile = helpers.tmpname()
+
+ feed(':function! AlmostNoSelfTime()<cr>')
+ feed('echo system("echo hi")<cr>')
+ feed('endfunction<cr>')
+
+ feed(':profile start ' .. tempfile .. '<cr>')
+ feed(':profile func AlmostNoSelfTime<cr>')
+ feed(':call AlmostNoSelfTime()<cr>')
+ feed(':profile dump<cr>')
+
+ feed(':edit ' .. tempfile .. '<cr>')
+
+ local command_total_time = tonumber(helpers.funcs.split(helpers.funcs.getline(7))[2])
+ local command_self_time = tonumber(helpers.funcs.split(helpers.funcs.getline(7))[3])
+
+ helpers.neq(nil, command_total_time)
+ helpers.neq(nil, command_self_time)
+ end)
+
it('`yes` interrupted with CTRL-C', function()
feed(':call system("' .. (iswin()
and 'for /L %I in (1,0,2) do @echo y'
@@ -386,13 +417,12 @@ describe('systemlist()', function()
local screen
before_each(function()
- clear()
- screen = Screen.new()
- screen:attach()
+ screen = Screen.new()
+ screen:attach()
end)
after_each(function()
- screen:detach()
+ screen:detach()
end)
it('`echo` and waits for its return', function()
diff --git a/test/functional/eval/timer_spec.lua b/test/functional/eval/timer_spec.lua
index 2dd9968a01..124b9625c3 100644
--- a/test/functional/eval/timer_spec.lua
+++ b/test/functional/eval/timer_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
-local ok, feed, eq, eval = helpers.ok, helpers.feed, helpers.eq, helpers.eval
+local feed, eq, eval = helpers.feed, helpers.eq, helpers.eval
local source, nvim_async, run = helpers.source, helpers.nvim_async, helpers.run
local clear, command, funcs = helpers.clear, helpers.command, helpers.funcs
local curbufmeths = helpers.curbufmeths
@@ -72,7 +72,8 @@ describe('timers', function()
run(nil, nil, nil, 300)
feed("<cr>")
local diff = eval("g:val") - count
- ok(0 <= diff and diff <= 4)
+ assert(0 <= diff and diff <= 4,
+ 'expected (0 <= diff <= 4), got: '..tostring(diff))
end)
it('are triggered in blocking getchar() call', function()
@@ -81,7 +82,7 @@ describe('timers', function()
run(nil, nil, nil, 300)
feed("c")
local count = eval("g:val")
- ok(count >= 4)
+ assert(count >= 3, 'expected count >= 3, got: '..tostring(count))
eq(99, eval("g:c"))
end)
@@ -96,6 +97,7 @@ describe('timers', function()
source([[
func! AddItem(timer)
call nvim_buf_set_lines(0, 2, 2, v:true, ['ITEM 3'])
+ call getchar(1)
redraw
endfunc
call timer_start(200, 'AddItem')
@@ -111,7 +113,6 @@ describe('timers', function()
^ |
]])
- screen:sleep(200)
screen:expect([[
ITEM 1 |
ITEM 2 |
@@ -141,9 +142,10 @@ describe('timers', function()
local count = eval("g:val")
run(nil, nil, nil, 300)
local count2 = eval("g:val")
- ok(4 <= count and count <= 7)
-- when count is eval:ed after timer_stop this should be non-racy
eq(count, count2)
+ assert(3 <= count and count <= 7,
+ 'expected (3 <= count <= 7), got: '..tostring(count))
end)
it('can be stopped from the handler', function()
@@ -170,8 +172,8 @@ describe('timers', function()
let g:val2 += 1
endfunc
]])
- command("call timer_start(50, 'MyHandler', {'repeat': 3})")
- command("call timer_start(100, 'MyHandler2', {'repeat': 2})")
+ command("call timer_start(20, 'MyHandler', {'repeat': 3})")
+ command("call timer_start(40, 'MyHandler2', {'repeat': 2})")
run(nil, nil, nil, 300)
eq(3,eval("g:val"))
eq(2,eval("g:val2"))
@@ -197,13 +199,14 @@ describe('timers', function()
screen:attach()
screen:set_default_attr_ids( {[0] = {bold=true, foreground=255}} )
source([[
+ let g:val = 0
func! MyHandler(timer)
echo "evil"
+ let g:val = 1
endfunc
]])
command("call timer_start(100, 'MyHandler', {'repeat': 1})")
feed(":good")
- screen:sleep(200)
screen:expect([[
|
{0:~ }|
@@ -212,6 +215,17 @@ describe('timers', function()
{0:~ }|
:good^ |
]])
+
+ screen:expect{grid=[[
+ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ :good^ |
+ ]], intermediate=true, timeout=200}
+
+ eq(1, eval('g:val'))
end)
end)