-- Tests for backtrace debug commands. local helpers = require('test.functional.helpers')(after_each) local command = helpers.command local feed, clear = helpers.feed, helpers.clear local feed_command, expect = helpers.feed_command, helpers.expect describe('108', function() before_each(clear) it('is working', function() command("set shortmess-=F") 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()') feed('step') feed('step') feed('step') feed('step') feed('step') feed('step') feed([[echo "- show backtrace:\n"]]) feed('backtrace') feed([[echo "\nshow variables on different levels:\n"]]) feed('echo var1') feed('up') feed('back') feed('echo var1') feed('u') feed('bt') feed('echo var1') feed([[echo "\n- undefined vars:\n"]]) feed('step') feed('frame 2') feed('echo "undefined var3 on former level:"') feed('echo var3') feed('fr 0') feed([[echo "here var3 is defined with \"another var\":"]]) feed('echo var3') feed('step') feed('step') feed('step') feed('up') feed([[echo "\nundefined var2 on former level"]]) feed('echo var2') feed('down') feed('echo "here var2 is defined with 10:"') feed('echo var2') feed([[echo "\n- backtrace movements:\n"]]) feed('b') feed([[echo "\nnext command cannot go down, we are on bottom\n"]]) feed('down') feed('up') feed([[echo "\nnext command cannot go up, we are on top\n"]]) feed('up') feed('b') feed('echo "fil is not frame or finish, it is file"') feed('fil') feed([[echo "\n- relative backtrace movement\n"]]) feed('fr -1') feed('frame') feed('fra +1') feed('fram') feed([[echo "\n- go beyond limits does not crash\n"]]) feed('fr 100') feed('fra') feed('frame -40') feed('fram') feed([[echo "\n- final result 19:"]]) feed('cont') feed_command('0debuggreedy') feed_command('redir END') feed_command('$put =out') -- Assert buffer contents. expect([=[ - show backtrace: 2 function Foo[2] 1 Bar[2] ->0 Bazz line 2: let var3 = "another var" show variables on different levels: 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 - undefined vars: 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 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 - backtrace movements: 1 function Foo[2] ->0 Bar line 3: End of function next command cannot go down, we are on bottom frame is zero next command cannot go up, we are on top 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-- - relative backtrace movement 1 function Foo[2] ->0 Bar line 3: End of function ->1 function Foo[2] 0 Bar line 3: End of function - go beyond limits does not crash 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 - final result 19: 19 ]=]) end) end)