Mercurial > vim
comparison src/testdir/test_debugger.vim @ 21777:4279767da6e8 v8.2.1438
patch 8.2.1438: missing tests for interrupting script execution from debugger
Commit: https://github.com/vim/vim/commit/7ac616cb0a52bc72b449e19cf9db93bee116c15a
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Aug 12 22:22:09 2020 +0200
patch 8.2.1438: missing tests for interrupting script execution from debugger
Problem: Missing tests for interrupting script execution from debugger.
Solution: Add tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/6697)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 12 Aug 2020 22:30:08 +0200 |
parents | 08940efa6b4e |
children | 99fe9e960207 |
comparison
equal
deleted
inserted
replaced
21776:2f8efe73cd7e | 21777:4279767da6e8 |
---|---|
1018 call StopVimInTerminal(buf) | 1018 call StopVimInTerminal(buf) |
1019 call delete('Xtest1.vim') | 1019 call delete('Xtest1.vim') |
1020 call delete('Xtest2.vim') | 1020 call delete('Xtest2.vim') |
1021 endfunc | 1021 endfunc |
1022 | 1022 |
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 0debuggreedy | |
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 0debuggreedy | |
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 0debuggreedy | |
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 0debuggreedy | |
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 | |
1023 " vim: shiftwidth=2 sts=2 expandtab | 1146 " vim: shiftwidth=2 sts=2 expandtab |