Patch 8.2.1440
Problem:    Debugger code insufficiently tested.
Solution:   Add a few more tests. (Yegappan Lakshmanan, closes #6700)
Files:      src/testdir/test_debugger.vim, src/testdir/test_vimscript.vim


*** ../vim-8.2.1439/src/testdir/test_debugger.vim       2020-08-12 
22:22:05.892516688 +0200
--- src/testdir/test_debugger.vim       2020-08-13 19:17:36.910546863 +0200
***************
*** 337,342 ****
--- 337,344 ----
    call StopVimInTerminal(buf)
  
    call delete('Xtest.vim')
+   %bw!
+   call assert_fails('breakadd here', 'E32:')
  endfunc
  
  func Test_Backtrace_Through_Source()
***************
*** 1037,1043 ****
      let caught_intr = 0
      debuggreedy
      call feedkeys(":call F()\<CR>quit\<CR>", "xt")
-     call F()
    catch /^Vim:Interrupt$/
      call assert_match('\.F, line 4', v:throwpoint)
      let caught_intr = 1
--- 1039,1044 ----
***************
*** 1068,1074 ****
      let caught_intr = 0
      debuggreedy
      call feedkeys(":call F()\<CR>quit\<CR>", "xt")
-     call F()
    catch /^Vim:Interrupt$/
      call assert_match('\.F, line 4', v:throwpoint)
      let caught_intr = 1
--- 1069,1074 ----
***************
*** 1097,1103 ****
      let caught_intr = 0
      debuggreedy
      call feedkeys(":call F()\<CR>quit\<CR>", "xt")
-     call F()
    catch /^Vim:Interrupt$/
      call assert_match('\.F, line 4', v:throwpoint)
      let caught_intr = 1
--- 1097,1102 ----
***************
*** 1109,1146 ****
    delfunc F
  endfunc
  
! " Test for setting a breakpoint on an :endtry where an exception is pending to
! " be processed and then quit the script. This should generate an interrupt and
! " the thrown exception should be ignored.
! func Test_breakpt_endtry_intr()
!   func F()
!     try
!       let g:Xpath ..= 'a'
!       throw "abc"
!     endtry
!     invalid_command
    endfunc
  
!   let g:Xpath = ''
!   breakadd func 4 F
!   try
!     let caught_intr = 0
!     let caught_abc = 0
!     debuggreedy
!     call feedkeys(":call F()\<CR>quit\<CR>", "xt")
!     call F()
!   catch /abc/
!     let caught_abc = 1
!   catch /^Vim:Interrupt$/
!     call assert_match('\.F, line 4', v:throwpoint)
!     let caught_intr = 1
!   endtry
    0debuggreedy
!   call assert_equal(1, caught_intr)
!   call assert_equal(0, caught_abc)
    call assert_equal('a', g:Xpath)
    breakdel *
!   delfunc F
  endfunc
  
  " vim: shiftwidth=2 sts=2 expandtab
--- 1108,1131 ----
    delfunc F
  endfunc
  
! " Test for setting a breakpoint on a script local function
! func Test_breakpt_scriptlocal_func()
!   let g:Xpath = ''
!   func s:G()
!     let g:Xpath ..= 'a'
    endfunc
  
!   let funcname = expand("<SID>") .. "G"
!   exe "breakadd func 1 " .. funcname
!   debuggreedy
!   redir => output
!   call feedkeys(":call " .. funcname .. "()\<CR>c\<CR>", "xt")
!   redir END
    0debuggreedy
!   call assert_match('Breakpoint in "' .. funcname .. '" line 1', output)
    call assert_equal('a', g:Xpath)
    breakdel *
!   exe "delfunc " .. funcname
  endfunc
  
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.1439/src/testdir/test_vimscript.vim      2020-08-11 
20:42:15.470616304 +0200
--- src/testdir/test_vimscript.vim      2020-08-13 19:17:36.910546863 +0200
***************
*** 5869,5895 ****
    call RunInNewVim(test, verify)
  endfunc
  
! " TODO: Need to interrupt the code before the endtry is invoked
! func Disable_Test_discard_exception_after_error_2()
!   let test =<< trim [CODE]
      try
        Xpath 'a'
        try
          Xpath 'b'
          throw "arrgh"
-         call interrupt()    " FIXME: throw is not interrupted here
          call assert_report('should not get here')
!       endtry
        call assert_report('should not get here')
      catch /arrgh/
        call assert_report('should not get here')
      endtry
      call assert_report('should not get here')
    [CODE]
!   let verify =<< trim [CODE]
!     call assert_equal('ab', g:Xpath)
!   [CODE]
!   call RunInNewVim(test, verify)
  endfunc
  
  
"-------------------------------------------------------------------------------
--- 5869,5907 ----
    call RunInNewVim(test, verify)
  endfunc
  
! " interrupt the code before the endtry is invoked
! func Test_discard_exception_after_error_2()
!   XpathINIT
!   let lines =<< trim [CODE]
      try
        Xpath 'a'
        try
          Xpath 'b'
          throw "arrgh"
          call assert_report('should not get here')
!       endtry                      " interrupt here
        call assert_report('should not get here')
      catch /arrgh/
        call assert_report('should not get here')
      endtry
      call assert_report('should not get here')
    [CODE]
!   call writefile(lines, 'Xscript')
! 
!   breakadd file 7 Xscript
!   try
!     let caught_intr = 0
!     debuggreedy
!     call feedkeys(":source Xscript\<CR>quit\<CR>", "xt")
!   catch /^Vim:Interrupt$/
!     call assert_match('Xscript, line 7', v:throwpoint)
!     let caught_intr = 1
!   endtry
!   0debuggreedy
!   call assert_equal(1, caught_intr)
!   call assert_equal('ab', g:Xpath)
!   breakdel *
!   call delete('Xscript')
  endfunc
  
  
"-------------------------------------------------------------------------------
***************
*** 5959,5974 ****
    call RunInNewVim(test, verify)
  endfunc
  
! " TODO: Need to interrupt the code right before the catch is invoked
! func FIXME_Test_ignore_catch_after_intr_1()
!   let test =<< trim [CODE]
      try
        try
          Xpath 'a'
          throw "arrgh"
          call assert_report('should not get here')
!       catch /.*/              " TODO: Need to interrupt before this catch is
!         call interrupt()      " invoked
          call assert_report('should not get here')
        catch /.*/
          call assert_report('should not get here')
--- 5971,5986 ----
    call RunInNewVim(test, verify)
  endfunc
  
! " interrupt right before a catch is invoked in a script
! func Test_ignore_catch_after_intr_1()
!   XpathINIT
!   let lines =<< trim [CODE]
      try
        try
          Xpath 'a'
          throw "arrgh"
          call assert_report('should not get here')
!       catch /.*/              " interrupt here
          call assert_report('should not get here')
        catch /.*/
          call assert_report('should not get here')
***************
*** 5979,6019 ****
      endtry
      call assert_report('should not get here')
    [CODE]
!   let verify =<< trim [CODE]
!     call assert_equal('a', g:Xpath)
!   [CODE]
!   call RunInNewVim(test, verify)
! endfunc
  
! " TODO: Need to interrupt the code right before the catch is invoked
! func FIXME_Test_ignore_catch_after_intr_2()
!   let test =<< trim [CODE]
!     func I()
        try
!         try
!           Xpath 'a'
!           throw "arrgh"
!           call assert_report('should not get here')
!         catch /.*/              " TODO: Need to interrupt before this catch is
!                                 " invoked
!           call interrupt()
!           call assert_report('should not get here')
!         catch /.*/
!           call assert_report('should not get here')
!         endtry
          call assert_report('should not get here')
!       catch /arrgh/
          call assert_report('should not get here')
        endtry
!     endfunc
! 
!     call I()
      call assert_report('should not get here')
!   [CODE]
!   let verify =<< trim [CODE]
!     call assert_equal('a', g:Xpath)
!   [CODE]
!   call RunInNewVim(test, verify)
  endfunc
  
  
"-------------------------------------------------------------------------------
--- 5991,6049 ----
      endtry
      call assert_report('should not get here')
    [CODE]
!   call writefile(lines, 'Xscript')
  
!   breakadd file 6 Xscript
!   try
!     let caught_intr = 0
!     debuggreedy
!     call feedkeys(":source Xscript\<CR>quit\<CR>", "xt")
!   catch /^Vim:Interrupt$/
!     call assert_match('Xscript, line 6', v:throwpoint)
!     let caught_intr = 1
!   endtry
!   0debuggreedy
!   call assert_equal(1, caught_intr)
!   call assert_equal('a', g:Xpath)
!   breakdel *
!   call delete('Xscript')
! endfunc
! 
! " interrupt right before a catch is invoked inside a function.
! func Test_ignore_catch_after_intr_2()
!   XpathINIT
!   func F()
!     try
        try
!         Xpath 'a'
!         throw "arrgh"
          call assert_report('should not get here')
!       catch /.*/              " interrupt here
!         call assert_report('should not get here')
!       catch /.*/
          call assert_report('should not get here')
        endtry
!       call assert_report('should not get here')
!     catch /arrgh/
!       call assert_report('should not get here')
!     endtry
      call assert_report('should not get here')
!   endfunc
! 
!   breakadd func 6 F
!   try
!     let caught_intr = 0
!     debuggreedy
!     call feedkeys(":call F()\<CR>quit\<CR>", "xt")
!   catch /^Vim:Interrupt$/
!     call assert_match('\.F, line 6', v:throwpoint)
!     let caught_intr = 1
!   endtry
!   0debuggreedy
!   call assert_equal(1, caught_intr)
!   call assert_equal('a', g:Xpath)
!   breakdel *
!   delfunc F
  endfunc
  
  
"-------------------------------------------------------------------------------
***************
*** 6050,6065 ****
    call RunInNewVim(test, verify)
  endfunc
  
! " TODO: Need to interrupt the code right before the finally is invoked
! func FIXME_Test_finally_after_intr()
!   let test =<< trim [CODE]
      try
        Xpath 'a'
        try
          Xpath 'b'
          throw "arrgh"
          call assert_report('should not get here')
!       finally         " TODO: Need to interrupt before the finally is invoked
          Xpath 'c'
        endtry
        call assert_report('should not get here')
--- 6080,6096 ----
    call RunInNewVim(test, verify)
  endfunc
  
! " interrupt the code right before the finally is invoked
! func Test_finally_after_intr()
!   XpathINIT
!   let lines =<< trim [CODE]
      try
        Xpath 'a'
        try
          Xpath 'b'
          throw "arrgh"
          call assert_report('should not get here')
!       finally         " interrupt here
          Xpath 'c'
        endtry
        call assert_report('should not get here')
***************
*** 6068,6077 ****
      endtry
      call assert_report('should not get here')
    [CODE]
!   let verify =<< trim [CODE]
!     call assert_equal('abc', g:Xpath)
!   [CODE]
!   call RunInNewVim(test, verify)
  endfunc
  
  
"-------------------------------------------------------------------------------
--- 6099,6120 ----
      endtry
      call assert_report('should not get here')
    [CODE]
!   call writefile(lines, 'Xscript')
! 
!   breakadd file 7 Xscript
!   try
!     let caught_intr = 0
!     debuggreedy
!     call feedkeys(":source Xscript\<CR>quit\<CR>", "xt")
!   catch /^Vim:Interrupt$/
!     call assert_match('Xscript, line 7', v:throwpoint)
!     let caught_intr = 1
!   endtry
!   0debuggreedy
!   call assert_equal(1, caught_intr)
!   call assert_equal('abc', g:Xpath)
!   breakdel *
!   call delete('Xscript')
  endfunc
  
  
"-------------------------------------------------------------------------------
*** ../vim-8.2.1439/src/version.c       2020-08-13 18:57:56.562214742 +0200
--- src/version.c       2020-08-13 19:19:08.922191333 +0200
***************
*** 756,757 ****
--- 756,759 ----
  {   /* Add new patch number below this line */
+ /**/
+     1440,
  /**/

-- 
What is the difference between a professional and an amateur?
The ark was built by an amateur; professionals gave us the Titanic.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202008131720.07DHKdF3383120%40masaka.moolenaar.net.

Raspunde prin e-mail lui