annotate src/testdir/test_trycatch.vim @ 25761:e855eba4ac39 v8.2.3416

patch 8.2.3416: second error is reported while exception is being thrown Commit: https://github.com/vim/vim/commit/36f691f5f1d0676f080cc97d697d742ed5cc8251 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Sep 8 15:33:30 2021 +0200 patch 8.2.3416: second error is reported while exception is being thrown Problem: Second error is reported while exception is being thrown. Solution: Do not check for trailing characters when already aborting. (closes #8842)
author Bram Moolenaar <Bram@vim.org>
date Wed, 08 Sep 2021 15:45:03 +0200
parents 3e7723bab4e5
children 5040fae521f6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18504
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Test try-catch-finally exception handling
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2 " Most of this was formerly in test49.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 source check.vim
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 source shared.vim
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 " Test environment {{{1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 com! XpathINIT let g:Xpath = ''
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 com! -nargs=1 -bar Xpath let g:Xpath = g:Xpath . <args>
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 " Test 25: Executing :finally clauses on normal control flow {{{1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 " Control flow in a :try conditional should always fall through to its
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 " :finally clause. A :finally clause of a :try conditional inside an
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 " inactive conditional should never be executed.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 func T25_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 let loops = 3
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 while loops > 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 Xpath 'a' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 if loops >= 2
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 Xpath 'b' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 if loops == 2
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 Xpath 'c' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 Xpath 'd' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 Xpath 'e' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 if loops == 2
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 Xpath 'f' . loops
22395
03249b8976a9 patch 8.2.1746: Vim9: cannot use "fina" for "finally"
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
40 final
18504
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 Xpath 'g' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 Xpath 'h' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 let loops = loops - 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 endwhile
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 Xpath 'i'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51
22395
03249b8976a9 patch 8.2.1746: Vim9: cannot use "fina" for "finally"
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
52 " Also try using "fina" and "final" and "finall" as abbraviations.
18504
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 func T25_G()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 if 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 Xpath 'A'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 call T25_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 Xpath 'B'
22395
03249b8976a9 patch 8.2.1746: Vim9: cannot use "fina" for "finally"
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
59 fina
18504
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 Xpath 'C'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 else
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 Xpath 'D'
22395
03249b8976a9 patch 8.2.1746: Vim9: cannot use "fina" for "finally"
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
65 finall
18504
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 Xpath 'E'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 func Test_finally()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 call T25_G()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 call assert_equal('Aa3b3e3h3a2b2c2d2e2f2g2h2a1h1iBC', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 " Test 26: Executing :finally clauses after :continue or :break {{{1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 " For a :continue or :break dynamically enclosed in a :try/:endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 " region inside the next surrounding :while/:endwhile, if the
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 " :continue/:break is before the :finally, the :finally clause is
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 " executed first. If the :continue/:break is after the :finally, the
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 " :finally clause is broken (like an :if/:endif region).
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 func T26_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 let loops = 3
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 while loops > 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 if loops == 2
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 Xpath 'a' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 let loops = loops - 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 continue
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 elseif loops == 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 Xpath 'b' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 break
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 finish
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 Xpath 'c' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 Xpath 'd' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 Xpath 'e' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 let loops = loops - 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 endwhile
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 Xpath 'f'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 Xpath 'g'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 let loops = 3
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115 while loops > 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119 if loops == 2
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 Xpath 'h' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 let loops = loops - 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 continue
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123 elseif loops == 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124 Xpath 'i' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
125 break
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
126 finish
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
127 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
128 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129 Xpath 'j' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131 Xpath 'k' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132 let loops = loops - 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133 endwhile
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134 Xpath 'l'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 Xpath 'm'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
138
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139 func Test_finally_after_continue()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
141 call T26_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
142 call assert_equal('c3d3e3a2d1b1d1fgj3k3h2i1lm', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
143 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
144
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
145
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
147 " Test 32: Remembering the :return value on :finally {{{1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
148 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
149 " If a :finally clause is executed due to a :return specifying
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
150 " a value, this is the value visible to the caller if not overwritten
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
151 " by a new :return in the :finally clause. A :return without a value
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
152 " in the :finally clause overwrites with value 0.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
153 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
154
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
155 func T32_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
156 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
157 Xpath 'a'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
158 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159 Xpath 'b'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
160 return "ABCD"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
161 Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
163 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
164 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
165 Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
166 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
167 Xpath 'f'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
168 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
169 Xpath 'g'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
170 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
171
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172 func T32_G()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
174 Xpath 'h'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
175 return 8
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
176 Xpath 'i'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
177 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
178 Xpath 'j'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
179 return 16 + strlen(T32_F())
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
180 Xpath 'k'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
181 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
182 Xpath 'l'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
183 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
184
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
185 func T32_H()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
186 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
187 Xpath 'm'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
188 return 32
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
189 Xpath 'n'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
190 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191 Xpath 'o'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
192 return
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
193 Xpath 'p'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
194 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
195 Xpath 'q'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
196 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
197
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
198 func T32_I()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
199 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
200 Xpath 'r'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
201 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
202 Xpath 's'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
203 return T32_G() + T32_H() + 64
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
204 Xpath 't'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
205 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
206 Xpath 'u'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
207 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
208
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
209 func Test_finally_return()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
210 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
211 call assert_equal(84, T32_I())
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
212 call assert_equal('rshjabdfmo', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
215 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
216 " Test 33: :return under :execute or user command and :finally {{{1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
217 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
218 " A :return command may be executed under an ":execute" or from
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
219 " a user command. Executing of :finally clauses and passing through
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
220 " the return code works also then.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
221 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
222
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
223 func T33_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
224 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
225 RETURN 10
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
226 Xpath 'a'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
227 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
228 Xpath 'b'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
229 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
230 Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
231 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
232
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
233 func T33_G()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
234 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
235 RETURN 20
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
236 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
237 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
238 Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
239 RETURN 30
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
240 Xpath 'f'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
241 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
242 Xpath 'g'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
243 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
244
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
245 func T33_H()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
246 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
247 execute "try | return 40 | finally | return 50 | endtry"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
248 Xpath 'h'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
249 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
250 Xpath 'i'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
251 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
252 Xpath 'j'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
253 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
254
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
255 func T33_I()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
256 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
257 execute "try | return 60 | finally | return 70 | endtry"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
258 Xpath 'k'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
259 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
260 Xpath 'l'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
261 execute "try | return 80 | finally | return 90 | endtry"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
262 Xpath 'm'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
263 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
264 Xpath 'n'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
265 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
266
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
267 func T33_J()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
268 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
269 RETURN 100
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
270 Xpath 'o'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
271 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
272 Xpath 'p'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
273 return
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
274 Xpath 'q'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
275 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
276 Xpath 'r'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
277 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
278
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
279 func T33_K()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
280 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
281 execute "try | return 110 | finally | return 120 | endtry"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
282 Xpath 's'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
283 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
284 Xpath 't'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
285 execute "try | return 130 | finally | return | endtry"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
286 Xpath 'u'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
287 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
288 Xpath 'v'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
289 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
290
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
291 func T33_L()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
292 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
293 return
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
294 Xpath 'w'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
295 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
296 Xpath 'x'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
297 RETURN 140
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
298 Xpath 'y'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
299 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
300 Xpath 'z'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
301 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
302
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
303 func T33_M()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
304 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
305 return
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
306 Xpath 'A'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
307 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
308 Xpath 'B'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
309 execute "try | return 150 | finally | return 160 | endtry"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
310 Xpath 'C'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
311 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
312 Xpath 'D'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
313 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
314
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
315 func T33_N()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
316 RETURN 170
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
317 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
318
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
319 func T33_O()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
320 execute "try | return 180 | finally | return 190 | endtry"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
321 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
322
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
323 func Test_finally_cmd_return()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
324 command! -nargs=? RETURN
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
325 \ try | return <args> | finally | return <args> * 2 | endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
326 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
327 call assert_equal(20, T33_F())
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
328 call assert_equal(60, T33_G())
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
329 call assert_equal(50, T33_H())
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
330 call assert_equal(90, T33_I())
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
331 call assert_equal(0, T33_J())
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
332 call assert_equal(0, T33_K())
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
333 call assert_equal(280, T33_L())
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
334 call assert_equal(160, T33_M())
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
335 call assert_equal(340, T33_N())
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
336 call assert_equal(190, T33_O())
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
337 call assert_equal('beilptxB', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
338 delcommand RETURN
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
339 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
340
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
341
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
342 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
343 " Test 41: Skipped :throw finding next command {{{1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
344 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
345 " A :throw in an inactive conditional must not hide a following
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
346 " command.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
347 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
348
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
349 func T41_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
350 Xpath 'a'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
351 if 0 | throw 'never' | endif | Xpath 'b'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
352 Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
353 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
354
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
355 func T41_G()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
356 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
357 while 0 | throw 'never' | endwhile | Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
358 Xpath 'f'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
359 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
360
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
361 func T41_H()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
362 Xpath 'g'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
363 if 0 | try | throw 'never' | endtry | endif | Xpath 'h'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
364 Xpath 'i'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
365 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
366
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
367 func Test_throw_inactive_cond()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
368 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
369 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
370 Xpath 'j'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
371 call T41_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
372 Xpath 'k'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
373 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
374 Xpath 'l'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
375 call assert_report('Caught ' . v:exception . ' in ' . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
376 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
377
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
378 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
379 Xpath 'm'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
380 call T41_G()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
381 Xpath 'n'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
382 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
383 Xpath 'o'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
384 call assert_report('Caught ' . v:exception . ' in ' . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
385 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
386
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
387 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
388 Xpath 'p'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
389 call T41_H()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
390 Xpath 'q'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
391 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
392 Xpath 'r'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
393 call assert_report('Caught ' . v:exception . ' in ' . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
394 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
395
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
396 call assert_equal('jabckmdefnpghiq', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
397 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
398
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
399
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
400 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
401 " Test 42: Catching number and string exceptions {{{1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
402 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
403 " When a number is thrown, it is converted to a string exception.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
404 " Numbers and strings may be caught by specifying a regular exception
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
405 " as argument to the :catch command.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
406 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
407
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
408
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
409 func T42_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
410 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
411
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
412 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
413 Xpath 'a'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
414 throw 4711
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
415 Xpath 'b'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
416 catch /4711/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
417 Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
418 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
419
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
420 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
421 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
422 throw 4711
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
423 Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
424 catch /^4711$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
425 Xpath 'f'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
426 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
427
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
428 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
429 Xpath 'g'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
430 throw 4711
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
431 Xpath 'h'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
432 catch /\d/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
433 Xpath 'i'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
434 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
435
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
436 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
437 Xpath 'j'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
438 throw 4711
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
439 Xpath 'k'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
440 catch /^\d\+$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
441 Xpath 'l'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
442 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
443
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
444 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
445 Xpath 'm'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
446 throw "arrgh"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
447 Xpath 'n'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
448 catch /arrgh/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
449 Xpath 'o'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
450 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
451
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
452 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
453 Xpath 'p'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
454 throw "arrgh"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
455 Xpath 'q'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
456 catch /^arrgh$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
457 Xpath 'r'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
458 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
459
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
460 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
461 Xpath 's'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
462 throw "arrgh"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
463 Xpath 't'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
464 catch /\l/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
465 Xpath 'u'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
466 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
467
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
468 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
469 Xpath 'v'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
470 throw "arrgh"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
471 Xpath 'w'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
472 catch /^\l\+$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
473 Xpath 'x'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
474 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
475
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
476 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
477 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
478 Xpath 'y'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
479 throw "ARRGH"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
480 Xpath 'z'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
481 catch /^arrgh$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
482 Xpath 'A'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
483 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
484 catch /^\carrgh$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
485 Xpath 'B'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
486 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
487
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
488 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
489 Xpath 'C'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
490 throw ""
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
491 Xpath 'D'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
492 catch /^$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
493 Xpath 'E'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
494 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
495
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
496 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
497 Xpath 'F'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
498 call assert_report('Caught ' . v:exception . ' in ' . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
499 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
500 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
501
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
502 func Test_catch_number_string()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
503 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
504 call T42_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
505 call assert_equal('acdfgijlmoprsuvxyBCE', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
506 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
507
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
508
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
509 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
510 " Test 43: Selecting the correct :catch clause {{{1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
511 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
512 " When an exception is thrown and there are multiple :catch clauses,
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
513 " the first matching one is taken.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
514 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
515
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
516 func T43_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
517 let loops = 3
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
518 while loops > 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
519 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
520 if loops == 3
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
521 Xpath 'a' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
522 throw "a"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
523 Xpath 'b' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
524 elseif loops == 2
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
525 Xpath 'c' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
526 throw "ab"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
527 Xpath 'd' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
528 elseif loops == 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
529 Xpath 'e' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
530 throw "abc"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
531 Xpath 'f' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
532 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
533 catch /abc/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
534 Xpath 'g' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
535 catch /ab/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
536 Xpath 'h' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
537 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
538 Xpath 'i' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
539 catch /a/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
540 Xpath 'j' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
541 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
542
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
543 let loops = loops - 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
544 endwhile
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
545 Xpath 'k'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
546 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
547
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
548 func Test_multi_catch()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
549 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
550 call T43_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
551 call assert_equal('a3i3c2h2e1g1k', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
552 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
553
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
554
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
555 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
556 " Test 44: Missing or empty :catch patterns {{{1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
557 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
558 " A missing or empty :catch pattern means the same as /.*/, that is,
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
559 " catches everything. To catch only empty exceptions, /^$/ must be
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
560 " used. A :catch with missing, empty, or /.*/ argument also works
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
561 " when followed by another command separated by a bar on the same
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
562 " line. :catch patterns cannot be specified between ||. But other
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
563 " pattern separators can be used instead of //.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
564 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
565
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
566 func T44_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
567 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
568 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
569 Xpath 'a'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
570 throw ""
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
571 catch /^$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
572 Xpath 'b'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
573 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
574
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
575 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
576 Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
577 throw ""
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
578 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
579 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
580 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
581
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
582 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
583 Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
584 throw ""
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
585 catch //
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
586 Xpath 'f'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
587 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
588
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
589 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
590 Xpath 'g'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
591 throw ""
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
592 catch
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
593 Xpath 'h'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
594 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
595
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
596 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
597 Xpath 'i'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
598 throw "oops"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
599 catch /^$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
600 Xpath 'j'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
601 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
602 Xpath 'k'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
603 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
604
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
605 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
606 Xpath 'l'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
607 throw "arrgh"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
608 catch /^$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
609 Xpath 'm'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
610 catch //
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
611 Xpath 'n'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
612 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
613
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
614 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
615 Xpath 'o'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
616 throw "brrr"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
617 catch /^$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
618 Xpath 'p'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
619 catch
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
620 Xpath 'q'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
621 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
622
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
623 try | Xpath 'r' | throw "x" | catch /.*/ | Xpath 's' | endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
624
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
625 try | Xpath 't' | throw "y" | catch // | Xpath 'u' | endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
626
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
627 while 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
628 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
629 let caught = 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
630 let v:errmsg = ""
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
631 " Extra try level: if ":catch" without arguments below raises
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
632 " a syntax error because it misinterprets the "Xpath" as a pattern,
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
633 " let it be caught by the ":catch /.*/" below.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
634 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
635 try | Xpath 'v' | throw "z" | catch | Xpath 'w' | :
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
636 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
637 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
638 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
639 let caught = 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
640 call assert_report('Caught ' . v:exception . ' in ' . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
641 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
642 if $VIMNOERRTHROW && v:errmsg != ""
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
643 call assert_report(v:errmsg)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
644 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
645 if caught || $VIMNOERRTHROW && v:errmsg != ""
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
646 Xpath 'x'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
647 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
648 break " discard error for $VIMNOERRTHROW
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
649 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
650 endwhile
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
651
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
652 let cologne = 4711
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
653 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
654 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
655 Xpath 'y'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
656 throw "throw cologne"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
657 " Next lines catches all and throws 4711:
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
658 catch |throw cologne|
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
659 Xpath 'z'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
660 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
661 catch /4711/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
662 Xpath 'A'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
663 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
664
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
665 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
666 Xpath 'B'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
667 throw "plus"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
668 catch +plus+
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
669 Xpath 'C'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
670 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
671
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
672 Xpath 'D'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
673 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
674 Xpath 'E'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
675 call assert_report('Caught ' . v:exception . ' in ' . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
676 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
677 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
678
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
679 func Test_empty_catch()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
680 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
681 call T44_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
682 call assert_equal('abcdefghiklnoqrstuvwyABCD', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
683 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
684
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
685
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
686 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
687 " Test 45: Catching exceptions from nested :try blocks {{{1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
688 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
689 " When :try blocks are nested, an exception is caught by the innermost
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
690 " try conditional that has a matching :catch clause.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
691 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
692
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
693 func T45_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
694 let loops = 3
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
695 while loops > 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
696 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
697 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
698 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
699 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
700 if loops == 3
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
701 Xpath 'a' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
702 throw "a"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
703 Xpath 'b' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
704 elseif loops == 2
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
705 Xpath 'c' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
706 throw "ab"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
707 Xpath 'd' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
708 elseif loops == 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
709 Xpath 'e' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
710 throw "abc"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
711 Xpath 'f' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
712 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
713 catch /abc/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
714 Xpath 'g' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
715 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
716 catch /ab/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
717 Xpath 'h' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
718 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
719 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
720 Xpath 'i' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
721 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
722 catch /a/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
723 Xpath 'j' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
724 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
725
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
726 let loops = loops - 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
727 endwhile
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
728 Xpath 'k'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
729 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
730
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
731 func Test_catch_from_nested_try()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
732 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
733 call T45_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
734 call assert_equal('a3i3c2h2e1g1k', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
735 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
736
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
737
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
738 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
739 " Test 46: Executing :finally after a :throw in nested :try {{{1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
740 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
741 " When an exception is thrown from within nested :try blocks, the
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
742 " :finally clauses of the non-catching try conditionals should be
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
743 " executed before the matching :catch of the next surrounding :try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
744 " gets the control. If this also has a :finally clause, it is
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
745 " executed afterwards.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
746 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
747
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
748 func T46_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
749 let sum = 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
750
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
751 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
752 Xpath 'a'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
753 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
754 Xpath 'b'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
755 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
756 Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
757 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
758 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
759 throw "ABC"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
760 Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
761 catch /xyz/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
762 Xpath 'f'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
763 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
764 Xpath 'g'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
765 if sum != 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
766 Xpath 'h'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
767 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
768 let sum = sum + 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
769 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
770 Xpath 'i'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
771 catch /123/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
772 Xpath 'j'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
773 catch /321/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
774 Xpath 'k'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
775 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
776 Xpath 'l'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
777 if sum != 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
778 Xpath 'm'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
779 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
780 let sum = sum + 2
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
781 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
782 Xpath 'n'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
783 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
784 Xpath 'o'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
785 if sum != 3
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
786 Xpath 'p'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
787 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
788 let sum = sum + 4
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
789 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
790 Xpath 'q'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
791 catch /ABC/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
792 Xpath 'r'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
793 if sum != 7
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
794 Xpath 's'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
795 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
796 let sum = sum + 8
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
797 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
798 Xpath 't'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
799 if sum != 15
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
800 Xpath 'u'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
801 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
802 let sum = sum + 16
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
803 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
804 Xpath 'v'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
805 if sum != 31
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
806 Xpath 'w'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
807 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
808 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
809
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
810 func Test_finally_after_throw()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
811 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
812 call T46_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
813 call assert_equal('abcdglortv', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
814 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
815
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
816
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
817 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
818 " Test 47: Throwing exceptions from a :catch clause {{{1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
819 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
820 " When an exception is thrown from a :catch clause, it should not be
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
821 " caught by a :catch of the same :try conditional. After executing
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
822 " the :finally clause (if present), surrounding try conditionals
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
823 " should be checked for a matching :catch.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
824 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
825
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
826 func T47_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
827 Xpath 'a'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
828 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
829 Xpath 'b'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
830 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
831 Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
832 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
833 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
834 throw "x1"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
835 Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
836 catch /x1/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
837 Xpath 'f'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
838 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
839 Xpath 'g'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
840 throw "x2"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
841 Xpath 'h'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
842 catch /x1/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
843 Xpath 'i'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
844 catch /x2/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
845 Xpath 'j'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
846 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
847 Xpath 'k'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
848 throw "x3"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
849 Xpath 'l'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
850 catch /x1/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
851 Xpath 'm'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
852 catch /x2/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
853 Xpath 'n'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
854 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
855 Xpath 'o'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
856 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
857 Xpath 'p'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
858 catch /x3/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
859 Xpath 'q'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
860 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
861 Xpath 'r'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
862 catch /x1/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
863 Xpath 's'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
864 catch /x2/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
865 Xpath 't'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
866 catch /x3/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
867 Xpath 'u'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
868 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
869 Xpath 'v'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
870 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
871 Xpath 'w'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
872 catch /x1/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
873 Xpath 'x'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
874 catch /x2/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
875 Xpath 'y'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
876 catch /x3/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
877 Xpath 'z'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
878 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
879 Xpath 'A'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
880 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
881 Xpath 'B'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
882 call assert_report('Caught ' . v:exception . ' in ' . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
883 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
884 Xpath 'C'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
885 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
886
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
887 func Test_throw_from_catch()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
888 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
889 call T47_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
890 call assert_equal('abcdfgjkovzAC', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
891 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
892
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
893
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
894 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
895 " Test 48: Throwing exceptions from a :finally clause {{{1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
896 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
897 " When an exception is thrown from a :finally clause, it should not be
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
898 " caught by a :catch of the same :try conditional. Surrounding try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
899 " conditionals should be checked for a matching :catch. A previously
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
900 " thrown exception is discarded.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
901 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
902
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
903 func T48_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
904 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
905
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
906 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
907 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
908 Xpath 'a'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
909 catch /x1/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
910 Xpath 'b'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
911 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
912 Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
913 throw "x1"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
914 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
915 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
916 Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
917 catch /x1/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
918 Xpath 'f'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
919 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
920 Xpath 'g'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
921
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
922 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
923 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
924 Xpath 'h'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
925 throw "x2"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
926 Xpath 'i'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
927 catch /x2/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
928 Xpath 'j'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
929 catch /x3/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
930 Xpath 'k'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
931 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
932 Xpath 'l'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
933 throw "x3"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
934 Xpath 'm'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
935 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
936 Xpath 'n'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
937 catch /x2/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
938 Xpath 'o'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
939 catch /x3/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
940 Xpath 'p'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
941 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
942 Xpath 'q'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
943
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
944 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
945 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
946 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
947 Xpath 'r'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
948 throw "x4"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
949 Xpath 's'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
950 catch /x5/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
951 Xpath 't'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
952 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
953 Xpath 'u'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
954 throw "x5" " discards 'x4'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
955 Xpath 'v'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
956 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
957 Xpath 'w'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
958 catch /x4/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
959 Xpath 'x'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
960 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
961 Xpath 'y'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
962 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
963 Xpath 'z'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
964 catch /x5/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
965 Xpath 'A'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
966 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
967 Xpath 'B'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
968
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
969 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
970 Xpath 'C'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
971 call assert_report('Caught ' . v:exception . ' in ' . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
972 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
973 Xpath 'D'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
974 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
975
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
976 func Test_throw_from_finally()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
977 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
978 call T48_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
979 call assert_equal('acfghjlpqruyABD', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
980 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
981
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
982
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
983 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
984 " Test 51: Throwing exceptions across :execute and user commands {{{1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
985 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
986 " A :throw command may be executed under an ":execute" or from
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
987 " a user command.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
988 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
989
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
990 func T51_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
991 command! -nargs=? THROW1 throw <args> | throw 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
992 command! -nargs=? THROW2 try | throw <args> | endtry | throw 2
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
993 command! -nargs=? THROW3 try | throw 3 | catch /3/ | throw <args> | endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
994 command! -nargs=? THROW4 try | throw 4 | finally | throw <args> | endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
995
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
996 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
997
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
998 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
999 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1000 Xpath 'a'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1001 THROW1 "A"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1002 catch /A/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1003 Xpath 'b'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1004 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1005 catch /1/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1006 Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1007 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1008
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1009 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1010 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1011 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1012 THROW2 "B"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1013 catch /B/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1014 Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1015 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1016 catch /2/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1017 Xpath 'f'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1018 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1019
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1020 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1021 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1022 Xpath 'g'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1023 THROW3 "C"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1024 catch /C/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1025 Xpath 'h'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1026 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1027 catch /3/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1028 Xpath 'i'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1029 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1030
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1031 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1032 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1033 Xpath 'j'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1034 THROW4 "D"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1035 catch /D/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1036 Xpath 'k'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1037 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1038 catch /4/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1039 Xpath 'l'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1040 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1041
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1042 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1043 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1044 Xpath 'm'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1045 execute 'throw "E" | throw 5'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1046 catch /E/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1047 Xpath 'n'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1048 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1049 catch /5/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1050 Xpath 'o'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1051 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1052
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1053 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1054 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1055 Xpath 'p'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1056 execute 'try | throw "F" | endtry | throw 6'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1057 catch /F/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1058 Xpath 'q'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1059 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1060 catch /6/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1061 Xpath 'r'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1062 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1063
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1064 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1065 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1066 Xpath 's'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1067 execute'try | throw 7 | catch /7/ | throw "G" | endtry'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1068 catch /G/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1069 Xpath 't'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1070 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1071 catch /7/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1072 Xpath 'u'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1073 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1074
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1075 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1076 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1077 Xpath 'v'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1078 execute 'try | throw 8 | finally | throw "H" | endtry'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1079 catch /H/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1080 Xpath 'w'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1081 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1082 catch /8/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1083 Xpath 'x'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1084 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1085
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1086 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1087 Xpath 'y'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1088 call assert_report('Caught ' . v:exception . ' in ' . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1089 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1090
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1091 Xpath 'z'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1092
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1093 delcommand THROW1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1094 delcommand THROW2
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1095 delcommand THROW3
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1096 delcommand THROW4
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1097 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1098
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1099 func Test_throw_across_commands()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1100 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1101 call T51_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1102 call assert_equal('abdeghjkmnpqstvwz', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1103 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1104
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1105
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1106
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1107 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1108 " Test 69: :throw across :if, :elseif, :while {{{1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1109 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1110 " On an :if, :elseif, or :while command, an exception might be thrown
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1111 " during evaluation of the expression to test. The exception can be
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1112 " caught by the script.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1113 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1114
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1115 func T69_throw(x)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1116 Xpath 'x'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1117 throw a:x
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1118 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1119
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1120 func Test_throw_ifelsewhile()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1121 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1122
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1123 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1124 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1125 Xpath 'a'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1126 if 111 == T69_throw("if") + 111
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1127 Xpath 'b'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1128 else
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1129 Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1130 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1131 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1132 catch /^if$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1133 Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1134 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1135 Xpath 'f'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1136 call assert_report("if: " . v:exception . " in " . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1137 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1138
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1139 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1140 Xpath 'g'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1141 if v:false
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1142 Xpath 'h'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1143 elseif 222 == T69_throw("elseif") + 222
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1144 Xpath 'i'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1145 else
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1146 Xpath 'j'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1147 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1148 Xpath 'k'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1149 catch /^elseif$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1150 Xpath 'l'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1151 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1152 Xpath 'm'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1153 call assert_report("elseif: " . v:exception . " in " . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1154 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1155
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1156 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1157 Xpath 'n'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1158 while 333 == T69_throw("while") + 333
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1159 Xpath 'o'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1160 break
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1161 endwhile
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1162 Xpath 'p'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1163 catch /^while$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1164 Xpath 'q'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1165 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1166 Xpath 'r'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1167 call assert_report("while: " .. v:exception .. " in " .. v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1168 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1169 catch /^0$/ " default return value
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1170 Xpath 's'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1171 call assert_report(v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1172 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1173 call assert_report(v:exception .. " in " .. v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1174 Xpath 't'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1175 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1176
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1177 call assert_equal('axegxlnxq', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1178 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1179
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1180
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1181 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1182 " Test 70: :throw across :return or :throw {{{1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1183 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1184 " On a :return or :throw command, an exception might be thrown during
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1185 " evaluation of the expression to return or throw, respectively. The
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1186 " exception can be caught by the script.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1187 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1188
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1189 let T70_taken = ""
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1190
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1191 func T70_throw(x, n)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1192 let g:T70_taken = g:T70_taken . "T" . a:n
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1193 throw a:x
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1194 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1195
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1196 func T70_F(x, y, n)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1197 let g:T70_taken = g:T70_taken . "F" . a:n
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1198 return a:x + T70_throw(a:y, a:n)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1199 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1200
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1201 func T70_G(x, y, n)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1202 let g:T70_taken = g:T70_taken . "G" . a:n
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1203 throw a:x . T70_throw(a:y, a:n)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1204 return a:x
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1205 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1206
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1207 func Test_throwreturn()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1208 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1209
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1210 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1211 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1212 Xpath 'a'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1213 call T70_F(4711, "return", 1)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1214 Xpath 'b'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1215 catch /^return$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1216 Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1217 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1218 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1219 call assert_report("return: " .. v:exception .. " in " .. v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1220 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1221
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1222 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1223 Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1224 let var = T70_F(4712, "return-var", 2)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1225 Xpath 'f'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1226 catch /^return-var$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1227 Xpath 'g'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1228 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1229 Xpath 'h'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1230 call assert_report("return-var: " . v:exception . " in " . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1231 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1232 unlet! var
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1233 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1234
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1235 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1236 Xpath 'i'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1237 throw "except1" . T70_throw("throw1", 3)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1238 Xpath 'j'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1239 catch /^except1/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1240 Xpath 'k'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1241 catch /^throw1$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1242 Xpath 'l'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1243 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1244 Xpath 'm'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1245 call assert_report("throw1: " .. v:exception .. " in " .. v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1246 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1247
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1248 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1249 Xpath 'n'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1250 call T70_G("except2", "throw2", 4)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1251 Xpath 'o'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1252 catch /^except2/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1253 Xpath 'p'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1254 catch /^throw2$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1255 Xpath 'q'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1256 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1257 Xpath 'r'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1258 call assert_report("throw2: " .. v:exception .. " in " .. v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1259 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1260
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1261 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1262 Xpath 's'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1263 let var = T70_G("except3", "throw3", 5)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1264 Xpath 't'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1265 catch /^except3/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1266 Xpath 'u'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1267 catch /^throw3$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1268 Xpath 'v'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1269 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1270 Xpath 'w'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1271 call assert_report("throw3: " .. v:exception .. " in " .. v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1272 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1273 unlet! var
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1274 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1275
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1276 call assert_equal('F1T1F2T2T3G4T4G5T5', g:T70_taken)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1277 Xpath 'x'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1278 catch /^0$/ " default return value
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1279 Xpath 'y'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1280 call assert_report(v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1281 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1282 Xpath 'z'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1283 call assert_report('Caught' .. v:exception .. ' in ' .. v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1284 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1285
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1286 call assert_equal('acegilnqsvx', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1287 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1288
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1289 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1290 " Test 71: :throw across :echo variants and :execute {{{1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1291 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1292 " On an :echo, :echon, :echomsg, :echoerr, or :execute command, an
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1293 " exception might be thrown during evaluation of the arguments to
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1294 " be displayed or executed as a command, respectively. Any following
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1295 " arguments are not evaluated, then. The exception can be caught by
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1296 " the script.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1297 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1298
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1299 let T71_taken = ""
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1300
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1301 func T71_throw(x, n)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1302 let g:T71_taken = g:T71_taken . "T" . a:n
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1303 throw a:x
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1304 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1305
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1306 func T71_F(n)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1307 let g:T71_taken = g:T71_taken . "F" . a:n
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1308 return "F" . a:n
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1309 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1310
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1311 func Test_throw_echo()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1312 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1313
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1314 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1315 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1316 Xpath 'a'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1317 echo 'echo ' . T71_throw("echo-except", 1) . T71_F(1)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1318 Xpath 'b'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1319 catch /^echo-except$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1320 Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1321 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1322 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1323 call assert_report("echo: " .. v:exception .. " in " .. v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1324 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1325
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1326 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1327 Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1328 echon "echon " . T71_throw("echon-except", 2) . T71_F(2)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1329 Xpath 'f'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1330 catch /^echon-except$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1331 Xpath 'g'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1332 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1333 Xpath 'h'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1334 call assert_report('echon: ' . v:exception . ' in ' . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1335 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1336
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1337 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1338 Xpath 'i'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1339 echomsg "echomsg " . T71_throw("echomsg-except", 3) . T71_F(3)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1340 Xpath 'j'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1341 catch /^echomsg-except$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1342 Xpath 'k'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1343 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1344 Xpath 'l'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1345 call assert_report('echomsg: ' . v:exception . ' in ' . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1346 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1347
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1348 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1349 Xpath 'm'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1350 echoerr "echoerr " . T71_throw("echoerr-except", 4) . T71_F(4)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1351 Xpath 'n'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1352 catch /^echoerr-except$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1353 Xpath 'o'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1354 catch /Vim/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1355 Xpath 'p'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1356 catch /echoerr/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1357 Xpath 'q'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1358 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1359 Xpath 'r'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1360 call assert_report('echoerr: ' . v:exception . ' in ' . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1361 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1362
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1363 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1364 Xpath 's'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1365 execute "echo 'execute " . T71_throw("execute-except", 5) . T71_F(5) "'"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1366 Xpath 't'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1367 catch /^execute-except$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1368 Xpath 'u'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1369 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1370 Xpath 'v'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1371 call assert_report('execute: ' . v:exception . ' in ' . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1372 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1373
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1374 call assert_equal('T1T2T3T4T5', g:T71_taken)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1375 Xpath 'w'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1376 catch /^0$/ " default return value
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1377 Xpath 'x'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1378 call assert_report(v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1379 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1380 Xpath 'y'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1381 call assert_report('Caught ' . v:exception . ' in ' . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1382 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1383
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1384 call assert_equal('acegikmosuw', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1385 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1386
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1387
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1388 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1389 " Test 72: :throw across :let or :unlet {{{1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1390 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1391 " On a :let command, an exception might be thrown during evaluation
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1392 " of the expression to assign. On an :let or :unlet command, the
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1393 " evaluation of the name of the variable to be assigned or list or
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1394 " deleted, respectively, may throw an exception. Any following
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1395 " arguments are not evaluated, then. The exception can be caught by
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1396 " the script.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1397 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1398
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1399 let throwcount = 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1400
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1401 func T72_throw(x)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1402 let g:throwcount = g:throwcount + 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1403 throw a:x
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1404 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1405
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1406 let T72_addpath = ''
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1407
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1408 func T72_addpath(p)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1409 let g:T72_addpath = g:T72_addpath . a:p
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1410 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1411
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1412 func Test_throw_let()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1413 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1414
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1415 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1416 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1417 let $VAR = 'old_value'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1418 Xpath 'a'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1419 let $VAR = 'let(' . T72_throw('var') . ')'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1420 Xpath 'b'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1421 catch /^var$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1422 Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1423 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1424 call assert_equal('old_value', $VAR)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1425 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1426
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1427 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1428 let @a = 'old_value'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1429 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1430 let @a = 'let(' . T72_throw('reg') . ')'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1431 Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1432 catch /^reg$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1433 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1434 Xpath 'f'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1435 let @A = 'let(' . T72_throw('REG') . ')'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1436 Xpath 'g'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1437 catch /^REG$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1438 Xpath 'h'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1439 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1440 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1441 call assert_equal('old_value', @a)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1442 call assert_equal('old_value', @A)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1443 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1444
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1445 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1446 let saved_gpath = &g:path
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1447 let saved_lpath = &l:path
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1448 Xpath 'i'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1449 let &path = 'let(' . T72_throw('opt') . ')'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1450 Xpath 'j'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1451 catch /^opt$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1452 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1453 Xpath 'k'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1454 let &g:path = 'let(' . T72_throw('gopt') . ')'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1455 Xpath 'l'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1456 catch /^gopt$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1457 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1458 Xpath 'm'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1459 let &l:path = 'let(' . T72_throw('lopt') . ')'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1460 Xpath 'n'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1461 catch /^lopt$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1462 Xpath 'o'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1463 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1464 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1465 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1466 call assert_equal(saved_gpath, &g:path)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1467 call assert_equal(saved_lpath, &l:path)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1468 let &g:path = saved_gpath
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1469 let &l:path = saved_lpath
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1470 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1471
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1472 unlet! var1 var2 var3
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1473
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1474 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1475 Xpath 'p'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1476 let var1 = 'let(' . T72_throw('var1') . ')'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1477 Xpath 'q'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1478 catch /^var1$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1479 Xpath 'r'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1480 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1481 call assert_true(!exists('var1'))
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1482 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1483
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1484 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1485 let var2 = 'old_value'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1486 Xpath 's'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1487 let var2 = 'let(' . T72_throw('var2'). ')'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1488 Xpath 't'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1489 catch /^var2$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1490 Xpath 'u'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1491 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1492 call assert_equal('old_value', var2)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1493 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1494
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1495 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1496 Xpath 'v'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1497 let var{T72_throw('var3')} = 4711
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1498 Xpath 'w'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1499 catch /^var3$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1500 Xpath 'x'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1501 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1502
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1503 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1504 call T72_addpath('T1')
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1505 let var{T72_throw('var4')} var{T72_addpath('T2')} | call T72_addpath('T3')
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1506 call T72_addpath('T4')
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1507 catch /^var4$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1508 call T72_addpath('T5')
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1509 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1510
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1511 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1512 call T72_addpath('T6')
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1513 unlet var{T72_throw('var5')} var{T72_addpath('T7')}
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1514 \ | call T72_addpath('T8')
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1515 call T72_addpath('T9')
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1516 catch /^var5$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1517 call T72_addpath('T10')
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1518 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1519
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1520 call assert_equal('T1T5T6T10', g:T72_addpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1521 call assert_equal(11, g:throwcount)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1522 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1523 call assert_report('Caught ' . v:exception . ' in ' . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1524 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1525
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1526 call assert_equal('acdfhikmoprsuvx', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1527 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1528
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1529
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1530 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1531 " Test 73: :throw across :function, :delfunction {{{1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1532 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1533 " The :function and :delfunction commands may cause an expression
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1534 " specified in braces to be evaluated. During evaluation, an
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1535 " exception might be thrown. The exception can be caught by the
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1536 " script.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1537 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1538
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1539 let T73_taken = ''
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1540
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1541 func T73_throw(x, n)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1542 let g:T73_taken = g:T73_taken . 'T' . a:n
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1543 throw a:x
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1544 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1545
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1546 func T73_expr(x, n)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1547 let g:T73_taken = g:T73_taken . 'E' . a:n
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1548 if a:n % 2 == 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1549 call T73_throw(a:x, a:n)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1550 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1551 return 2 - a:n % 2
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1552 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1553
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1554 func Test_throw_func()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1555 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1556
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1557 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1558 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1559 " Define function.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1560 Xpath 'a'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1561 function! F0()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1562 endfunction
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1563 Xpath 'b'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1564 function! F{T73_expr('function-def-ok', 1)}()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1565 endfunction
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1566 Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1567 function! F{T73_expr('function-def', 2)}()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1568 endfunction
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1569 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1570 catch /^function-def-ok$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1571 Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1572 catch /^function-def$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1573 Xpath 'f'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1574 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1575 call assert_report('def: ' . v:exception . ' in ' . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1576 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1577
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1578 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1579 " List function.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1580 Xpath 'g'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1581 function F0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1582 Xpath 'h'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1583 function F{T73_expr('function-lst-ok', 3)}
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1584 Xpath 'i'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1585 function F{T73_expr('function-lst', 4)}
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1586 Xpath 'j'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1587 catch /^function-lst-ok$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1588 Xpath 'k'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1589 catch /^function-lst$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1590 Xpath 'l'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1591 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1592 call assert_report('lst: ' . v:exception . ' in ' . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1593 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1594
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1595 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1596 " Delete function
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1597 Xpath 'm'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1598 delfunction F0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1599 Xpath 'n'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1600 delfunction F{T73_expr('function-del-ok', 5)}
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1601 Xpath 'o'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1602 delfunction F{T73_expr('function-del', 6)}
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1603 Xpath 'p'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1604 catch /^function-del-ok$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1605 Xpath 'q'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1606 catch /^function-del$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1607 Xpath 'r'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1608 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1609 call assert_report('del: ' . v:exception . ' in ' . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1610 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1611 call assert_equal('E1E2T2E3E4T4E5E6T6', g:T73_taken)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1612 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1613 call assert_report('Caught ' . v:exception . ' in ' . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1614 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1615
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1616 call assert_equal('abcfghilmnor', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1617 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1618
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1619
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1620 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1621 " Test 74: :throw across builtin functions and commands {{{1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1622 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1623 " Some functions like exists(), searchpair() take expression
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1624 " arguments, other functions or commands like substitute() or
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1625 " :substitute cause an expression (specified in the regular
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1626 " expression) to be evaluated. During evaluation an exception
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1627 " might be thrown. The exception can be caught by the script.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1628 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1629
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1630 let T74_taken = ""
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1631
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1632 func T74_throw(x, n)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1633 let g:T74_taken = g:T74_taken . "T" . a:n
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1634 throw a:x
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1635 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1636
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1637 func T74_expr(x, n)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1638 let g:T74_taken = g:T74_taken . "E" . a:n
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1639 call T74_throw(a:x . a:n, a:n)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1640 return "EXPR"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1641 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1642
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1643 func T74_skip(x, n)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1644 let g:T74_taken = g:T74_taken . "S" . a:n . "(" . line(".")
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1645 let theline = getline(".")
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1646 if theline =~ "skip"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1647 let g:T74_taken = g:T74_taken . "s)"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1648 return 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1649 elseif theline =~ "throw"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1650 let g:T74_taken = g:T74_taken . "t)"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1651 call T74_throw(a:x . a:n, a:n)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1652 else
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1653 let g:T74_taken = g:T74_taken . ")"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1654 return 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1655 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1656 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1657
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1658 func T74_subst(x, n)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1659 let g:T74_taken = g:T74_taken . "U" . a:n . "(" . line(".")
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1660 let theline = getline(".")
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1661 if theline =~ "not" " T74_subst() should not be called for this line
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1662 let g:T74_taken = g:T74_taken . "n)"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1663 call T74_throw(a:x . a:n, a:n)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1664 elseif theline =~ "throw"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1665 let g:T74_taken = g:T74_taken . "t)"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1666 call T74_throw(a:x . a:n, a:n)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1667 else
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1668 let g:T74_taken = g:T74_taken . ")"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1669 return "replaced"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1670 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1671 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1672
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1673 func Test_throw_builtin_func()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1674 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1675
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1676 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1677 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1678 Xpath 'a'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1679 let result = exists('*{T74_expr("exists", 1)}')
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1680 Xpath 'b'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1681 catch /^exists1$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1682 Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1683 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1684 let result = exists('{T74_expr("exists", 2)}')
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1685 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1686 catch /^exists2$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1687 Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1688 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1689 call assert_report('exists2: ' . v:exception . ' in ' . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1690 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1691 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1692 call assert_report('exists1: ' . v:exception . ' in ' . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1693 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1694
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1695 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1696 let file = tempname()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1697 exec "edit" file
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1698 call append(0, [
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1699 \ 'begin',
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1700 \ 'xx',
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1701 \ 'middle 3',
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1702 \ 'xx',
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1703 \ 'middle 5 skip',
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1704 \ 'xx',
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1705 \ 'middle 7 throw',
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1706 \ 'xx',
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1707 \ 'end'])
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1708 normal! gg
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1709 Xpath 'f'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1710 let result = searchpair("begin", "middle", "end", '',
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1711 \ 'T74_skip("searchpair", 3)')
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1712 Xpath 'g'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1713 let result = searchpair("begin", "middle", "end", '',
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1714 \ 'T74_skip("searchpair", 4)')
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1715 Xpath 'h'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1716 let result = searchpair("begin", "middle", "end", '',
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1717 \ 'T74_skip("searchpair", 5)')
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1718 Xpath 'i'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1719 catch /^searchpair[35]$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1720 Xpath 'j'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1721 catch /^searchpair4$/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1722 Xpath 'k'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1723 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1724 call assert_report('searchpair: ' . v:exception . ' in ' . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1725 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1726 bwipeout!
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1727 call delete(file)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1728 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1729
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1730 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1731 let file = tempname()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1732 exec "edit" file
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1733 call append(0, [
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1734 \ 'subst 1',
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1735 \ 'subst 2',
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1736 \ 'not',
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1737 \ 'subst 4',
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1738 \ 'subst throw',
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1739 \ 'subst 6'])
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1740 normal! gg
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1741 Xpath 'l'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1742 1,2substitute/subst/\=T74_subst("substitute", 6)/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1743 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1744 Xpath 'm'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1745 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1746 let v:errmsg = ""
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1747 3substitute/subst/\=T74_subst("substitute", 7)/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1748 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1749 if v:errmsg != ""
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1750 " If exceptions are not thrown on errors, fake the error
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1751 " exception in order to get the same execution path.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1752 throw "faked Vim(substitute)"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1753 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1754 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1755 catch /Vim(substitute)/ " Pattern not found ('e' flag missing)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1756 Xpath 'n'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1757 3substitute/subst/\=T74_subst("substitute", 8)/e
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1758 Xpath 'o'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1759 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1760 Xpath 'p'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1761 4,6substitute/subst/\=T74_subst("substitute", 9)/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1762 Xpath 'q'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1763 catch /^substitute[678]/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1764 Xpath 'r'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1765 catch /^substitute9/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1766 Xpath 's'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1767 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1768 bwipeout!
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1769 call delete(file)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1770 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1771
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1772 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1773 Xpath 't'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1774 let var = substitute("sub", "sub", '\=T74_throw("substitute()y", 10)', '')
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1775 Xpath 'u'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1776 catch /substitute()y/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1777 Xpath 'v'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1778 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1779 call assert_report('substitute()y: ' . v:exception . ' in '
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1780 \ . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1781 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1782
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1783 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1784 Xpath 'w'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1785 let var = substitute("not", "sub", '\=T74_throw("substitute()n", 11)', '')
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1786 Xpath 'x'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1787 catch /substitute()n/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1788 Xpath 'y'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1789 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1790 call assert_report('substitute()n: ' . v:exception . ' in '
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1791 \ . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1792 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1793
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1794 call assert_equal('E1T1E2T2S3(3)S4(5s)S4(7t)T4U6(1)U6(2)U9(4)U9(5t)T9T10',
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1795 \ g:T74_taken)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1796
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1797 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1798 call assert_report('Caught ' . v:exception . ' in ' . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1799 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1800
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1801 call assert_equal('acefgklmnopstvwx', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1802 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1803
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1804
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1805 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1806 " Test 75: Errors in builtin functions. {{{1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1807 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1808 " On an error in a builtin function called inside a :try/:endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1809 " region, the evaluation of the expression calling that function and
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1810 " the command containing that expression are abandoned. The error can
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1811 " be caught as an exception.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1812 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1813 " A simple :call of the builtin function is a trivial case. If the
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1814 " builtin function is called in the argument list of another function,
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1815 " no further arguments are evaluated, and the other function is not
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1816 " executed. If the builtin function is called from the argument of
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1817 " a :return command, the :return command is not executed. If the
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1818 " builtin function is called from the argument of a :throw command,
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1819 " the :throw command is not executed. The evaluation of the
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1820 " expression calling the builtin function is abandoned.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1821 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1822
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1823 func T75_F1(arg1)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1824 Xpath 'a'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1825 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1826
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1827 func T75_F2(arg1, arg2)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1828 Xpath 'b'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1829 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1830
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1831 func T75_G()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1832 Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1833 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1834
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1835 func T75_H()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1836 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1837 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1838
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1839 func T75_R()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1840 while 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1841 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1842 let caught = 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1843 let v:errmsg = ""
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1844 Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1845 return append(1, "s")
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1846 catch /E21/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1847 let caught = 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1848 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1849 Xpath 'f'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1850 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1851 Xpath 'g'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1852 if caught || $VIMNOERRTHROW && v:errmsg =~ 'E21'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1853 Xpath 'h'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1854 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1855 break " discard error for $VIMNOERRTHROW
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1856 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1857 endwhile
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1858 Xpath 'i'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1859 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1860
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1861 func Test_builtin_func_error()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1862 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1863
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1864 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1865 set noma " let append() fail with "E21"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1866
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1867 while 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1868 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1869 let caught = 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1870 let v:errmsg = ""
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1871 Xpath 'j'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1872 call append(1, "s")
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1873 catch /E21/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1874 let caught = 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1875 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1876 Xpath 'k'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1877 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1878 Xpath 'l'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1879 if caught || $VIMNOERRTHROW && v:errmsg =~ 'E21'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1880 Xpath 'm'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1881 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1882 break " discard error for $VIMNOERRTHROW
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1883 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1884 endwhile
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1885
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1886 while 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1887 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1888 let caught = 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1889 let v:errmsg = ""
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1890 Xpath 'n'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1891 call T75_F1('x' . append(1, "s"))
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1892 catch /E21/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1893 let caught = 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1894 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1895 Xpath 'o'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1896 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1897 Xpath 'p'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1898 if caught || $VIMNOERRTHROW && v:errmsg =~ 'E21'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1899 Xpath 'q'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1900 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1901 break " discard error for $VIMNOERRTHROW
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1902 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1903 endwhile
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1904
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1905 while 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1906 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1907 let caught = 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1908 let v:errmsg = ""
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1909 Xpath 'r'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1910 call T75_F2('x' . append(1, "s"), T75_G())
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1911 catch /E21/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1912 let caught = 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1913 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1914 Xpath 's'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1915 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1916 Xpath 't'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1917 if caught || $VIMNOERRTHROW && v:errmsg =~ 'E21'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1918 Xpath 'u'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1919 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1920 break " discard error for $VIMNOERRTHROW
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1921 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1922 endwhile
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1923
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1924 call T75_R()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1925
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1926 while 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1927 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1928 let caught = 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1929 let v:errmsg = ""
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1930 Xpath 'v'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1931 throw "T" . append(1, "s")
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1932 catch /E21/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1933 let caught = 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1934 catch /^T.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1935 Xpath 'w'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1936 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1937 Xpath 'x'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1938 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1939 Xpath 'y'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1940 if caught || $VIMNOERRTHROW && v:errmsg =~ 'E21'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1941 Xpath 'z'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1942 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1943 break " discard error for $VIMNOERRTHROW
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1944 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1945 endwhile
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1946
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1947 while 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1948 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1949 let caught = 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1950 let v:errmsg = ""
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1951 Xpath 'A'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1952 let x = "a"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1953 let x = x . "b" . append(1, "s") . T75_H()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1954 catch /E21/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1955 let caught = 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1956 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1957 Xpath 'B'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1958 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1959 Xpath 'C'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1960 if caught || $VIMNOERRTHROW && v:errmsg =~ 'E21'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1961 Xpath 'D'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1962 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1963 call assert_equal('a', x)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1964 break " discard error for $VIMNOERRTHROW
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1965 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1966 endwhile
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1967 catch /.*/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1968 call assert_report('Caught ' . v:exception . ' in ' . v:throwpoint)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1969 finally
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1970 set ma&
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1971 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1972
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1973 call assert_equal('jlmnpqrtueghivyzACD', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1974 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1975
18886
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
1976 func Test_reload_in_try_catch()
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
1977 call writefile(['x'], 'Xreload')
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
1978 set autoread
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
1979 edit Xreload
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
1980 tabnew
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
1981 call writefile(['xx'], 'Xreload')
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
1982 augroup ReLoad
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
1983 au FileReadPost Xreload let x = doesnotexist
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
1984 au BufReadPost Xreload let x = doesnotexist
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
1985 augroup END
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
1986 try
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
1987 edit Xreload
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
1988 catch
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
1989 endtry
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
1990 tabnew
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
1991
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
1992 tabclose
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
1993 tabclose
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
1994 autocmd! ReLoad
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
1995 set noautoread
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
1996 bwipe! Xreload
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
1997 call delete('Xreload')
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
1998 endfunc
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
1999
19471
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2000 " Test for errors with :catch, :throw, :finally {{{1
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2001 func Test_try_catch_errors()
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2002 call assert_fails('throw |', 'E471:')
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2003 call assert_fails("throw \n ", 'E471:')
21265
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 19906
diff changeset
2004 call assert_fails('catch abc', 'E654:')
19471
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2005 call assert_fails('try | let i = 1| finally | catch | endtry', 'E604:')
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2006 call assert_fails('finally', 'E606:')
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2007 call assert_fails('try | finally | finally | endtry', 'E607:')
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2008 call assert_fails('try | for i in range(5) | endif | endtry', 'E580:')
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2009 call assert_fails('try | while v:true | endtry', 'E170:')
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2010 call assert_fails('try | if v:true | endtry', 'E171:')
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2011 endfunc
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2012
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2013 " Test for verbose messages with :try :catch, and :finally {{{1
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2014 func Test_try_catch_verbose()
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2015 " This test works only when the language is English
19906
031184ace7c5 patch 8.2.0509: various code is not properly tested.
Bram Moolenaar <Bram@vim.org>
parents: 19487
diff changeset
2016 CheckEnglish
19471
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2017
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2018 set verbose=14
19487
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2019
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2020 " Test for verbose messages displayed when an exception is caught
19471
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2021 redir => msg
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2022 try
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2023 echo i
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2024 catch /E121:/
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2025 finally
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2026 endtry
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2027 redir END
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2028 let expected = [
19487
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2029 \ 'Exception thrown: Vim(echo):E121: Undefined variable: i', '',
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2030 \ 'Exception caught: Vim(echo):E121: Undefined variable: i', '',
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2031 \ 'Exception finished: Vim(echo):E121: Undefined variable: i']
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2032 call assert_equal(expected, split(msg, "\n"))
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2033
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2034 " Test for verbose messages displayed when an exception is discarded
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2035 redir => msg
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2036 try
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2037 try
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2038 throw 'abc'
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2039 finally
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2040 throw 'xyz'
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2041 endtry
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2042 catch
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2043 endtry
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2044 redir END
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2045 let expected = [
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2046 \ 'Exception thrown: abc', '',
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2047 \ 'Exception made pending: abc', '',
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2048 \ 'Exception thrown: xyz', '',
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2049 \ 'Exception discarded: abc', '',
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2050 \ 'Exception caught: xyz', '',
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2051 \ 'Exception finished: xyz']
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2052 call assert_equal(expected, split(msg, "\n"))
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2053
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2054 " Test for messages displayed when :throw is resumed after :finally
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2055 redir => msg
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2056 try
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2057 try
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2058 throw 'abc'
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2059 finally
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2060 endtry
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2061 catch
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2062 endtry
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2063 redir END
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2064 let expected = [
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2065 \ 'Exception thrown: abc', '',
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2066 \ 'Exception made pending: abc', '',
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2067 \ 'Exception resumed: abc', '',
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2068 \ 'Exception caught: abc', '',
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2069 \ 'Exception finished: abc']
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2070 call assert_equal(expected, split(msg, "\n"))
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2071
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2072 " Test for messages displayed when :break is resumed after :finally
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2073 redir => msg
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2074 for i in range(1)
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2075 try
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2076 break
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2077 finally
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2078 endtry
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2079 endfor
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2080 redir END
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2081 let expected = [':break made pending', '', ':break resumed']
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2082 call assert_equal(expected, split(msg, "\n"))
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2083
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2084 " Test for messages displayed when :continue is resumed after :finally
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2085 redir => msg
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2086 for i in range(1)
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2087 try
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2088 continue
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2089 finally
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2090 endtry
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2091 endfor
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2092 redir END
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2093 let expected = [':continue made pending', '', ':continue resumed']
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2094 call assert_equal(expected, split(msg, "\n"))
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2095
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2096 " Test for messages displayed when :return is resumed after :finally
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2097 func Xtest()
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2098 try
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2099 return 'vim'
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2100 finally
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2101 endtry
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2102 endfunc
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2103 redir => msg
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2104 call Xtest()
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2105 redir END
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2106 let expected = [
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2107 \ 'calling Xtest()', '',
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2108 \ ':return vim made pending', '',
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2109 \ ':return vim resumed', '',
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2110 \ 'Xtest returning ''vim''', '',
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2111 \ 'continuing in Test_try_catch_verbose']
19471
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2112 call assert_equal(expected, split(msg, "\n"))
19487
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2113 delfunc Xtest
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2114
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2115 " Test for messages displayed when :finish is resumed after :finally
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2116 call writefile(['try', 'finish', 'finally', 'endtry'], 'Xscript')
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2117 redir => msg
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2118 source Xscript
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2119 redir END
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2120 let expected = [
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2121 \ ':finish made pending', '',
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2122 \ ':finish resumed', '',
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2123 \ 'finished sourcing Xscript',
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2124 \ 'continuing in Test_try_catch_verbose']
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2125 call assert_equal(expected, split(msg, "\n")[1:])
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2126 call delete('Xscript')
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2127
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2128 " Test for messages displayed when a pending :continue is discarded by an
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2129 " exception in a finally handler
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2130 redir => msg
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2131 try
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2132 for i in range(1)
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2133 try
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2134 continue
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2135 finally
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2136 throw 'abc'
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2137 endtry
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2138 endfor
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2139 catch
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2140 endtry
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2141 redir END
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2142 let expected = [
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2143 \ ':continue made pending', '',
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2144 \ 'Exception thrown: abc', '',
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2145 \ ':continue discarded', '',
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2146 \ 'Exception caught: abc', '',
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2147 \ 'Exception finished: abc']
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2148 call assert_equal(expected, split(msg, "\n"))
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2149
19471
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2150 set verbose&
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2151 endfunc
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 18886
diff changeset
2152
19487
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2153 " Test for throwing an exception from a BufEnter autocmd {{{1
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2154 func Test_BufEnter_exception()
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2155 augroup bufenter_exception
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2156 au!
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2157 autocmd BufEnter Xfile1 throw 'abc'
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2158 augroup END
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2159
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2160 let caught_abc = 0
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2161 try
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2162 sp Xfile1
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2163 catch /^abc/
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2164 let caught_abc = 1
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2165 endtry
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2166 call assert_equal(1, caught_abc)
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2167 call assert_equal(1, winnr('$'))
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2168
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2169 augroup bufenter_exception
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2170 au!
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2171 augroup END
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2172 augroup! bufenter_exception
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2173 %bwipe!
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2174
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2175 " Test for recursively throwing exceptions in autocmds
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2176 augroup bufenter_exception
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2177 au!
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2178 autocmd BufEnter Xfile1 throw 'bufenter'
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2179 autocmd BufLeave Xfile1 throw 'bufleave'
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2180 augroup END
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2181
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2182 let ex_count = 0
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2183 try
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2184 try
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2185 sp Xfile1
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2186 catch /^bufenter/
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2187 let ex_count += 1
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2188 endtry
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2189 catch /^bufleave/
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2190 let ex_count += 10
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2191 endtry
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2192 call assert_equal(10, ex_count)
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2193 call assert_equal(2, winnr('$'))
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2194
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2195 augroup bufenter_exception
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2196 au!
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2197 augroup END
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2198 augroup! bufenter_exception
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2199 %bwipe!
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2200 endfunc
0aba9ef12488 patch 8.2.0301: insufficient testing for exception handling
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
2201
23191
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2202 " Test for using try/catch in a user command with a failing expression {{{1
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2203 func Test_user_command_try_catch()
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2204 let lines =<< trim END
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2205 function s:throw() abort
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2206 throw 'error'
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2207 endfunction
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2208
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2209 command! Execute
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2210 \ try
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2211 \ | let s:x = s:throw()
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2212 \ | catch
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2213 \ | let g:caught = 'caught'
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2214 \ | endtry
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2215
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2216 let g:caught = 'no'
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2217 Execute
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2218 call assert_equal('caught', g:caught)
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2219 END
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2220 call writefile(lines, 'XtestTryCatch')
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2221 source XtestTryCatch
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2222
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2223 call delete('XtestTryCatch')
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2224 unlet g:caught
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2225 endfunc
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22395
diff changeset
2226
25761
e855eba4ac39 patch 8.2.3416: second error is reported while exception is being thrown
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
2227 " Test for using throw in a called function with following error {{{1
e855eba4ac39 patch 8.2.3416: second error is reported while exception is being thrown
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
2228 func Test_user_command_throw_in_function_call()
e855eba4ac39 patch 8.2.3416: second error is reported while exception is being thrown
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
2229 let lines =<< trim END
e855eba4ac39 patch 8.2.3416: second error is reported while exception is being thrown
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
2230 function s:get_dict() abort
e855eba4ac39 patch 8.2.3416: second error is reported while exception is being thrown
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
2231 throw 'my_error'
e855eba4ac39 patch 8.2.3416: second error is reported while exception is being thrown
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
2232 endfunction
e855eba4ac39 patch 8.2.3416: second error is reported while exception is being thrown
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
2233
e855eba4ac39 patch 8.2.3416: second error is reported while exception is being thrown
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
2234 try
e855eba4ac39 patch 8.2.3416: second error is reported while exception is being thrown
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
2235 call s:get_dict().foo()
e855eba4ac39 patch 8.2.3416: second error is reported while exception is being thrown
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
2236 catch /my_error/
e855eba4ac39 patch 8.2.3416: second error is reported while exception is being thrown
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
2237 let caught = 'yes'
e855eba4ac39 patch 8.2.3416: second error is reported while exception is being thrown
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
2238 catch
e855eba4ac39 patch 8.2.3416: second error is reported while exception is being thrown
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
2239 let caught = 'no'
e855eba4ac39 patch 8.2.3416: second error is reported while exception is being thrown
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
2240 endtry
e855eba4ac39 patch 8.2.3416: second error is reported while exception is being thrown
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
2241 call assert_equal('yes', caught)
e855eba4ac39 patch 8.2.3416: second error is reported while exception is being thrown
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
2242 END
e855eba4ac39 patch 8.2.3416: second error is reported while exception is being thrown
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
2243 call writefile(lines, 'XtestThrow')
e855eba4ac39 patch 8.2.3416: second error is reported while exception is being thrown
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
2244 source XtestThrow
e855eba4ac39 patch 8.2.3416: second error is reported while exception is being thrown
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
2245
e855eba4ac39 patch 8.2.3416: second error is reported while exception is being thrown
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
2246 call delete('XtestThrow')
e855eba4ac39 patch 8.2.3416: second error is reported while exception is being thrown
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
2247 unlet g:caught
e855eba4ac39 patch 8.2.3416: second error is reported while exception is being thrown
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
2248 endfunc
e855eba4ac39 patch 8.2.3416: second error is reported while exception is being thrown
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
2249
e855eba4ac39 patch 8.2.3416: second error is reported while exception is being thrown
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
2250
18886
050f5eaa9e50 patch 8.2.0004: get E685 and E931 if buffer reload is interrupted
Bram Moolenaar <Bram@vim.org>
parents: 18504
diff changeset
2251 " Modeline {{{1
18504
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2252 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker