2016-05-10 12:34:56 -07:00
|
|
|
-- Tests for backtrace debug commands.
|
|
|
|
|
2016-04-23 16:53:11 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2018-06-21 23:18:02 -07:00
|
|
|
local command = helpers.command
|
2016-05-12 14:35:29 -07:00
|
|
|
local feed, clear = helpers.feed, helpers.clear
|
2017-04-08 14:12:26 -07:00
|
|
|
local feed_command, expect = helpers.feed_command, helpers.expect
|
2016-05-10 12:34:56 -07:00
|
|
|
|
|
|
|
describe('108', function()
|
|
|
|
before_each(clear)
|
|
|
|
|
|
|
|
it('is working', function()
|
2018-06-21 23:18:02 -07:00
|
|
|
command("set shortmess-=F")
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('lang mess C')
|
|
|
|
feed_command('function! Foo()')
|
|
|
|
feed_command(' let var1 = 1')
|
|
|
|
feed_command(' let var2 = Bar(var1) + 9')
|
|
|
|
feed_command(' return var2')
|
|
|
|
feed_command('endfunction')
|
|
|
|
feed_command('function! Bar(var)')
|
|
|
|
feed_command(' let var1 = 2 + a:var')
|
|
|
|
feed_command(' let var2 = Bazz(var1) + 4')
|
|
|
|
feed_command(' return var2')
|
|
|
|
feed_command('endfunction')
|
|
|
|
feed_command('function! Bazz(var)')
|
|
|
|
feed_command(' let var1 = 3 + a:var')
|
|
|
|
feed_command(' let var3 = "another var"')
|
|
|
|
feed_command(' return var1')
|
|
|
|
feed_command('endfunction')
|
|
|
|
feed_command('new')
|
|
|
|
feed_command('debuggreedy')
|
|
|
|
feed_command('redir => out')
|
|
|
|
feed_command('debug echo Foo()')
|
2016-05-10 12:34:56 -07:00
|
|
|
feed('step<cr>')
|
|
|
|
feed('step<cr>')
|
|
|
|
feed('step<cr>')
|
|
|
|
feed('step<cr>')
|
|
|
|
feed('step<cr>')
|
|
|
|
feed('step<cr>')
|
|
|
|
feed([[echo "- show backtrace:\n"<cr>]])
|
|
|
|
feed('backtrace<cr>')
|
|
|
|
feed([[echo "\nshow variables on different levels:\n"<cr>]])
|
|
|
|
feed('echo var1<cr>')
|
|
|
|
feed('up<cr>')
|
|
|
|
feed('back<cr>')
|
|
|
|
feed('echo var1<cr>')
|
|
|
|
feed('u<cr>')
|
|
|
|
feed('bt<cr>')
|
|
|
|
feed('echo var1<cr>')
|
|
|
|
feed([[echo "\n- undefined vars:\n"<cr>]])
|
|
|
|
feed('step<cr>')
|
|
|
|
feed('frame 2<cr>')
|
|
|
|
feed('echo "undefined var3 on former level:"<cr>')
|
|
|
|
feed('echo var3<cr>')
|
|
|
|
feed('fr 0<cr>')
|
|
|
|
feed([[echo "here var3 is defined with \"another var\":"<cr>]])
|
|
|
|
feed('echo var3<cr>')
|
|
|
|
feed('step<cr>')
|
|
|
|
feed('step<cr>')
|
|
|
|
feed('step<cr>')
|
|
|
|
feed('up<cr>')
|
|
|
|
feed([[echo "\nundefined var2 on former level"<cr>]])
|
|
|
|
feed('echo var2<cr>')
|
|
|
|
feed('down<cr>')
|
|
|
|
feed('echo "here var2 is defined with 10:"<cr>')
|
|
|
|
feed('echo var2<cr>')
|
|
|
|
feed([[echo "\n- backtrace movements:\n"<cr>]])
|
|
|
|
feed('b<cr>')
|
|
|
|
feed([[echo "\nnext command cannot go down, we are on bottom\n"<cr>]])
|
|
|
|
feed('down<cr>')
|
|
|
|
feed('up<cr>')
|
|
|
|
feed([[echo "\nnext command cannot go up, we are on top\n"<cr>]])
|
|
|
|
feed('up<cr>')
|
|
|
|
feed('b<cr>')
|
|
|
|
feed('echo "fil is not frame or finish, it is file"<cr>')
|
|
|
|
feed('fil<cr>')
|
|
|
|
feed([[echo "\n- relative backtrace movement\n"<cr>]])
|
|
|
|
feed('fr -1<cr>')
|
|
|
|
feed('frame<cr>')
|
|
|
|
feed('fra +1<cr>')
|
|
|
|
feed('fram<cr>')
|
|
|
|
feed([[echo "\n- go beyond limits does not crash\n"<cr>]])
|
|
|
|
feed('fr 100<cr>')
|
|
|
|
feed('fra<cr>')
|
|
|
|
feed('frame -40<cr>')
|
|
|
|
feed('fram<cr>')
|
|
|
|
feed([[echo "\n- final result 19:"<cr>]])
|
|
|
|
feed('cont<cr>')
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('0debuggreedy')
|
|
|
|
feed_command('redir END')
|
|
|
|
feed_command('$put =out')
|
2016-05-10 12:34:56 -07:00
|
|
|
|
|
|
|
-- Assert buffer contents.
|
|
|
|
expect([=[
|
2017-09-24 11:42:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-10 12:34:56 -07:00
|
|
|
- show backtrace:
|
2017-09-24 11:42:48 -07:00
|
|
|
|
2016-05-10 12:34:56 -07:00
|
|
|
2 function Foo[2]
|
|
|
|
1 Bar[2]
|
|
|
|
->0 Bazz
|
|
|
|
line 2: let var3 = "another var"
|
2017-09-24 11:42:48 -07:00
|
|
|
|
2016-05-10 12:34:56 -07:00
|
|
|
show variables on different levels:
|
2017-09-24 11:42:48 -07:00
|
|
|
|
2016-05-10 12:34:56 -07:00
|
|
|
6
|
|
|
|
2 function Foo[2]
|
|
|
|
->1 Bar[2]
|
|
|
|
0 Bazz
|
|
|
|
line 2: let var3 = "another var"
|
|
|
|
3
|
|
|
|
->2 function Foo[2]
|
|
|
|
1 Bar[2]
|
|
|
|
0 Bazz
|
|
|
|
line 2: let var3 = "another var"
|
|
|
|
1
|
2017-09-24 11:42:48 -07:00
|
|
|
|
2016-05-10 12:34:56 -07:00
|
|
|
- undefined vars:
|
2017-09-24 11:42:48 -07:00
|
|
|
|
2016-05-10 12:34:56 -07:00
|
|
|
undefined var3 on former level:
|
|
|
|
Error detected while processing function Foo[2]..Bar[2]..Bazz:
|
|
|
|
line 3:
|
|
|
|
E121: Undefined variable: var3
|
|
|
|
here var3 is defined with "another var":
|
|
|
|
another var
|
2017-09-24 11:42:48 -07:00
|
|
|
|
2016-05-10 12:34:56 -07:00
|
|
|
undefined var2 on former level
|
|
|
|
Error detected while processing function Foo[2]..Bar:
|
|
|
|
line 3:
|
|
|
|
E121: Undefined variable: var2
|
|
|
|
here var2 is defined with 10:
|
|
|
|
10
|
2017-09-24 11:42:48 -07:00
|
|
|
|
2016-05-10 12:34:56 -07:00
|
|
|
- backtrace movements:
|
2017-09-24 11:42:48 -07:00
|
|
|
|
2016-05-10 12:34:56 -07:00
|
|
|
1 function Foo[2]
|
|
|
|
->0 Bar
|
|
|
|
line 3: End of function
|
2017-09-24 11:42:48 -07:00
|
|
|
|
2016-05-10 12:34:56 -07:00
|
|
|
next command cannot go down, we are on bottom
|
2017-09-24 11:42:48 -07:00
|
|
|
|
2016-05-10 12:34:56 -07:00
|
|
|
frame is zero
|
2017-09-24 11:42:48 -07:00
|
|
|
|
2016-05-10 12:34:56 -07:00
|
|
|
next command cannot go up, we are on top
|
2017-09-24 11:42:48 -07:00
|
|
|
|
2016-05-10 12:34:56 -07:00
|
|
|
frame at highest level: 1
|
|
|
|
->1 function Foo[2]
|
|
|
|
0 Bar
|
|
|
|
line 3: End of function
|
|
|
|
fil is not frame or finish, it is file
|
|
|
|
"[No Name]" --No lines in buffer--
|
2017-09-24 11:42:48 -07:00
|
|
|
|
2016-05-10 12:34:56 -07:00
|
|
|
- relative backtrace movement
|
2017-09-24 11:42:48 -07:00
|
|
|
|
2016-05-10 12:34:56 -07:00
|
|
|
1 function Foo[2]
|
|
|
|
->0 Bar
|
|
|
|
line 3: End of function
|
|
|
|
->1 function Foo[2]
|
|
|
|
0 Bar
|
|
|
|
line 3: End of function
|
2017-09-24 11:42:48 -07:00
|
|
|
|
2016-05-10 12:34:56 -07:00
|
|
|
- go beyond limits does not crash
|
2017-09-24 11:42:48 -07:00
|
|
|
|
2016-05-10 12:34:56 -07:00
|
|
|
frame at highest level: 1
|
|
|
|
->1 function Foo[2]
|
|
|
|
0 Bar
|
|
|
|
line 3: End of function
|
|
|
|
frame is zero
|
|
|
|
1 function Foo[2]
|
|
|
|
->0 Bar
|
|
|
|
line 3: End of function
|
2017-09-24 11:42:48 -07:00
|
|
|
|
2016-05-10 12:34:56 -07:00
|
|
|
- final result 19:
|
|
|
|
19
|
|
|
|
]=])
|
|
|
|
end)
|
|
|
|
end)
|