functests: Add test for debug.debug

This commit is contained in:
ZyX
2017-01-30 03:30:45 +03:00
parent 73d37f8b6e
commit d13fdfd446

View File

@@ -1,8 +1,10 @@
-- Test for Vim overrides of lua built-ins
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local eq = helpers.eq
local NIL = helpers.NIL
local feed = helpers.feed
local clear = helpers.clear
local funcs = helpers.funcs
local meths = helpers.meths
@@ -10,6 +12,8 @@ local command = helpers.command
local write_file = helpers.write_file
local redir_exec = helpers.redir_exec
local screen
local fname = 'Xtest-functional-lua-overrides-luafile'
before_each(clear)
@@ -63,3 +67,110 @@ describe('print', function()
eq('\nT\n', redir_exec([[lua print("T\n")]]))
end)
end)
describe('debug.debug', function()
before_each(function()
screen = Screen.new()
screen:attach()
screen:set_default_attr_ids({
[0] = {bold=true, foreground=255},
E = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
cr = {bold = true, foreground = Screen.colors.SeaGreen4},
})
end)
it('works', function()
write_file(fname, [[
function Test(a)
print(a)
debug.debug()
print(a * 100)
end
]])
eq('', redir_exec('luafile ' .. fname))
feed(':lua Test()\n')
screen:expect([[
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
nil |
lua_debug> ^ |
]])
feed('print("TEST")\n')
screen:expect([[
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
nil |
lua_debug> print("TEST") |
TEST |
lua_debug> ^ |
]])
feed('<C-c>')
screen:expect([[
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
nil |
lua_debug> print("TEST") |
TEST |
|
{E:E5105: Error while calling lua chunk: Xtest-functiona}|
{E:l-lua-overrides-luafile:4: attempt to perform arithme}|
{E:tic on local 'a' (a nil value)} |
Interrupt: {cr:Press ENTER or type command to continue}^ |
]])
feed('<C-l>:lua Test()\n')
screen:expect([[
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
nil |
lua_debug> ^ |
]])
feed('\n')
screen:expect([[
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
nil |
lua_debug> |
{E:E5105: Error while calling lua chunk: Xtest-functiona}|
{E:l-lua-overrides-luafile:4: attempt to perform arithme}|
{E:tic on local 'a' (a nil value)} |
{cr:Press ENTER or type command to continue}^ |
]])
end)
end)