debugger_spec.lua (3410B)
1 local t = require('test.testutil') 2 local n = require('test.functional.testnvim')() 3 local Screen = require('test.functional.ui.screen') 4 5 local clear = n.clear 6 local command = n.command 7 local feed = n.feed 8 local write_file = t.write_file 9 10 before_each(clear) 11 12 describe('debugger', function() 13 local screen 14 15 before_each(function() 16 screen = Screen.new(999, 7) 17 end) 18 19 -- oldtest: Test_Debugger_breakadd_expr() 20 -- This doesn't seem to work as documented. The breakpoint is not 21 -- triggered until the next function call. 22 it(':breakadd expr', function() 23 write_file( 24 'XbreakExpr.vim', 25 [[ 26 func Foo() 27 eval 1 28 eval 2 29 endfunc 30 31 let g:Xtest_var += 1 32 call Foo() 33 let g:Xtest_var += 1 34 call Foo()]] 35 ) 36 finally(function() 37 os.remove('XbreakExpr.vim') 38 end) 39 40 command('edit XbreakExpr.vim') 41 command(':let g:Xtest_var = 10') 42 command(':breakadd expr g:Xtest_var') 43 local initial_screen = [[ 44 ^func Foo(){MATCH: *}| 45 eval 1{MATCH: *}| 46 eval 2{MATCH: *}| 47 endfunc{MATCH: *}| 48 {MATCH: *}| 49 let g:Xtest_var += 1{MATCH: *}| 50 {MATCH: *}| 51 ]] 52 screen:expect(initial_screen) 53 54 feed(':source %<CR>') 55 screen:expect([[ 56 Breakpoint in "Foo" line 1{MATCH: *}| 57 Entering Debug mode. Type "cont" to continue.{MATCH: *}| 58 Oldval = "10"{MATCH: *}| 59 Newval = "11"{MATCH: *}| 60 {MATCH:.*}XbreakExpr.vim[7]..function Foo{MATCH: *}| 61 line 1: eval 1{MATCH: *}| 62 >^{MATCH: *}| 63 ]]) 64 feed('cont<CR>') 65 screen:expect([[ 66 >cont{MATCH: *}| 67 Breakpoint in "Foo" line 1{MATCH: *}| 68 Oldval = "11"{MATCH: *}| 69 Newval = "12"{MATCH: *}| 70 {MATCH:.*}XbreakExpr.vim[9]..function Foo{MATCH: *}| 71 line 1: eval 1{MATCH: *}| 72 >^{MATCH: *}| 73 ]]) 74 feed('cont<CR>') 75 screen:expect(initial_screen) 76 77 -- Check the behavior without the g: prefix. 78 -- The Oldval and Newval don't look right here. 79 command(':breakdel *') 80 command(':breakadd expr Xtest_var') 81 feed(':source %<CR>') 82 screen:expect([[ 83 Breakpoint in "Foo" line 1{MATCH: *}| 84 Entering Debug mode. Type "cont" to continue.{MATCH: *}| 85 Oldval = "13"{MATCH: *}| 86 Newval = "(does not exist)"{MATCH: *}| 87 {MATCH:.*}XbreakExpr.vim[7]..function Foo{MATCH: *}| 88 line 1: eval 1{MATCH: *}| 89 >^{MATCH: *}| 90 ]]) 91 feed('cont<CR>') 92 screen:expect([[ 93 {MATCH:.*}XbreakExpr.vim[7]..function Foo{MATCH: *}| 94 line 1: eval 1{MATCH: *}| 95 >cont{MATCH: *}| 96 Breakpoint in "Foo" line 2{MATCH: *}| 97 {MATCH:.*}XbreakExpr.vim[7]..function Foo{MATCH: *}| 98 line 2: eval 2{MATCH: *}| 99 >^{MATCH: *}| 100 ]]) 101 feed('cont<CR>') 102 screen:expect([[ 103 >cont{MATCH: *}| 104 Breakpoint in "Foo" line 1{MATCH: *}| 105 Oldval = "14"{MATCH: *}| 106 Newval = "(does not exist)"{MATCH: *}| 107 {MATCH:.*}XbreakExpr.vim[9]..function Foo{MATCH: *}| 108 line 1: eval 1{MATCH: *}| 109 >^{MATCH: *}| 110 ]]) 111 feed('cont<CR>') 112 screen:expect([[ 113 {MATCH:.*}XbreakExpr.vim[9]..function Foo{MATCH: *}| 114 line 1: eval 1{MATCH: *}| 115 >cont{MATCH: *}| 116 Breakpoint in "Foo" line 2{MATCH: *}| 117 {MATCH:.*}XbreakExpr.vim[9]..function Foo{MATCH: *}| 118 line 2: eval 2{MATCH: *}| 119 >^{MATCH: *}| 120 ]]) 121 feed('cont<CR>') 122 screen:expect(initial_screen) 123 end) 124 end)