@@ -1020,4 +1020,127 @@ func Test_debug_backtrace_level()
10201020 call delete (' Xtest2.vim' )
10211021endfunc
10221022
1023+ " Test for setting a breakpoint on a :endif where the :if condition is false
1024+ " and then quit the script. This should generate an interrupt.
1025+ func Test_breakpt_endif_intr ()
1026+ func F ()
1027+ let g: Xpath ..= ' a'
1028+ if v: false
1029+ let g: Xpath ..= ' b'
1030+ endif
1031+ invalid_command
1032+ endfunc
1033+
1034+ let g: Xpath = ' '
1035+ breakadd func 4 F
1036+ try
1037+ let caught_intr = 0
1038+ debuggreedy
1039+ call feedkeys (" :call F()\<CR> quit\<CR> " , " xt" )
1040+ call F ()
1041+ catch /^Vim:Interrupt$/
1042+ call assert_match (' \.F, line 4' , v: throwpoint )
1043+ let caught_intr = 1
1044+ endtry
1045+ 0 debuggreedy
1046+ call assert_equal (1 , caught_intr)
1047+ call assert_equal (' a' , g: Xpath )
1048+ breakdel *
1049+ delfunc F
1050+ endfunc
1051+
1052+ " Test for setting a breakpoint on a :else where the :if condition is false
1053+ " and then quit the script. This should generate an interrupt.
1054+ func Test_breakpt_else_intr ()
1055+ func F ()
1056+ let g: Xpath ..= ' a'
1057+ if v: false
1058+ let g: Xpath ..= ' b'
1059+ else
1060+ invalid_command
1061+ endif
1062+ invalid_command
1063+ endfunc
1064+
1065+ let g: Xpath = ' '
1066+ breakadd func 4 F
1067+ try
1068+ let caught_intr = 0
1069+ debuggreedy
1070+ call feedkeys (" :call F()\<CR> quit\<CR> " , " xt" )
1071+ call F ()
1072+ catch /^Vim:Interrupt$/
1073+ call assert_match (' \.F, line 4' , v: throwpoint )
1074+ let caught_intr = 1
1075+ endtry
1076+ 0 debuggreedy
1077+ call assert_equal (1 , caught_intr)
1078+ call assert_equal (' a' , g: Xpath )
1079+ breakdel *
1080+ delfunc F
1081+ endfunc
1082+
1083+ " Test for setting a breakpoint on a :endwhile where the :while condition is
1084+ " false and then quit the script. This should generate an interrupt.
1085+ func Test_breakpt_endwhile_intr ()
1086+ func F ()
1087+ let g: Xpath ..= ' a'
1088+ while v: false
1089+ let g: Xpath ..= ' b'
1090+ endwhile
1091+ invalid_command
1092+ endfunc
1093+
1094+ let g: Xpath = ' '
1095+ breakadd func 4 F
1096+ try
1097+ let caught_intr = 0
1098+ debuggreedy
1099+ call feedkeys (" :call F()\<CR> quit\<CR> " , " xt" )
1100+ call F ()
1101+ catch /^Vim:Interrupt$/
1102+ call assert_match (' \.F, line 4' , v: throwpoint )
1103+ let caught_intr = 1
1104+ endtry
1105+ 0 debuggreedy
1106+ call assert_equal (1 , caught_intr)
1107+ call assert_equal (' a' , g: Xpath )
1108+ breakdel *
1109+ delfunc F
1110+ endfunc
1111+
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
1122+ endfunc
1123+
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
1138+ 0 debuggreedy
1139+ call assert_equal (1 , caught_intr)
1140+ call assert_equal (0 , caught_abc)
1141+ call assert_equal (' a' , g: Xpath )
1142+ breakdel *
1143+ delfunc F
1144+ endfunc
1145+
10231146" vim: shiftwidth = 2 sts = 2 expandtab
0 commit comments