comparison src/testdir/test49.vim @ 303:6a21eb563c34

updated for version 7.0080
author vimboss
date Sun, 05 Jun 2005 22:01:26 +0000
parents a20218704019
children 2d8c2622e1fa
comparison
equal deleted inserted replaced
302:250611b3068d 303:6a21eb563c34
145 " Commands for recording the execution path. {{{2 145 " Commands for recording the execution path. {{{2
146 " 146 "
147 " The Xpath/Xloop commands can be used for computing the eXecution path by 147 " The Xpath/Xloop commands can be used for computing the eXecution path by
148 " adding (different) powers of 2 from those script lines, for which the 148 " adding (different) powers of 2 from those script lines, for which the
149 " execution should be checked. Xloop provides different addends for each 149 " execution should be checked. Xloop provides different addends for each
150 " execution of a loop. Permittable values are 2^0 to 2^30, so that 31 execution 150 " execution of a loop. Permitted values are 2^0 to 2^30, so that 31 execution
151 " points (multiply counted inside loops) can be tested. 151 " points (multiply counted inside loops) can be tested.
152 " 152 "
153 " Note that the arguments of the following commands can be generated 153 " Note that the arguments of the following commands can be generated
154 " automatically, see below. 154 " automatically, see below.
155 " 155 "
255 \ let @R = Xresult . "\n" | 255 \ let @R = Xresult . "\n" |
256 \ echo Xresult | 256 \ echo Xresult |
257 \ let Xtest = Xtest + 1 257 \ let Xtest = Xtest + 1
258 258
259 if exists("g:ExtraVimResult") 259 if exists("g:ExtraVimResult")
260 com! -nargs=+ Xout exec "exec \"!echo @R:'\" ." 260 com! -nargs=+ Xoutq exec "!echo @R:'" .
261 \ 'substitute(substitute("' . <args> . 261 \ substitute(substitute(<q-args>,
262 \ '", "' . "'" . '", ' . "'" . '&\\&&' . "'" 262 \ "'", '&\\&&', "g"), "\n", "@NL@", "g")
263 \ . ', "g"), "\n", "@NL@", "g")' 263 \ . "' >>" . g:ExtraVimResult
264 \ ". \"' >>\" . g:ExtraVimResult"
265 else 264 else
266 com! -nargs=+ Xout exec 'let @R = "--- Test ' . 265 com! -nargs=+ Xoutq let @R = "--- Test " .
267 \ (g:Xtest<10?" ":g:Xtest<100?" ":"") . 266 \ (g:Xtest<10?" ":g:Xtest<100?" ":"") .
268 \ g:Xtest . ": " . 267 \ g:Xtest . ": " . substitute(<q-args>,
269 \ '" . substitute("' . <args> . 268 \ "\n", "&\t ", "g") . "\n"
270 \ '", "\n", "&\t ", "g") . "\n"' 269 endif
271 endif 270 com! -nargs=+ Xout exec 'Xoutq' <args>
272 271
273 " Switch off storing of lines for undoing changes. Speeds things up a little. 272 " Switch off storing of lines for undoing changes. Speeds things up a little.
274 set undolevels=-1 273 set undolevels=-1
275 274
276 " EXTRA_VIM_STOP - do not change or remove this line. 275 " EXTRA_VIM_STOP - do not change or remove this line.
456 455
457 " Run the script in an extra vim. Switch to extra modus by passing the 456 " Run the script in an extra vim. Switch to extra modus by passing the
458 " resultfile in ExtraVimResult. Redirect messages to the file specified as 457 " resultfile in ExtraVimResult. Redirect messages to the file specified as
459 " argument if any. Use ":debuggreedy" so that the commands provided on the 458 " argument if any. Use ":debuggreedy" so that the commands provided on the
460 " pipe are consumed at the debug prompt. Use "-N" to enable command-line 459 " pipe are consumed at the debug prompt. Use "-N" to enable command-line
461 " contiunation ("C" in 'cpo'). Add "nviminfo" to 'viminfo' to avoid 460 " continuation ("C" in 'cpo'). Add "nviminfo" to 'viminfo' to avoid
462 " messing up the user's viminfo file. 461 " messing up the user's viminfo file.
463 let redirect = a:0 ? 462 let redirect = a:0 ?
464 \ " -c 'au VimLeave * redir END' -c 'redir\\! >" . a:1 . "'" : "" 463 \ " -c 'au VimLeave * redir END' -c 'redir\\! >" . a:1 . "'" : ""
465 exec "!echo '" . debug_quits . "q' | ../vim -u NONE -N -Xes" . redirect . 464 exec "!echo '" . debug_quits . "q' | ../vim -u NONE -N -Xes" . redirect .
466 \ " -c 'debuggreedy|set viminfo+=nviminfo'" . 465 \ " -c 'debuggreedy|set viminfo+=nviminfo'" .
500 endfunction 499 endfunction
501 500
502 501
503 " ExtraVimThrowpoint() - Relative throwpoint in ExtraVim script {{{2 502 " ExtraVimThrowpoint() - Relative throwpoint in ExtraVim script {{{2
504 " 503 "
505 " Evaluates v:throwpoint and returns the throwpoint relativ to the beginning of 504 " Evaluates v:throwpoint and returns the throwpoint relative to the beginning of
506 " an ExtraVim script as passed by ExtraVim() in ExtraVimBegin. 505 " an ExtraVim script as passed by ExtraVim() in ExtraVimBegin.
507 " 506 "
508 " EXTRA_VIM_START - do not change or remove this line. 507 " EXTRA_VIM_START - do not change or remove this line.
509 function! ExtraVimThrowpoint() 508 function! ExtraVimThrowpoint()
510 if !exists("g:ExtraVimBegin") 509 if !exists("g:ExtraVimBegin")
4140 4139
4141 Xcheck 756255461 4140 Xcheck 756255461
4142 4141
4143 4142
4144 "------------------------------------------------------------------------------- 4143 "-------------------------------------------------------------------------------
4145 " Test 49: Throwing exceptions accross functions {{{1 4144 " Test 49: Throwing exceptions across functions {{{1
4146 " 4145 "
4147 " When an exception is thrown but not caught inside a function, the 4146 " When an exception is thrown but not caught inside a function, the
4148 " caller is checked for a matching :catch clause. 4147 " caller is checked for a matching :catch clause.
4149 "------------------------------------------------------------------------------- 4148 "-------------------------------------------------------------------------------
4150 4149
4222 4221
4223 " Leave C, T1, and T2 for execution as scripts in the next test. 4222 " Leave C, T1, and T2 for execution as scripts in the next test.
4224 4223
4225 4224
4226 "------------------------------------------------------------------------------- 4225 "-------------------------------------------------------------------------------
4227 " Test 50: Throwing exceptions accross script files {{{1 4226 " Test 50: Throwing exceptions across script files {{{1
4228 " 4227 "
4229 " When an exception is thrown but not caught inside a script file, 4228 " When an exception is thrown but not caught inside a script file,
4230 " the sourcing script or function is checked for a matching :catch 4229 " the sourcing script or function is checked for a matching :catch
4231 " clause. 4230 " clause.
4232 " 4231 "
4291 4290
4292 Xcheck 363550045 4291 Xcheck 363550045
4293 4292
4294 4293
4295 "------------------------------------------------------------------------------- 4294 "-------------------------------------------------------------------------------
4296 " Test 51: Throwing exceptions accross :execute and user commands {{{1 4295 " Test 51: Throwing exceptions across :execute and user commands {{{1
4297 " 4296 "
4298 " A :throw command may be executed under an ":execute" or from 4297 " A :throw command may be executed under an ":execute" or from
4299 " a user command. 4298 " a user command.
4300 "------------------------------------------------------------------------------- 4299 "-------------------------------------------------------------------------------
4301 4300
5433 let exception = a:0 != 0 ? a:1 : "" " second parameter (optional) 5432 let exception = a:0 != 0 ? a:1 : "" " second parameter (optional)
5434 let emsg = a:0 != 0 ? a:2 : "" " third parameter (optional) 5433 let emsg = a:0 != 0 ? a:2 : "" " third parameter (optional)
5435 let line = a:0 != 0 ? a:3 : 0 " fourth parameter (optional) 5434 let line = a:0 != 0 ? a:3 : 0 " fourth parameter (optional)
5436 let error = 0 5435 let error = 0
5437 if emsg != "" 5436 if emsg != ""
5438 " exception is the error number, emsg the english error message text 5437 " exception is the error number, emsg the English error message text
5439 if exception !~ '^E\d\+$' 5438 if exception !~ '^E\d\+$'
5440 Xout "TODO: Add message number for:" emsg 5439 Xout "TODO: Add message number for:" emsg
5441 elseif v:lang == "C" || v:lang =~ '^[Ee]n' 5440 elseif v:lang == "C" || v:lang =~ '^[Ee]n'
5442 if exception == "E492" && emsg == "Not an editor command" 5441 if exception == "E492" && emsg == "Not an editor command"
5443 let exception = '^Vim:' . exception . ': ' . emsg 5442 let exception = '^Vim:' . exception . ': ' . emsg
6304 let v:errmsg = errmsg3 6303 let v:errmsg = errmsg3
6305 if !MSG('E492', "Not an editor command") 6304 if !MSG('E492', "Not an editor command")
6306 Xpath 4194304 " X: 0 6305 Xpath 4194304 " X: 0
6307 endif 6306 endif
6308 silent! call S(5) " X: 3 * 256 6307 silent! call S(5) " X: 3 * 256
6309 " Break out of try conds that cover ":silent!". This also 6308 " Break out of try conditionals that cover ":silent!". This also
6310 " discards the aborting error when $VIMNOERRTHROW is non-zero. 6309 " discards the aborting error when $VIMNOERRTHROW is non-zero.
6311 break 6310 break
6312 endtry 6311 endtry
6313 catch /.*/ 6312 catch /.*/
6314 Xpath 8388608 " X: 0 6313 Xpath 8388608 " X: 0
6718 6717
6719 Xcheck 5464 6718 Xcheck 5464
6720 6719
6721 6720
6722 "------------------------------------------------------------------------------- 6721 "-------------------------------------------------------------------------------
6723 " Test 67: :throw accross :call command {{{1 6722 " Test 67: :throw across :call command {{{1
6724 " 6723 "
6725 " On a call command, an exception might be thrown when evaluating the 6724 " On a call command, an exception might be thrown when evaluating the
6726 " function name, during evaluation of the arguments, or when the 6725 " function name, during evaluation of the arguments, or when the
6727 " function is being executed. The exception can be caught by the 6726 " function is being executed. The exception can be caught by the
6728 " caller. 6727 " caller.
6730 6729
6731 XpathINIT 6730 XpathINIT
6732 6731
6733 function! THROW(x, n) 6732 function! THROW(x, n)
6734 if a:n == 1 6733 if a:n == 1
6735 Xpath 1 " X: 1 6734 Xpath 1 " X: 1
6736 elseif a:n == 2 6735 elseif a:n == 2
6737 Xpath 2 " X: 2 6736 Xpath 2 " X: 2
6738 elseif a:n == 3 6737 elseif a:n == 3
6739 Xpath 4 " X: 4 6738 Xpath 4 " X: 4
6740 endif 6739 endif
6741 throw a:x 6740 throw a:x
6742 endfunction 6741 endfunction
6743 6742
6744 function! NAME(x, n) 6743 function! NAME(x, n)
6745 if a:n == 1 6744 if a:n == 1
6746 Xpath 8 " X: 0 6745 Xpath 8 " X: 0
6747 elseif a:n == 2 6746 elseif a:n == 2
6748 Xpath 16 " X: 16 6747 Xpath 16 " X: 16
6749 elseif a:n == 3 6748 elseif a:n == 3
6750 Xpath 32 " X: 32 6749 Xpath 32 " X: 32
6751 elseif a:n == 4 6750 elseif a:n == 4
6752 Xpath 64 " X: 64 6751 Xpath 64 " X: 64
6753 endif 6752 endif
6754 return a:x 6753 return a:x
6755 endfunction 6754 endfunction
6756 6755
6757 function! ARG(x, n) 6756 function! ARG(x, n)
6758 if a:n == 1 6757 if a:n == 1
6759 Xpath 128 " X: 0 6758 Xpath 128 " X: 0
6760 elseif a:n == 2 6759 elseif a:n == 2
6761 Xpath 256 " X: 0 6760 Xpath 256 " X: 0
6762 elseif a:n == 3 6761 elseif a:n == 3
6763 Xpath 512 " X: 512 6762 Xpath 512 " X: 512
6764 elseif a:n == 4 6763 elseif a:n == 4
6765 Xpath 1024 " X: 1024 6764 Xpath 1024 " X: 1024
6766 endif 6765 endif
6767 return a:x 6766 return a:x
6768 endfunction 6767 endfunction
6769 6768
6770 function! F(x, n) 6769 function! F(x, n)
6771 if a:n == 2 6770 if a:n == 2
6772 Xpath 2048 " X: 0 6771 Xpath 2048 " X: 0
6773 elseif a:n == 4 6772 elseif a:n == 4
6774 Xpath 4096 " X: 4096 6773 Xpath 4096 " X: 4096
6775 endif 6774 endif
6776 endfunction 6775 endfunction
6777 6776
6778 try 6777 while 1
6779 6778 try
6780 try 6779 let error = 0
6781 Xpath 8192 " X: 8192 6780 let v:errmsg = ""
6782 call {NAME(THROW("name", 1), 1)}(ARG(4711, 1), 1) 6781
6783 Xpath 16384 " X: 0 6782 while 1
6784 catch /^name$/ 6783 try
6785 Xpath 32768 " X: 32768 6784 Xpath 8192 " X: 8192
6785 call {NAME(THROW("name", 1), 1)}(ARG(4711, 1), 1)
6786 Xpath 16384 " X: 0
6787 catch /^name$/
6788 Xpath 32768 " X: 32768
6789 catch /.*/
6790 let error = 1
6791 Xout "1:" v:exception "in" v:throwpoint
6792 finally
6793 if !error && $VIMNOERRTHROW && v:errmsg != ""
6794 let error = 1
6795 Xout "1:" v:errmsg
6796 endif
6797 if error
6798 Xpath 65536 " X: 0
6799 endif
6800 let error = 0
6801 let v:errmsg = ""
6802 break " discard error for $VIMNOERRTHROW
6803 endtry
6804 endwhile
6805
6806 while 1
6807 try
6808 Xpath 131072 " X: 131072
6809 call {NAME("F", 2)}(ARG(THROW("arg", 2), 2), 2)
6810 Xpath 262144 " X: 0
6811 catch /^arg$/
6812 Xpath 524288 " X: 524288
6813 catch /.*/
6814 let error = 1
6815 Xout "2:" v:exception "in" v:throwpoint
6816 finally
6817 if !error && $VIMNOERRTHROW && v:errmsg != ""
6818 let error = 1
6819 Xout "2:" v:errmsg
6820 endif
6821 if error
6822 Xpath 1048576 " X: 0
6823 endif
6824 let error = 0
6825 let v:errmsg = ""
6826 break " discard error for $VIMNOERRTHROW
6827 endtry
6828 endwhile
6829
6830 while 1
6831 try
6832 Xpath 2097152 " X: 2097152
6833 call {NAME("THROW", 3)}(ARG("call", 3), 3)
6834 Xpath 4194304 " X: 0
6835 catch /^call$/
6836 Xpath 8388608 " X: 8388608
6837 catch /^0$/ " default return value
6838 Xpath 16777216 " X: 0
6839 Xout "3:" v:throwpoint
6840 catch /.*/
6841 let error = 1
6842 Xout "3:" v:exception "in" v:throwpoint
6843 finally
6844 if !error && $VIMNOERRTHROW && v:errmsg != ""
6845 let error = 1
6846 Xout "3:" v:errmsg
6847 endif
6848 if error
6849 Xpath 33554432 " X: 0
6850 endif
6851 let error = 0
6852 let v:errmsg = ""
6853 break " discard error for $VIMNOERRTHROW
6854 endtry
6855 endwhile
6856
6857 while 1
6858 try
6859 Xpath 67108864 " X: 67108864
6860 call {NAME("F", 4)}(ARG(4711, 4), 4)
6861 Xpath 134217728 " X: 134217728
6862 catch /.*/
6863 let error = 1
6864 Xout "4:" v:exception "in" v:throwpoint
6865 finally
6866 if !error && $VIMNOERRTHROW && v:errmsg != ""
6867 let error = 1
6868 Xout "4:" v:errmsg
6869 endif
6870 if error
6871 Xpath 268435456 " X: 0
6872 endif
6873 let error = 0
6874 let v:errmsg = ""
6875 break " discard error for $VIMNOERRTHROW
6876 endtry
6877 endwhile
6878
6879 catch /^0$/ " default return value
6880 Xpath 536870912 " X: 0
6881 Xout v:throwpoint
6786 catch /.*/ 6882 catch /.*/
6787 Xpath 65536 " X: 0 6883 let error = 1
6788 Xout "1:" v:exception "in" v:throwpoint 6884 Xout v:exception "in" v:throwpoint
6789 endtry 6885 finally
6790 6886 if !error && $VIMNOERRTHROW && v:errmsg != ""
6791 try 6887 let error = 1
6792 Xpath 131072 " X: 131072 6888 Xout v:errmsg
6793 call {NAME("F", 2)}(ARG(THROW("arg", 2), 2), 2) 6889 endif
6794 Xpath 262144 " X: 0 6890 if error
6795 catch /^arg$/ 6891 Xpath 1073741824 " X: 0
6796 Xpath 524288 " X: 524288 6892 endif
6797 catch /.*/ 6893 break " discard error for $VIMNOERRTHROW
6798 Xpath 1048576 " X: 0 6894 endtry
6799 Xout "2:" v:exception "in" v:throwpoint 6895 endwhile
6800 endtry 6896
6801 6897 unlet error
6802 try
6803 Xpath 2097152 " X: 2097152
6804 call {NAME("THROW", 3)}(ARG("call", 3), 3)
6805 Xpath 4194304 " X: 0
6806 catch /^call$/
6807 Xpath 8388608 " X: 8388608
6808 catch /^0$/ " default return value
6809 Xpath 16777216 " X: 0
6810 Xout "3:" v:throwpoint
6811 catch /.*/
6812 Xpath 33554432 " X: 0
6813 Xout "3:" v:exception "in" v:throwpoint
6814 endtry
6815
6816 try
6817 Xpath 67108864 " X: 67108864
6818 call {NAME("F", 4)}(ARG(4711, 4), 4)
6819 Xpath 134217728 " X: 134217728
6820 catch /.*/
6821 Xpath 268435456 " X: 0
6822 Xout "4:" v:exception "in" v:throwpoint
6823 endtry
6824
6825 catch /^0$/ " default return value
6826 Xpath 536870912 " X: 0
6827 Xout v:throwpoint
6828 catch /.*/
6829 Xpath 1073741824 " X: 0
6830 Xout v:exception "in" v:throwpoint
6831 endtry
6832
6833 delfunction F 6898 delfunction F
6834 6899
6835 Xcheck 212514423 6900 Xcheck 212514423
6836 6901
6837 " Leave THROW(), NAME(), and ARG() for the next test. 6902 " Leave THROW(), NAME(), and ARG() for the next test.
6838 6903
6839 6904
6840 "------------------------------------------------------------------------------- 6905 "-------------------------------------------------------------------------------
6841 " Test 68: :throw accross function calls in expressions {{{1 6906 " Test 68: :throw across function calls in expressions {{{1
6842 " 6907 "
6843 " On a function call within an expression, an exception might be 6908 " On a function call within an expression, an exception might be
6844 " thrown when evaluating the function name, during evaluation of the 6909 " thrown when evaluating the function name, during evaluation of the
6845 " arguments, or when the function is being executed. The exception 6910 " arguments, or when the function is being executed. The exception
6846 " can be caught by the caller. 6911 " can be caught by the caller.
6851 6916
6852 XpathINIT 6917 XpathINIT
6853 6918
6854 function! F(x, n) 6919 function! F(x, n)
6855 if a:n == 2 6920 if a:n == 2
6856 Xpath 2048 " X: 0 6921 Xpath 2048 " X: 0
6857 elseif a:n == 4 6922 elseif a:n == 4
6858 Xpath 4096 " X: 4096 6923 Xpath 4096 " X: 4096
6859 endif 6924 endif
6860 return a:x 6925 return a:x
6861 endfunction 6926 endfunction
6862 6927
6863 unlet! var1 var2 var3 var4 6928 unlet! var1 var2 var3 var4
6864 6929
6865 try 6930 while 1
6866 6931 try
6867 try 6932 let error = 0
6868 Xpath 8192 " X: 8192 6933 let v:errmsg = ""
6869 let var1 = {NAME(THROW("name", 1), 1)}(ARG(4711, 1), 1) 6934
6870 Xpath 16384 " X: 0 6935 while 1
6871 catch /^name$/ 6936 try
6872 Xpath 32768 " X: 32768 6937 Xpath 8192 " X: 8192
6938 let var1 = {NAME(THROW("name", 1), 1)}(ARG(4711, 1), 1)
6939 Xpath 16384 " X: 0
6940 catch /^name$/
6941 Xpath 32768 " X: 32768
6942 catch /.*/
6943 let error = 1
6944 Xout "1:" v:exception "in" v:throwpoint
6945 finally
6946 if !error && $VIMNOERRTHROW && v:errmsg != ""
6947 let error = 1
6948 Xout "1:" v:errmsg
6949 endif
6950 if error
6951 Xpath 65536 " X: 0
6952 endif
6953 let error = 0
6954 let v:errmsg = ""
6955 break " discard error for $VIMNOERRTHROW
6956 endtry
6957 endwhile
6958
6959 while 1
6960 try
6961 Xpath 131072 " X: 131072
6962 let var2 = {NAME("F", 2)}(ARG(THROW("arg", 2), 2), 2)
6963 Xpath 262144 " X: 0
6964 catch /^arg$/
6965 Xpath 524288 " X: 524288
6966 catch /.*/
6967 let error = 1
6968 Xout "2:" v:exception "in" v:throwpoint
6969 finally
6970 if !error && $VIMNOERRTHROW && v:errmsg != ""
6971 let error = 1
6972 Xout "2:" v:errmsg
6973 endif
6974 if error
6975 Xpath 1048576 " X: 0
6976 endif
6977 let error = 0
6978 let v:errmsg = ""
6979 break " discard error for $VIMNOERRTHROW
6980 endtry
6981 endwhile
6982
6983 while 1
6984 try
6985 Xpath 2097152 " X: 2097152
6986 let var3 = {NAME("THROW", 3)}(ARG("call", 3), 3)
6987 Xpath 4194304 " X: 0
6988 catch /^call$/
6989 Xpath 8388608 " X: 8388608
6990 catch /^0$/ " default return value
6991 Xpath 16777216 " X: 0
6992 Xout "3:" v:throwpoint
6993 catch /.*/
6994 let error = 1
6995 Xout "3:" v:exception "in" v:throwpoint
6996 finally
6997 if !error && $VIMNOERRTHROW && v:errmsg != ""
6998 let error = 1
6999 Xout "3:" v:errmsg
7000 endif
7001 if error
7002 Xpath 33554432 " X: 0
7003 endif
7004 let error = 0
7005 let v:errmsg = ""
7006 break " discard error for $VIMNOERRTHROW
7007 endtry
7008 endwhile
7009
7010 while 1
7011 try
7012 Xpath 67108864 " X: 67108864
7013 let var4 = {NAME("F", 4)}(ARG(4711, 4), 4)
7014 Xpath 134217728 " X: 134217728
7015 catch /.*/
7016 let error = 1
7017 Xout "4:" v:exception "in" v:throwpoint
7018 finally
7019 if !error && $VIMNOERRTHROW && v:errmsg != ""
7020 let error = 1
7021 Xout "4:" v:errmsg
7022 endif
7023 if error
7024 Xpath 268435456 " X: 0
7025 endif
7026 let error = 0
7027 let v:errmsg = ""
7028 break " discard error for $VIMNOERRTHROW
7029 endtry
7030 endwhile
7031
7032 catch /^0$/ " default return value
7033 Xpath 536870912 " X: 0
7034 Xout v:throwpoint
6873 catch /.*/ 7035 catch /.*/
6874 Xpath 65536 " X: 0 7036 let error = 1
6875 Xout "1:" v:exception "in" v:throwpoint 7037 Xout v:exception "in" v:throwpoint
6876 endtry 7038 finally
6877 7039 if !error && $VIMNOERRTHROW && v:errmsg != ""
6878 try 7040 let error = 1
6879 Xpath 131072 " X: 131072 7041 Xout v:errmsg
6880 let var2 = {NAME("F", 2)}(ARG(THROW("arg", 2), 2), 2) 7042 endif
6881 Xpath 262144 " X: 0 7043 if error
6882 catch /^arg$/ 7044 Xpath 1073741824 " X: 0
6883 Xpath 524288 " X: 524288 7045 endif
6884 catch /.*/ 7046 break " discard error for $VIMNOERRTHROW
6885 Xpath 1048576 " X: 0 7047 endtry
6886 Xout "2:" v:exception "in" v:throwpoint 7048 endwhile
6887 endtry
6888
6889 try
6890 Xpath 2097152 " X: 2097152
6891 let var3 = {NAME("THROW", 3)}(ARG("call", 3), 3)
6892 Xpath 4194304 " X: 0
6893 catch /^call$/
6894 Xpath 8388608 " X: 8388608
6895 catch /^0$/ " default return value
6896 Xpath 16777216 " X: 0
6897 Xout "3:" v:throwpoint
6898 catch /.*/
6899 Xpath 33554432 " X: 0
6900 Xout "3:" v:exception "in" v:throwpoint
6901 endtry
6902
6903 try
6904 Xpath 67108864 " X: 67108864
6905 let var4 = {NAME("F", 4)}(ARG(4711, 4), 4)
6906 Xpath 134217728 " X: 134217728
6907 catch /.*/
6908 Xpath 268435456 " X: 0
6909 Xout "4:" v:exception "in" v:throwpoint
6910 endtry
6911
6912 catch /^0$/ " default return value
6913 Xpath 536870912 " X: 0
6914 Xout v:throwpoint
6915 catch /.*/
6916 Xpath 1073741824 " X: 0
6917 Xout v:exception "in" v:throwpoint
6918 endtry
6919 7049
6920 if exists("var1") || exists("var2") || exists("var3") || 7050 if exists("var1") || exists("var2") || exists("var3") ||
6921 \ !exists("var4") || var4 != 4711 7051 \ !exists("var4") || var4 != 4711
6922 " The Xpath command does not accept 2^31 (negative); add explicitly: 7052 " The Xpath command does not accept 2^31 (negative); add explicitly:
6923 let Xpath = Xpath + 2147483648 " X: 0 7053 let Xpath = Xpath + 2147483648 " X: 0
6924 if exists("var1") 7054 if exists("var1")
6925 Xout "var1 =" var1 7055 Xout "var1 =" var1
6926 endif 7056 endif
6927 if exists("var2") 7057 if exists("var2")
6928 Xout "var2 =" var2 7058 Xout "var2 =" var2
6935 elseif var4 != 4711 7065 elseif var4 != 4711
6936 Xout "var4 =" var4 7066 Xout "var4 =" var4
6937 endif 7067 endif
6938 endif 7068 endif
6939 7069
6940 unlet! var1 var2 var3 var4 7070 unlet! error var1 var2 var3 var4
6941 delfunction THROW 7071 delfunction THROW
6942 delfunction NAME 7072 delfunction NAME
6943 delfunction ARG 7073 delfunction ARG
6944 delfunction F 7074 delfunction F
6945 7075
6946 Xcheck 212514423 7076 Xcheck 212514423
6947 7077
6948 7078
6949 "------------------------------------------------------------------------------- 7079 "-------------------------------------------------------------------------------
6950 " Test 69: :throw accross :if, :elseif, :while {{{1 7080 " Test 69: :throw across :if, :elseif, :while {{{1
6951 " 7081 "
6952 " On an :if, :elseif, or :while command, an exception might be thrown 7082 " On an :if, :elseif, or :while command, an exception might be thrown
6953 " during evaluation of the expression to test. The exception can be 7083 " during evaluation of the expression to test. The exception can be
6954 " caught by the script. 7084 " caught by the script.
6955 "------------------------------------------------------------------------------- 7085 "-------------------------------------------------------------------------------
7026 7156
7027 Xcheck 8995471 7157 Xcheck 8995471
7028 7158
7029 7159
7030 "------------------------------------------------------------------------------- 7160 "-------------------------------------------------------------------------------
7031 " Test 70: :throw accross :return or :throw {{{1 7161 " Test 70: :throw across :return or :throw {{{1
7032 " 7162 "
7033 " On a :return or :throw command, an exception might be thrown during 7163 " On a :return or :throw command, an exception might be thrown during
7034 " evaluation of the expression to return or throw, respectively. The 7164 " evaluation of the expression to return or throw, respectively. The
7035 " exception can be caught by the script. 7165 " exception can be caught by the script.
7036 "------------------------------------------------------------------------------- 7166 "-------------------------------------------------------------------------------
7144 7274
7145 Xcheck 69544277 7275 Xcheck 69544277
7146 7276
7147 7277
7148 "------------------------------------------------------------------------------- 7278 "-------------------------------------------------------------------------------
7149 " Test 71: :throw accross :echo variants and :execute {{{1 7279 " Test 71: :throw across :echo variants and :execute {{{1
7150 " 7280 "
7151 " On an :echo, :echon, :echomsg, :echoerr, or :execute command, an 7281 " On an :echo, :echon, :echomsg, :echoerr, or :execute command, an
7152 " exception might be thrown during evaluation of the arguments to 7282 " exception might be thrown during evaluation of the arguments to
7153 " be displayed or executed as a command, respectively. Any following 7283 " be displayed or executed as a command, respectively. Any following
7154 " arguments are not evaluated, then. The exception can be caught by 7284 " arguments are not evaluated, then. The exception can be caught by
7251 7381
7252 Xcheck 34886997 7382 Xcheck 34886997
7253 7383
7254 7384
7255 "------------------------------------------------------------------------------- 7385 "-------------------------------------------------------------------------------
7256 " Test 72: :throw accross :let or :unlet {{{1 7386 " Test 72: :throw across :let or :unlet {{{1
7257 " 7387 "
7258 " On a :let command, an exception might be thrown during evaluation 7388 " On a :let command, an exception might be thrown during evaluation
7259 " of the expression to assign. On an :let or :unlet command, the 7389 " of the expression to assign. On an :let or :unlet command, the
7260 " evaluation of the name of the variable to be assigned or list or 7390 " evaluation of the name of the variable to be assigned or list or
7261 " deleted, respectively, may throw an exception. Any following 7391 " deleted, respectively, may throw an exception. Any following
7410 7540
7411 Xcheck 1789569365 7541 Xcheck 1789569365
7412 7542
7413 7543
7414 "------------------------------------------------------------------------------- 7544 "-------------------------------------------------------------------------------
7415 " Test 73: :throw accross :function, :delfunction {{{1 7545 " Test 73: :throw across :function, :delfunction {{{1
7416 " 7546 "
7417 " The :function and :delfunction commands may cause an expression 7547 " The :function and :delfunction commands may cause an expression
7418 " specified in braces to be evaluated. During evaluation, an 7548 " specified in braces to be evaluated. During evaluation, an
7419 " exception might be thrown. The exception can be caught by the 7549 " exception might be thrown. The exception can be caught by the
7420 " script. 7550 " script.
7514 7644
7515 Xcheck 9032615 7645 Xcheck 9032615
7516 7646
7517 7647
7518 "------------------------------------------------------------------------------- 7648 "-------------------------------------------------------------------------------
7519 " Test 74: :throw accross builtin functions and commands {{{1 7649 " Test 74: :throw across builtin functions and commands {{{1
7520 " 7650 "
7521 " Some functions like exists(), searchpair() take expression 7651 " Some functions like exists(), searchpair() take expression
7522 " arguments, other functions or commands like substitute() or 7652 " arguments, other functions or commands like substitute() or
7523 " :substitute cause an expression (specified in the regular 7653 " :substitute cause an expression (specified in the regular
7524 " expression) to be evaluated. During evaluation an exception 7654 " expression) to be evaluated. During evaluation an exception
7894 8024
7895 Xcheck 2000403408 8025 Xcheck 2000403408
7896 8026
7897 8027
7898 "------------------------------------------------------------------------------- 8028 "-------------------------------------------------------------------------------
7899 " Test 76: Errors, interupts, :throw during expression evaluation {{{1 8029 " Test 76: Errors, interrupts, :throw during expression evaluation {{{1
7900 " 8030 "
7901 " When a function call made during expression evaluation is aborted 8031 " When a function call made during expression evaluation is aborted
7902 " due to an error inside a :try/:endtry region or due to an interrupt 8032 " due to an error inside a :try/:endtry region or due to an interrupt
7903 " or a :throw, the expression evaluation is aborted as well. No 8033 " or a :throw, the expression evaluation is aborted as well. No
7904 " message is displayed for the cancelled expression evaluation. On an 8034 " message is displayed for the cancelled expression evaluation. On an
8153 8283
8154 Xcheck 1610087935 8284 Xcheck 1610087935
8155 8285
8156 8286
8157 "------------------------------------------------------------------------------- 8287 "-------------------------------------------------------------------------------
8158 " Test 77: Errors, interupts, :throw in name{brace-expression} {{{1 8288 " Test 77: Errors, interrupts, :throw in name{brace-expression} {{{1
8159 " 8289 "
8160 " When a function call made during evaluation of an expression in 8290 " When a function call made during evaluation of an expression in
8161 " braces as part of a function name after ":function" is aborted due 8291 " braces as part of a function name after ":function" is aborted due
8162 " to an error inside a :try/:endtry region or due to an interrupt or 8292 " to an error inside a :try/:endtry region or due to an interrupt or
8163 " a :throw, the expression evaluation is aborted as well, and the 8293 " a :throw, the expression evaluation is aborted as well, and the
8369 " exception. Set it to the original error message. 8499 " exception. Set it to the original error message.
8370 let v:errmsg = substitute(v:exception, 8500 let v:errmsg = substitute(v:exception,
8371 \ '^Vim\((\a\+)\)\=:', '', "") 8501 \ '^Vim\((\a\+)\)\=:', '', "")
8372 let caught = 1 8502 let caught = 1
8373 finally 8503 finally
8374 if !caught " no error exceptions ($VIMNOERRTHROW set) 8504 if t <= 8 && t != 3 && t != 7
8375 if t <= 8 && t != 3 8505 call MSG(t, 'E475', 'Invalid argument\>')
8376 call MSG(t, 'E475', 'Invalid argument\>') 8506 else
8377 else 8507 if !caught " no error exceptions ($VIMNOERRTHROW set)
8378 call MSG(t, 'E15', "Invalid expression") 8508 call MSG(t, 'E15', "Invalid expression")
8379 endif
8380 else
8381 if t <= 2 || t == 4 || t == 5 || t == 6 || t == 8
8382 call MSG(t, 'E475', 'Invalid argument\>')
8383 else 8509 else
8384 call MSG(t, 'E121', "Undefined variable") 8510 call MSG(t, 'E121', "Undefined variable")
8385 endif 8511 endif
8386 endif 8512 endif
8387 let t = t + 1 8513 let t = t + 1
9056 " a specific event, the rest of the sequence is not executed. The 9182 " a specific event, the rest of the sequence is not executed. The
9057 " command that triggered the autocommand execution aborts, and the 9183 " command that triggered the autocommand execution aborts, and the
9058 " exception is propagated to the caller. 9184 " exception is propagated to the caller.
9059 " 9185 "
9060 " For the FuncUndefined event under a function call expression or 9186 " For the FuncUndefined event under a function call expression or
9061 " :call command, the function is not exexecuted, even when it has 9187 " :call command, the function is not executed, even when it has
9062 " been defined by the autocommands before the exception occurred. 9188 " been defined by the autocommands before the exception occurred.
9063 "------------------------------------------------------------------------------- 9189 "-------------------------------------------------------------------------------
9064 9190
9065 XpathINIT 9191 XpathINIT
9066 9192