Skip to content

Commit 16c6232

Browse files
committed
patch 8.2.1440: debugger code insufficiently tested
Problem: Debugger code insufficiently tested. Solution: Add a few more tests. (Yegappan Lakshmanan, closes #6700)
1 parent b96a32e commit 16c6232

3 files changed

Lines changed: 110 additions & 80 deletions

File tree

src/testdir/test_debugger.vim

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ func Test_Debugger()
337337
call StopVimInTerminal(buf)
338338

339339
call delete('Xtest.vim')
340+
%bw!
341+
call assert_fails('breakadd here', 'E32:')
340342
endfunc
341343

342344
func Test_Backtrace_Through_Source()
@@ -1037,7 +1039,6 @@ func Test_breakpt_endif_intr()
10371039
let caught_intr = 0
10381040
debuggreedy
10391041
call feedkeys(":call F()\<CR>quit\<CR>", "xt")
1040-
call F()
10411042
catch /^Vim:Interrupt$/
10421043
call assert_match('\.F, line 4', v:throwpoint)
10431044
let caught_intr = 1
@@ -1068,7 +1069,6 @@ func Test_breakpt_else_intr()
10681069
let caught_intr = 0
10691070
debuggreedy
10701071
call feedkeys(":call F()\<CR>quit\<CR>", "xt")
1071-
call F()
10721072
catch /^Vim:Interrupt$/
10731073
call assert_match('\.F, line 4', v:throwpoint)
10741074
let caught_intr = 1
@@ -1097,7 +1097,6 @@ func Test_breakpt_endwhile_intr()
10971097
let caught_intr = 0
10981098
debuggreedy
10991099
call feedkeys(":call F()\<CR>quit\<CR>", "xt")
1100-
call F()
11011100
catch /^Vim:Interrupt$/
11021101
call assert_match('\.F, line 4', v:throwpoint)
11031102
let caught_intr = 1
@@ -1109,38 +1108,24 @@ func Test_breakpt_endwhile_intr()
11091108
delfunc F
11101109
endfunc
11111110

1112-
" Test for setting a breakpoint on an :endtry where an exception is pending to
1113-
" be processed and then quit the script. This should generate an interrupt and
1114-
" the thrown exception should be ignored.
1115-
func Test_breakpt_endtry_intr()
1116-
func F()
1117-
try
1118-
let g:Xpath ..= 'a'
1119-
throw "abc"
1120-
endtry
1121-
invalid_command
1111+
" Test for setting a breakpoint on a script local function
1112+
func Test_breakpt_scriptlocal_func()
1113+
let g:Xpath = ''
1114+
func s:G()
1115+
let g:Xpath ..= 'a'
11221116
endfunc
11231117

1124-
let g:Xpath = ''
1125-
breakadd func 4 F
1126-
try
1127-
let caught_intr = 0
1128-
let caught_abc = 0
1129-
debuggreedy
1130-
call feedkeys(":call F()\<CR>quit\<CR>", "xt")
1131-
call F()
1132-
catch /abc/
1133-
let caught_abc = 1
1134-
catch /^Vim:Interrupt$/
1135-
call assert_match('\.F, line 4', v:throwpoint)
1136-
let caught_intr = 1
1137-
endtry
1118+
let funcname = expand("<SID>") .. "G"
1119+
exe "breakadd func 1 " .. funcname
1120+
debuggreedy
1121+
redir => output
1122+
call feedkeys(":call " .. funcname .. "()\<CR>c\<CR>", "xt")
1123+
redir END
11381124
0debuggreedy
1139-
call assert_equal(1, caught_intr)
1140-
call assert_equal(0, caught_abc)
1125+
call assert_match('Breakpoint in "' .. funcname .. '" line 1', output)
11411126
call assert_equal('a', g:Xpath)
11421127
breakdel *
1143-
delfunc F
1128+
exe "delfunc " .. funcname
11441129
endfunc
11451130

11461131
" vim: shiftwidth=2 sts=2 expandtab

src/testdir/test_vimscript.vim

Lines changed: 93 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5869,27 +5869,39 @@ func Test_discard_exception_after_error_1()
58695869
call RunInNewVim(test, verify)
58705870
endfunc
58715871

5872-
" TODO: Need to interrupt the code before the endtry is invoked
5873-
func Disable_Test_discard_exception_after_error_2()
5874-
let test =<< trim [CODE]
5872+
" interrupt the code before the endtry is invoked
5873+
func Test_discard_exception_after_error_2()
5874+
XpathINIT
5875+
let lines =<< trim [CODE]
58755876
try
58765877
Xpath 'a'
58775878
try
58785879
Xpath 'b'
58795880
throw "arrgh"
5880-
call interrupt() " FIXME: throw is not interrupted here
58815881
call assert_report('should not get here')
5882-
endtry
5882+
endtry " interrupt here
58835883
call assert_report('should not get here')
58845884
catch /arrgh/
58855885
call assert_report('should not get here')
58865886
endtry
58875887
call assert_report('should not get here')
58885888
[CODE]
5889-
let verify =<< trim [CODE]
5890-
call assert_equal('ab', g:Xpath)
5891-
[CODE]
5892-
call RunInNewVim(test, verify)
5889+
call writefile(lines, 'Xscript')
5890+
5891+
breakadd file 7 Xscript
5892+
try
5893+
let caught_intr = 0
5894+
debuggreedy
5895+
call feedkeys(":source Xscript\<CR>quit\<CR>", "xt")
5896+
catch /^Vim:Interrupt$/
5897+
call assert_match('Xscript, line 7', v:throwpoint)
5898+
let caught_intr = 1
5899+
endtry
5900+
0debuggreedy
5901+
call assert_equal(1, caught_intr)
5902+
call assert_equal('ab', g:Xpath)
5903+
breakdel *
5904+
call delete('Xscript')
58935905
endfunc
58945906

58955907
"-------------------------------------------------------------------------------
@@ -5959,16 +5971,16 @@ func Test_ignore_catch_after_error_2()
59595971
call RunInNewVim(test, verify)
59605972
endfunc
59615973

5962-
" TODO: Need to interrupt the code right before the catch is invoked
5963-
func FIXME_Test_ignore_catch_after_intr_1()
5964-
let test =<< trim [CODE]
5974+
" interrupt right before a catch is invoked in a script
5975+
func Test_ignore_catch_after_intr_1()
5976+
XpathINIT
5977+
let lines =<< trim [CODE]
59655978
try
59665979
try
59675980
Xpath 'a'
59685981
throw "arrgh"
59695982
call assert_report('should not get here')
5970-
catch /.*/ " TODO: Need to interrupt before this catch is
5971-
call interrupt() " invoked
5983+
catch /.*/ " interrupt here
59725984
call assert_report('should not get here')
59735985
catch /.*/
59745986
call assert_report('should not get here')
@@ -5979,41 +5991,59 @@ func FIXME_Test_ignore_catch_after_intr_1()
59795991
endtry
59805992
call assert_report('should not get here')
59815993
[CODE]
5982-
let verify =<< trim [CODE]
5983-
call assert_equal('a', g:Xpath)
5984-
[CODE]
5985-
call RunInNewVim(test, verify)
5994+
call writefile(lines, 'Xscript')
5995+
5996+
breakadd file 6 Xscript
5997+
try
5998+
let caught_intr = 0
5999+
debuggreedy
6000+
call feedkeys(":source Xscript\<CR>quit\<CR>", "xt")
6001+
catch /^Vim:Interrupt$/
6002+
call assert_match('Xscript, line 6', v:throwpoint)
6003+
let caught_intr = 1
6004+
endtry
6005+
0debuggreedy
6006+
call assert_equal(1, caught_intr)
6007+
call assert_equal('a', g:Xpath)
6008+
breakdel *
6009+
call delete('Xscript')
59866010
endfunc
59876011

5988-
" TODO: Need to interrupt the code right before the catch is invoked
5989-
func FIXME_Test_ignore_catch_after_intr_2()
5990-
let test =<< trim [CODE]
5991-
func I()
6012+
" interrupt right before a catch is invoked inside a function.
6013+
func Test_ignore_catch_after_intr_2()
6014+
XpathINIT
6015+
func F()
6016+
try
59926017
try
5993-
try
5994-
Xpath 'a'
5995-
throw "arrgh"
5996-
call assert_report('should not get here')
5997-
catch /.*/ " TODO: Need to interrupt before this catch is
5998-
" invoked
5999-
call interrupt()
6000-
call assert_report('should not get here')
6001-
catch /.*/
6002-
call assert_report('should not get here')
6003-
endtry
6018+
Xpath 'a'
6019+
throw "arrgh"
60046020
call assert_report('should not get here')
6005-
catch /arrgh/
6021+
catch /.*/ " interrupt here
6022+
call assert_report('should not get here')
6023+
catch /.*/
60066024
call assert_report('should not get here')
60076025
endtry
6008-
endfunc
6009-
6010-
call I()
6026+
call assert_report('should not get here')
6027+
catch /arrgh/
6028+
call assert_report('should not get here')
6029+
endtry
60116030
call assert_report('should not get here')
6012-
[CODE]
6013-
let verify =<< trim [CODE]
6014-
call assert_equal('a', g:Xpath)
6015-
[CODE]
6016-
call RunInNewVim(test, verify)
6031+
endfunc
6032+
6033+
breakadd func 6 F
6034+
try
6035+
let caught_intr = 0
6036+
debuggreedy
6037+
call feedkeys(":call F()\<CR>quit\<CR>", "xt")
6038+
catch /^Vim:Interrupt$/
6039+
call assert_match('\.F, line 6', v:throwpoint)
6040+
let caught_intr = 1
6041+
endtry
6042+
0debuggreedy
6043+
call assert_equal(1, caught_intr)
6044+
call assert_equal('a', g:Xpath)
6045+
breakdel *
6046+
delfunc F
60176047
endfunc
60186048

60196049
"-------------------------------------------------------------------------------
@@ -6050,16 +6080,17 @@ func Test_finally_after_error()
60506080
call RunInNewVim(test, verify)
60516081
endfunc
60526082

6053-
" TODO: Need to interrupt the code right before the finally is invoked
6054-
func FIXME_Test_finally_after_intr()
6055-
let test =<< trim [CODE]
6083+
" interrupt the code right before the finally is invoked
6084+
func Test_finally_after_intr()
6085+
XpathINIT
6086+
let lines =<< trim [CODE]
60566087
try
60576088
Xpath 'a'
60586089
try
60596090
Xpath 'b'
60606091
throw "arrgh"
60616092
call assert_report('should not get here')
6062-
finally " TODO: Need to interrupt before the finally is invoked
6093+
finally " interrupt here
60636094
Xpath 'c'
60646095
endtry
60656096
call assert_report('should not get here')
@@ -6068,10 +6099,22 @@ func FIXME_Test_finally_after_intr()
60686099
endtry
60696100
call assert_report('should not get here')
60706101
[CODE]
6071-
let verify =<< trim [CODE]
6072-
call assert_equal('abc', g:Xpath)
6073-
[CODE]
6074-
call RunInNewVim(test, verify)
6102+
call writefile(lines, 'Xscript')
6103+
6104+
breakadd file 7 Xscript
6105+
try
6106+
let caught_intr = 0
6107+
debuggreedy
6108+
call feedkeys(":source Xscript\<CR>quit\<CR>", "xt")
6109+
catch /^Vim:Interrupt$/
6110+
call assert_match('Xscript, line 7', v:throwpoint)
6111+
let caught_intr = 1
6112+
endtry
6113+
0debuggreedy
6114+
call assert_equal(1, caught_intr)
6115+
call assert_equal('abc', g:Xpath)
6116+
breakdel *
6117+
call delete('Xscript')
60756118
endfunc
60766119

60776120
"-------------------------------------------------------------------------------

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ static char *(features[]) =
754754

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
1440,
757759
/**/
758760
1439,
759761
/**/

0 commit comments

Comments
 (0)