From b4cbfd3c082732bf584d37671d90793fd5fa09a6 Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Tue, 10 May 2016 21:34:56 +0200 Subject: vim-patch:7.4.1102 Problem: Debugger has no stack backtrace support. Solution: Add "backtrace", "frame", "up" and "down" commands. (Alberto Fanjul, closes vim/vim#433) https://github.com/vim/vim/commit/f1f60f859cdbb2638b3662ccf7b1d179865fe7dc --- .../legacy/108_backtrace_debug_commands_spec.lua | 176 +++++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 test/functional/legacy/108_backtrace_debug_commands_spec.lua (limited to 'test') diff --git a/test/functional/legacy/108_backtrace_debug_commands_spec.lua b/test/functional/legacy/108_backtrace_debug_commands_spec.lua new file mode 100644 index 0000000000..5eb632b0e1 --- /dev/null +++ b/test/functional/legacy/108_backtrace_debug_commands_spec.lua @@ -0,0 +1,176 @@ +-- Tests for backtrace debug commands. + +local helpers = require('test.functional.helpers') +local feed, insert, source = helpers.feed, helpers.insert, helpers.source +local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect + +describe('108', function() + before_each(clear) + + it('is working', function() + execute('function! Foo()') + execute(' let var1 = 1') + execute(' let var2 = Bar(var1) + 9') + execute(' return var2') + execute('endfunction') + execute('function! Bar(var)') + execute(' let var1 = 2 + a:var') + execute(' let var2 = Bazz(var1) + 4') + execute(' return var2') + execute('endfunction') + execute('function! Bazz(var)') + execute(' let var1 = 3 + a:var') + execute(' let var3 = "another var"') + execute(' return var1') + execute('endfunction') + execute('new') + execute('debuggreedy') + execute('redir => out') + execute('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') + execute('0debuggreedy') + execute('redir END') + execute('$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 + E15: Invalid expression: 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 + E15: Invalid expression: 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) -- cgit From 5fdb6043d71bb097cd8b3579dee2f85eab31dc40 Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Tue, 10 May 2016 22:44:37 +0200 Subject: vim-patch:7.4.1110 Problem: Test 108 fails when language is French. Solution: Force English messages. (Dominique Pelle) https://github.com/vim/vim/commit/8c600052fabe4859470d9d0ba2ddd74a52ea9745 --- test/functional/legacy/108_backtrace_debug_commands_spec.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'test') diff --git a/test/functional/legacy/108_backtrace_debug_commands_spec.lua b/test/functional/legacy/108_backtrace_debug_commands_spec.lua index 5eb632b0e1..e06a117969 100644 --- a/test/functional/legacy/108_backtrace_debug_commands_spec.lua +++ b/test/functional/legacy/108_backtrace_debug_commands_spec.lua @@ -8,6 +8,7 @@ describe('108', function() before_each(clear) it('is working', function() + execute('lang mess C') execute('function! Foo()') execute(' let var1 = 1') execute(' let var2 = Bar(var1) + 9') -- cgit From dd0e8a03fcbfde3b5ef73ae1af29c9d413ebdc72 Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Thu, 12 May 2016 23:35:29 +0200 Subject: 108_backtrace_debug_comands: Fix linter errors. --- test/functional/legacy/108_backtrace_debug_commands_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/functional/legacy/108_backtrace_debug_commands_spec.lua b/test/functional/legacy/108_backtrace_debug_commands_spec.lua index e06a117969..6df645d255 100644 --- a/test/functional/legacy/108_backtrace_debug_commands_spec.lua +++ b/test/functional/legacy/108_backtrace_debug_commands_spec.lua @@ -1,8 +1,8 @@ -- Tests for backtrace debug commands. local helpers = require('test.functional.helpers') -local feed, insert, source = helpers.feed, helpers.insert, helpers.source -local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect +local feed, clear = helpers.feed, helpers.clear +local execute, expect = helpers.execute, helpers.expect describe('108', function() before_each(clear) -- cgit