Mercurial > vim
comparison src/testdir/test_vim9_script.vim @ 32452:c1f730c2b51e v9.0.1557
patch 9.0.1557: test failures for unreachable code
Commit: https://github.com/vim/vim/commit/9d383f30bbd06552ad0bf343b2c03c6a0d1f6df2
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun May 14 21:38:12 2023 +0100
patch 9.0.1557: test failures for unreachable code
Problem: Test failures for unreachable code.
Solution: Add a test override to ignore unreachable code.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 14 May 2023 22:45:04 +0200 |
parents | 2e07c2bb2f60 |
children | db97ccaaa7c8 |
comparison
equal
deleted
inserted
replaced
32451:88d0403cc156 | 32452:c1f730c2b51e |
---|---|
488 def Test_try_catch_throw() | 488 def Test_try_catch_throw() |
489 var l = [] | 489 var l = [] |
490 try # comment | 490 try # comment |
491 add(l, '1') | 491 add(l, '1') |
492 throw 'wrong' | 492 throw 'wrong' |
493 add(l, '2') | 493 add(l, '2') # "unreachable code" |
494 catch # comment | 494 catch # comment |
495 add(l, v:exception) | 495 add(l, v:exception) |
496 finally # comment | 496 finally # comment |
497 add(l, '3') | 497 add(l, '3') |
498 endtry # comment | 498 endtry # comment |
501 l = [] | 501 l = [] |
502 try | 502 try |
503 try | 503 try |
504 add(l, '1') | 504 add(l, '1') |
505 throw 'wrong' | 505 throw 'wrong' |
506 add(l, '2') | 506 add(l, '2') # "unreachable code" |
507 catch /right/ | 507 catch /right/ |
508 add(l, v:exception) | 508 add(l, v:exception) |
509 endtry | 509 endtry |
510 catch /wrong/ | 510 catch /wrong/ |
511 add(l, 'caught') | 511 add(l, 'caught') |
752 # return in catch with finally | 752 # return in catch with finally |
753 def ReturnInCatch(): number | 753 def ReturnInCatch(): number |
754 var ret = 5 | 754 var ret = 5 |
755 try | 755 try |
756 throw 'getout' | 756 throw 'getout' |
757 return -1 | 757 return -1 # "unreachable code" |
758 catch /getout/ | 758 catch /getout/ |
759 # ret is evaluated here | 759 # ret is evaluated here |
760 return ret | 760 return ret |
761 finally | 761 finally |
762 # changing ret later has no effect | 762 # changing ret later has no effect |
1080 enddef | 1080 enddef |
1081 | 1081 |
1082 def DeletedFunc(): list<any> | 1082 def DeletedFunc(): list<any> |
1083 return ['delete me'] | 1083 return ['delete me'] |
1084 enddef | 1084 enddef |
1085 defcompile | 1085 defcompile DeletedFunc |
1086 | |
1087 call test_override('unreachable', 1) | |
1088 defcompile Test_try_catch_throw | |
1089 call test_override('unreachable', 0) | |
1090 | |
1086 delfunc DeletedFunc | 1091 delfunc DeletedFunc |
1087 | 1092 |
1088 def s:ThrowFromDef() | 1093 def s:ThrowFromDef() |
1089 throw "getout" # comment | 1094 throw "getout" # comment |
1090 enddef | 1095 enddef |
1126 | 1131 |
1127 var l = [] | 1132 var l = [] |
1128 try | 1133 try |
1129 l->add('1') | 1134 l->add('1') |
1130 throw 'bad' | 1135 throw 'bad' |
1131 l->add('x') | 1136 l->add('x') # "unreachable code" |
1132 catch /bad/ | 1137 catch /bad/ |
1133 l->add('2') | 1138 l->add('2') |
1134 try | 1139 try |
1135 l->add('3') | 1140 l->add('3') |
1136 throw 'one' | 1141 throw 'one' |
1165 catch /bar/ | 1170 catch /bar/ |
1166 l->add('4') | 1171 l->add('4') |
1167 endtry | 1172 endtry |
1168 assert_equal(['1', '2', '3', '4'], l) | 1173 assert_equal(['1', '2', '3', '4'], l) |
1169 enddef | 1174 enddef |
1175 | |
1176 call test_override('unreachable', 1) | |
1177 defcompile Test_try_catch_nested | |
1178 call test_override('unreachable', 0) | |
1170 | 1179 |
1171 def s:TryOne(): number | 1180 def s:TryOne(): number |
1172 try | 1181 try |
1173 return 0 | 1182 return 0 |
1174 catch | 1183 catch |