annotate src/testdir/test_vimscript.vim @ 30867:0913cd44fdfa v9.0.0768

patch 9.0.0768: too many delete() calls in tests Commit: https://github.com/vim/vim/commit/5b148ef2628251b2d79f78c65a614f8aca404329 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Oct 15 21:35:56 2022 +0100 patch 9.0.0768: too many delete() calls in tests Problem: Too many delete() calls in tests. Solution: Use deferred delete where possible.
author Bram Moolenaar <Bram@vim.org>
date Sat, 15 Oct 2022 22:45:02 +0200
parents f936d46cc9c1
children 360f286b5869
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13351
33a2277b8d4d patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents: 12523
diff changeset
1 " Test various aspects of the Vim script language.
21741
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
2 " Most of this was formerly in test49.vim (developed by Servatius Brandt
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
3 " <Servatius.Brandt@fujitsu-siemens.com>)
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4
17657
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17251
diff changeset
5 source check.vim
17698
131f1d8c5860 patch 8.1.1846: inconsistently using GetVimCommand() and v:progpath
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
6 source shared.vim
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
7 source script_util.vim
17657
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17251
diff changeset
8
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 " Test environment {{{1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 " Append a message to the "messages" file
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
14 func Xout(text)
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 split messages
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 $put =a:text
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 wq
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 com! -nargs=1 Xout call Xout(<args>)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
22 " Create a new instance of Vim and run the commands in 'test' and then 'verify'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
23 " The commands in 'test' are expected to store the test results in the Xtest.out
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
24 " file. If the test passes successfully, then Xtest.out should be empty.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
25 func RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
26 let init =<< trim END
21735
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
27 set cpo-=C " support line-continuation in sourced script
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
28 source script_util.vim
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
29 XpathINIT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
30 XloopINIT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
31 END
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
32 let cleanup =<< trim END
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
33 call writefile(v:errors, 'Xtest.out')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
34 qall
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
35 END
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
36 call writefile(init, 'Xtest.vim', 'D')
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
37 call writefile(a:test, 'Xtest.vim', 'a')
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
38 call writefile(a:verify, 'Xverify.vim', 'D')
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
39 call writefile(cleanup, 'Xverify.vim', 'a')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
40 call RunVim([], [], "-S Xtest.vim -S Xverify.vim")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
41 call assert_equal([], readfile('Xtest.out'))
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
42 call delete('Xtest.out')
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
43 endfunc
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 " Test 1: :endwhile in function {{{1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 " Detect if a broken loop is (incorrectly) reactivated by the
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 " :endwhile. Use a :return to prevent an endless loop, and make
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 " this test first to get a meaningful result on an error before other
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 " tests will hang.
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
54 func T1_F()
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 Xpath 'a'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 let first = 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 while 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 Xpath 'b'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 if first
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 Xpath 'c'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 let first = 0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 break
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 else
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 Xpath 'd'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 return
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 endwhile
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
68 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
69
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
70 func T1_G()
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 Xpath 'h'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 let first = 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 while 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 Xpath 'i'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 if first
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 Xpath 'j'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 let first = 0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 break
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 else
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 Xpath 'k'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 return
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 if 1 " unmatched :if
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 endwhile
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
85 endfunc
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 func Test_endwhile_function()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89 call T1_F()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 Xpath 'F'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92 try
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93 call T1_G()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94 catch
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
95 " Catch missing :endif
22087
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21925
diff changeset
96 call assert_true(v:exception =~ 'E171:')
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
97 Xpath 'x'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
98 endtry
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
99 Xpath 'G'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
100
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
101 call assert_equal('abcFhijxG', g:Xpath)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
102 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
104 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
105 " Test 2: :endwhile in script {{{1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
106 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107 " Detect if a broken loop is (incorrectly) reactivated by the
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
108 " :endwhile. Use a :finish to prevent an endless loop, and place
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
109 " this test before others that might hang to get a meaningful result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
110 " on an error.
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
111 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112 " This test executes the bodies of the functions T1_F and T1_G from
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
113 " the previous test as script files (:return replaced by :finish).
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
114 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
115
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
116 func Test_endwhile_script()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
117 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
118 ExecAsScript T1_F
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
119 Xpath 'F'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
120 call DeleteTheScript()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
121
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
122 try
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
123 ExecAsScript T1_G
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
124 catch
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
125 " Catch missing :endif
22087
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21925
diff changeset
126 call assert_true(v:exception =~ 'E171:')
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
127 Xpath 'x'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
128 endtry
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
129 Xpath 'G'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
130 call DeleteTheScript()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
131
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
132 call assert_equal('abcFhijxG', g:Xpath)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
133 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
134
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
135 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
136 " Test 3: :if, :elseif, :while, :continue, :break {{{1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
137 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
138
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
139 func Test_if_while()
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
140 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
141 if 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
142 Xpath 'a'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
143 let loops = 3
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
144 while loops > -1 " main loop: loops == 3, 2, 1 (which breaks)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
145 if loops <= 0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
146 let break_err = 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
147 let loops = -1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
148 else
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
149 Xpath 'b' . loops
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
151 if (loops == 2)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
152 while loops == 2 " dummy loop
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
153 Xpath 'c' . loops
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
154 let loops = loops - 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
155 continue " stop dummy loop
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
156 Xpath 'd' . loops
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
157 endwhile
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
158 continue " continue main loop
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
159 Xpath 'e' . loops
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
160 elseif (loops == 1)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
161 let p = 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
162 while p " dummy loop
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
163 Xpath 'f' . loops
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
164 let p = 0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
165 break " break dummy loop
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
166 Xpath 'g' . loops
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
167 endwhile
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
168 Xpath 'h' . loops
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
169 unlet p
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
170 break " break main loop
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
171 Xpath 'i' . loops
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
172 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
173 if (loops > 0)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
174 Xpath 'j' . loops
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
176 while loops == 3 " dummy loop
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
177 let loops = loops - 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178 endwhile " end dummy loop
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
179 endwhile " end main loop
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
180 Xpath 'k'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
181 else
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
182 Xpath 'l'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
183 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
184 Xpath 'm'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
185 if exists("break_err")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
186 Xpath 'm'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
187 unlet break_err
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
188 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
189
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
190 unlet loops
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
191
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
192 call assert_equal('ab3j3b2c2b1f1h1km', g:Xpath)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
193 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
194
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
195 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
196 " Test 4: :return {{{1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
197 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
198
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
199 func T4_F()
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
200 if 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
201 Xpath 'a'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
202 let loops = 3
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
203 while loops > 0 " 3: 2: 1:
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
204 Xpath 'b' . loops
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
205 if (loops == 2)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
206 Xpath 'c' . loops
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
207 return
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
208 Xpath 'd' . loops
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
209 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
210 Xpath 'e' . loops
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
211 let loops = loops - 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
212 endwhile
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
213 Xpath 'f'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
214 else
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
215 Xpath 'g'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
216 endif
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
217 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
218
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
219 func Test_return()
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
220 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
221 call T4_F()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
222 Xpath '4'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
223
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
224 call assert_equal('ab3e3b2c24', g:Xpath)
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
225 endfunc
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
226
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
227
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
228 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
229 " Test 5: :finish {{{1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
230 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
231 " This test executes the body of the function T4_F from the previous
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
232 " test as a script file (:return replaced by :finish).
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
233 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
234
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
235 func Test_finish()
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
236 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
237 ExecAsScript T4_F
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
238 Xpath '5'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
239 call DeleteTheScript()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
240
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
241 call assert_equal('ab3e3b2c25', g:Xpath)
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
242 endfunc
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
243
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
244
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
245
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
246 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
247 " Test 6: Defining functions in :while loops {{{1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
248 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
249 " Functions can be defined inside other functions. An inner function
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
250 " gets defined when the outer function is executed. Functions may
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
251 " also be defined inside while loops. Expressions in braces for
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
252 " defining the function name are allowed.
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
253 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
254 " The functions are defined when sourcing the script, only the
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
255 " resulting path is checked in the test function.
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
256 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
257
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
258 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
259
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
260 " The command CALL collects the argument of all its invocations in "calls"
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
261 " when used from a function (that is, when the global variable "calls" needs
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
262 " the "g:" prefix). This is to check that the function code is skipped when
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
263 " the function is defined. For inner functions, do so only if the outer
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
264 " function is not being executed.
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
265 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
266 let calls = ""
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
267 com! -nargs=1 CALL
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
268 \ if !exists("calls") && !exists("outer") |
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
269 \ let g:calls = g:calls . <args> |
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
270 \ endif
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
271
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
272 let i = 0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
273 while i < 3
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
274 let i = i + 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
275 if i == 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
276 Xpath 'a'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
277 function! F1(arg)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
278 CALL a:arg
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
279 let outer = 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
280
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
281 let j = 0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
282 while j < 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
283 Xpath 'b'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
284 let j = j + 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
285 function! G1(arg)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
286 CALL a:arg
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
287 endfunction
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
288 Xpath 'c'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
289 endwhile
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
290 endfunction
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
291 Xpath 'd'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
292
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
293 continue
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
294 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
295
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
296 Xpath 'e' . i
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
297 function! F{i}(i, arg)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
298 CALL a:arg
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
299 let outer = 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
300
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
301 if a:i == 3
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
302 Xpath 'f'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
303 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
304 let k = 0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
305 while k < 3
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
306 Xpath 'g' . k
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
307 let k = k + 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
308 function! G{a:i}{k}(arg)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
309 CALL a:arg
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
310 endfunction
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
311 Xpath 'h' . k
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
312 endwhile
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
313 endfunction
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
314 Xpath 'i'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
315
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
316 endwhile
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
317
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
318 if exists("*G1")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
319 Xpath 'j'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
320 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
321 if exists("*F1")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
322 call F1("F1")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
323 if exists("*G1")
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
324 call G1("G1")
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
325 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
326 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
327
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
328 if exists("G21") || exists("G22") || exists("G23")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
329 Xpath 'k'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
330 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
331 if exists("*F2")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
332 call F2(2, "F2")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
333 if exists("*G21")
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
334 call G21("G21")
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
335 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
336 if exists("*G22")
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
337 call G22("G22")
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
338 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
339 if exists("*G23")
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
340 call G23("G23")
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
341 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
342 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
343
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
344 if exists("G31") || exists("G32") || exists("G33")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
345 Xpath 'l'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
346 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
347 if exists("*F3")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
348 call F3(3, "F3")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
349 if exists("*G31")
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
350 call G31("G31")
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
351 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
352 if exists("*G32")
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
353 call G32("G32")
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
354 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
355 if exists("*G33")
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
356 call G33("G33")
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
357 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
358 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
359
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
360 Xpath 'm'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
361
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
362 let g:test6_result = g:Xpath
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
363 let g:test6_calls = calls
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
364
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
365 unlet calls
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
366 delfunction F1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
367 delfunction G1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
368 delfunction F2
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
369 delfunction G21
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
370 delfunction G22
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
371 delfunction G23
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
372 delfunction G31
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
373 delfunction G32
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
374 delfunction G33
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
375
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
376 func Test_defining_functions()
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
377 call assert_equal('ade2ie3ibcg0h1g1h2g2h3fg0h1g1h2g2h3m', g:test6_result)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
378 call assert_equal('F1G1F2G21G22G23F3G31G32G33', g:test6_calls)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
379 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
380
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
381 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
382 " Test 7: Continuing on errors outside functions {{{1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
383 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
384 " On an error outside a function, the script processing continues
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
385 " at the line following the outermost :endif or :endwhile. When not
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
386 " inside an :if or :while, the script processing continues at the next
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
387 " line.
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
388 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
389
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
390 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
391
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
392 if 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
393 Xpath 'a'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
394 while 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
395 Xpath 'b'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
396 asdf
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
397 Xpath 'c'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
398 break
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
399 endwhile | Xpath 'd'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
400 Xpath 'e'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
401 endif | Xpath 'f'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
402 Xpath 'g'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
403
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
404 while 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
405 Xpath 'h'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
406 if 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
407 Xpath 'i'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
408 asdf
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
409 Xpath 'j'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
410 endif | Xpath 'k'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
411 Xpath 'l'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
412 break
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
413 endwhile | Xpath 'm'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
414 Xpath 'n'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
415
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
416 asdf
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
417 Xpath 'o'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
418
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
419 asdf | Xpath 'p'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
420 Xpath 'q'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
421
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
422 let g:test7_result = g:Xpath
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
423
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
424 func Test_error_in_script()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
425 call assert_equal('abghinoq', g:test7_result)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
426 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
427
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
428 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
429 " Test 8: Aborting and continuing on errors inside functions {{{1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
430 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
431 " On an error inside a function without the "abort" attribute, the
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
432 " script processing continues at the next line (unless the error was
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
433 " in a :return command). On an error inside a function with the
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
434 " "abort" attribute, the function is aborted and the script processing
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
435 " continues after the function call; the value -1 is returned then.
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
436 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
437
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
438 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
439
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
440 func T8_F()
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
441 if 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
442 Xpath 'a'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
443 while 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
444 Xpath 'b'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
445 asdf
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
446 Xpath 'c'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
447 asdf | Xpath 'd'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
448 Xpath 'e'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
449 break
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
450 endwhile
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
451 Xpath 'f'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
452 endif | Xpath 'g'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
453 Xpath 'h'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
454
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
455 while 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
456 Xpath 'i'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
457 if 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
458 Xpath 'j'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
459 asdf
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
460 Xpath 'k'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
461 asdf | Xpath 'l'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
462 Xpath 'm'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
463 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
464 Xpath 'n'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
465 break
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
466 endwhile | Xpath 'o'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
467 Xpath 'p'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
468
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
469 return novar " returns (default return value 0)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
470 Xpath 'q'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
471 return 1 " not reached
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
472 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
473
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
474 func T8_G() abort
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
475 if 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
476 Xpath 'r'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
477 while 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
478 Xpath 's'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
479 asdf " returns -1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
480 Xpath 't'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
481 break
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
482 endwhile
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
483 Xpath 'v'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
484 endif | Xpath 'w'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
485 Xpath 'x'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
486
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
487 return -4 " not reached
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
488 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
489
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
490 func T8_H() abort
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
491 while 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
492 Xpath 'A'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
493 if 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
494 Xpath 'B'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
495 asdf " returns -1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
496 Xpath 'C'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
497 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
498 Xpath 'D'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
499 break
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
500 endwhile | Xpath 'E'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
501 Xpath 'F'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
502
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
503 return -4 " not reached
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
504 endfunc
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
505
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
506 " Aborted functions (T8_G and T8_H) return -1.
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
507 let g:test8_sum = (T8_F() + 1) - 4 * T8_G() - 8 * T8_H()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
508 Xpath 'X'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
509 let g:test8_result = g:Xpath
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
510
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
511 func Test_error_in_function()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
512 call assert_equal(13, g:test8_sum)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
513 call assert_equal('abcefghijkmnoprsABX', g:test8_result)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
514
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
515 delfunction T8_F
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
516 delfunction T8_G
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
517 delfunction T8_H
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
518 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
519
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
520
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
521 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
522 " Test 9: Continuing after aborted functions {{{1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
523 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
524 " When a function with the "abort" attribute is aborted due to an
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
525 " error, the next function back in the call hierarchy without an
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
526 " "abort" attribute continues; the value -1 is returned then.
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
527 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
528
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
529 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
530
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
531 func F() abort
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
532 Xpath 'a'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
533 let result = G() " not aborted
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
534 Xpath 'b'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
535 if result != 2
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
536 Xpath 'c'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
537 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
538 return 1
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
539 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
540
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
541 func G() " no abort attribute
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
542 Xpath 'd'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
543 if H() != -1 " aborted
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
544 Xpath 'e'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
545 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
546 Xpath 'f'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
547 return 2
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
548 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
549
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
550 func H() abort
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
551 Xpath 'g'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
552 call I() " aborted
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
553 Xpath 'h'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
554 return 4
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
555 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
556
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
557 func I() abort
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
558 Xpath 'i'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
559 asdf " error
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
560 Xpath 'j'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
561 return 8
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
562 endfunc
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
563
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
564 if F() != 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
565 Xpath 'k'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
566 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
567
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
568 let g:test9_result = g:Xpath
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
569
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
570 delfunction F
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
571 delfunction G
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
572 delfunction H
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
573 delfunction I
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
574
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
575 func Test_func_abort()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
576 call assert_equal('adgifb', g:test9_result)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
577 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
578
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
579
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
580 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
581 " Test 10: :if, :elseif, :while argument parsing {{{1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
582 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
583 " A '"' or '|' in an argument expression must not be mixed up with
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
584 " a comment or a next command after a bar. Parsing errors should
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
585 " be recognized.
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
586 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
587
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
588 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
589
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
590 func MSG(enr, emsg)
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
591 let english = v:lang == "C" || v:lang =~ '^[Ee]n'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
592 if a:enr == ""
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
593 Xout "TODO: Add message number for:" a:emsg
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
594 let v:errmsg = ":" . v:errmsg
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
595 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
596 let match = 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
597 if v:errmsg !~ '^'.a:enr.':' || (english && v:errmsg !~ a:emsg)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
598 let match = 0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
599 if v:errmsg == ""
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
600 Xout "Message missing."
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
601 else
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
602 let v:errmsg = v:errmsg->escape('"')
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
603 Xout "Unexpected message:" v:errmsg
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
604 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
605 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
606 return match
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
607 endfunc
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
608
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
609 if 1 || strlen("\"") | Xpath 'a'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
610 Xpath 'b'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
611 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
612 Xpath 'c'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
613
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
614 if 0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
615 elseif 1 || strlen("\"") | Xpath 'd'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
616 Xpath 'e'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
617 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
618 Xpath 'f'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
619
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
620 while 1 || strlen("\"") | Xpath 'g'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
621 Xpath 'h'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
622 break
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
623 endwhile
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
624 Xpath 'i'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
625
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
626 let v:errmsg = ""
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
627 if 1 ||| strlen("\"") | Xpath 'j'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
628 Xpath 'k'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
629 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
630 Xpath 'l'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
631 if !MSG('E15', "Invalid expression")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
632 Xpath 'm'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
633 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
634
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
635 let v:errmsg = ""
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
636 if 0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
637 elseif 1 ||| strlen("\"") | Xpath 'n'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
638 Xpath 'o'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
639 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
640 Xpath 'p'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
641 if !MSG('E15', "Invalid expression")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
642 Xpath 'q'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
643 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
644
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
645 let v:errmsg = ""
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
646 while 1 ||| strlen("\"") | Xpath 'r'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
647 Xpath 's'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
648 break
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
649 endwhile
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
650 Xpath 't'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
651 if !MSG('E15', "Invalid expression")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
652 Xpath 'u'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
653 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
654
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
655 let g:test10_result = g:Xpath
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
656 delfunction MSG
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
657
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
658 func Test_expr_parsing()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
659 call assert_equal('abcdefghilpt', g:test10_result)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
660 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
661
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
662
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
663 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
664 " Test 11: :if, :elseif, :while argument evaluation after abort {{{1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
665 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
666 " When code is skipped over due to an error, the boolean argument to
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
667 " an :if, :elseif, or :while must not be evaluated.
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
668 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
669
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
670 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
671
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
672 let calls = 0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
673
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
674 func P(num)
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
675 let g:calls = g:calls + a:num " side effect on call
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
676 return 0
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
677 endfunc
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
678
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
679 if 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
680 Xpath 'a'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
681 asdf " error
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
682 Xpath 'b'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
683 if P(1) " should not be called
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
684 Xpath 'c'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
685 elseif !P(2) " should not be called
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
686 Xpath 'd'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
687 else
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
688 Xpath 'e'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
689 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
690 Xpath 'f'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
691 while P(4) " should not be called
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
692 Xpath 'g'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
693 endwhile
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
694 Xpath 'h'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
695 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
696 Xpath 'x'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
697
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
698 let g:test11_calls = calls
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
699 let g:test11_result = g:Xpath
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
700
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
701 unlet calls
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
702 delfunction P
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
703
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
704 func Test_arg_abort()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
705 call assert_equal(0, g:test11_calls)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
706 call assert_equal('ax', g:test11_result)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
707 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
708
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
709
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
710 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
711 " Test 12: Expressions in braces in skipped code {{{1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
712 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
713 " In code skipped over due to an error or inactive conditional,
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
714 " an expression in braces as part of a variable or function name
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
715 " should not be evaluated.
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
716 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
717
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
718 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
719
30687
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
720 func NULL()
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
721 Xpath 'a'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
722 return 0
30687
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
723 endfunc
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
724
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
725 func ZERO()
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
726 Xpath 'b'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
727 return 0
30687
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
728 endfunc
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
729
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
730 func! F0()
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
731 Xpath 'c'
30687
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
732 endfunc
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
733
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
734 func! F1(arg)
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
735 Xpath 'e'
30687
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
736 endfunc
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
737
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
738 let V0 = 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
739
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
740 Xpath 'f'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
741 echo 0 ? F{NULL() + V{ZERO()}}() : 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
742
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
743 Xpath 'g'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
744 if 0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
745 Xpath 'h'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
746 call F{NULL() + V{ZERO()}}()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
747 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
748
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
749 Xpath 'i'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
750 if 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
751 asdf " error
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
752 Xpath 'j'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
753 call F1(F{NULL() + V{ZERO()}}())
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
754 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
755
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
756 Xpath 'k'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
757 if 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
758 asdf " error
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
759 Xpath 'l'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
760 call F{NULL() + V{ZERO()}}()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
761 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
762
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
763 let g:test12_result = g:Xpath
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
764
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
765 func Test_braces_skipped()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
766 call assert_equal('fgik', g:test12_result)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
767 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
768
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
769
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
770 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
771 " Test 13: Failure in argument evaluation for :while {{{1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
772 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
773 " A failure in the expression evaluation for the condition of a :while
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
774 " causes the whole :while loop until the matching :endwhile being
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
775 " ignored. Continuation is at the next following line.
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
776 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
777
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
778 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
779
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
780 Xpath 'a'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
781 while asdf
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
782 Xpath 'b'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
783 while 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
784 Xpath 'c'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
785 break
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
786 endwhile
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
787 Xpath 'd'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
788 break
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
789 endwhile
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
790 Xpath 'e'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
791
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
792 while asdf | Xpath 'f' | endwhile | Xpath 'g'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
793 Xpath 'h'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
794 let g:test13_result = g:Xpath
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
795
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
796 func Test_while_fail()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
797 call assert_equal('aeh', g:test13_result)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
798 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
799
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
800
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
801 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
802 " Test 14: Failure in argument evaluation for :if {{{1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
803 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
804 " A failure in the expression evaluation for the condition of an :if
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
805 " does not cause the corresponding :else or :endif being matched to
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
806 " a previous :if/:elseif. Neither of both branches of the failed :if
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
807 " are executed.
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
808 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
809
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
810 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
811
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
812 function! F()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
813 Xpath 'a'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
814 let x = 0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
815 if x " false
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
816 Xpath 'b'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
817 elseif !x " always true
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
818 Xpath 'c'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
819 let x = 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
820 if g:boolvar " possibly undefined
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
821 Xpath 'd'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
822 else
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
823 Xpath 'e'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
824 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
825 Xpath 'f'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
826 elseif x " never executed
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
827 Xpath 'g'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
828 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
829 Xpath 'h'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
830 endfunction
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
831
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
832 let boolvar = 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
833 call F()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
834 Xpath '-'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
835
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
836 unlet boolvar
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
837 call F()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
838 let g:test14_result = g:Xpath
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
839
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
840 delfunction F
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
841
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
842 func Test_if_fail()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
843 call assert_equal('acdfh-acfh', g:test14_result)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
844 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
845
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
846
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
847 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
848 " Test 15: Failure in argument evaluation for :if (bar) {{{1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
849 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
850 " Like previous test, except that the failing :if ... | ... | :endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
851 " is in a single line.
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
852 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
853
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
854 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
855
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
856 function! F()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
857 Xpath 'a'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
858 let x = 0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
859 if x " false
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
860 Xpath 'b'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
861 elseif !x " always true
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
862 Xpath 'c'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
863 let x = 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
864 if g:boolvar | Xpath 'd' | else | Xpath 'e' | endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
865 Xpath 'f'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
866 elseif x " never executed
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
867 Xpath 'g'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
868 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
869 Xpath 'h'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
870 endfunction
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
871
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
872 let boolvar = 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
873 call F()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
874 Xpath '-'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
875
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
876 unlet boolvar
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
877 call F()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
878 let g:test15_result = g:Xpath
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
879
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
880 delfunction F
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
881
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
882 func Test_if_bar_fail()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
883 call assert_equal('acdfh-acfh', g:test15_result)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
884 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
885
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
886 "-------------------------------------------------------------------------------
18504
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
887 " Test 16: Double :else or :elseif after :else {{{1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
888 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
889 " Multiple :elses or an :elseif after an :else are forbidden.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
890 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
891
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
892 func T16_F() abort
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
893 if 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
894 Xpath 'a'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
895 else
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
896 Xpath 'b'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
897 else " aborts function
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
898 Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
899 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
900 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
901 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
902
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
903 func T16_G() abort
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
904 if 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
905 Xpath 'a'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
906 else
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
907 Xpath 'b'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
908 elseif 1 " aborts function
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
909 Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
910 else
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
911 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
912 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
913 Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
914 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
915
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
916 func T16_H() abort
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
917 if 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
918 Xpath 'a'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
919 elseif 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
920 Xpath 'b'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
921 else
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
922 Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
923 else " aborts function
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
924 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
925 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
926 Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
927 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
928
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
929 func T16_I() abort
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
930 if 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
931 Xpath 'a'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
932 elseif 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
933 Xpath 'b'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
934 else
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
935 Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
936 elseif 1 " aborts function
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
937 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
938 else
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
939 Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
940 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
941 Xpath 'f'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
942 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
943
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
944 func Test_Multi_Else()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
945 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
946 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
947 call T16_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
948 catch /E583:/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
949 Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
950 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
951 call assert_equal('be', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
952
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
953 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
954 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
955 call T16_G()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
956 catch /E584:/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
957 Xpath 'f'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
958 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
959 call assert_equal('bf', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
960
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
961 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
962 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
963 call T16_H()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
964 catch /E583:/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
965 Xpath 'f'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
966 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
967 call assert_equal('cf', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
968
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
969 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
970 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
971 call T16_I()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
972 catch /E584:/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
973 Xpath 'g'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
974 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
975 call assert_equal('cg', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
976 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
977
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
978 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
979 " Test 17: Nesting of unmatched :if or :endif inside a :while {{{1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
980 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
981 " The :while/:endwhile takes precedence in nesting over an unclosed
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
982 " :if or an unopened :endif.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
983 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
984
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
985 " While loops inside a function are continued on error.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
986 func T17_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
987 let loops = 3
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
988 while loops > 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
989 let loops -= 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
990 Xpath 'a' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
991 if (loops == 1)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
992 Xpath 'b' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
993 continue
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
994 elseif (loops == 0)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
995 Xpath 'c' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
996 break
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
997 elseif 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
998 Xpath 'd' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
999 " endif missing!
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1000 endwhile " :endwhile after :if 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1001 Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1002 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1003
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1004 func T17_G()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1005 let loops = 2
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1006 while loops > 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1007 let loops -= 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1008 Xpath 'a' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1009 if 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1010 Xpath 'b' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1011 " endif missing
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1012 endwhile " :endwhile after :if 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1013 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1014
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1015 func T17_H()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1016 let loops = 2
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1017 while loops > 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1018 let loops -= 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1019 Xpath 'a' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1020 " if missing!
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1021 endif " :endif without :if in while
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1022 Xpath 'b' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1023 endwhile
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1024 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1025
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1026 " Error continuation outside a function is at the outermost :endwhile or :endif.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1027 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1028 let v:errmsg = ''
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1029 let loops = 2
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1030 while loops > 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1031 let loops -= 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1032 Xpath 'a' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1033 if 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1034 Xpath 'b' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1035 " endif missing! Following :endwhile fails.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1036 endwhile | Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1037 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1038 call assert_match('E171:', v:errmsg)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1039 call assert_equal('a1d', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1040
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1041 func Test_unmatched_if_in_while()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1042 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1043 call assert_fails('call T17_F()', 'E171:')
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1044 call assert_equal('a2d2a1b1a0c0e', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1045
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1046 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1047 call assert_fails('call T17_G()', 'E171:')
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1048 call assert_equal('a1a0', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1049
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1050 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1051 call assert_fails('call T17_H()', 'E580:')
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1052 call assert_equal('a1b1a0b0', g:Xpath)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1053 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1054
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1055 "-------------------------------------------------------------------------------
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1056 " Test 18: Interrupt (Ctrl-C pressed) {{{1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1057 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1058 " On an interrupt, the script processing is terminated immediately.
18504
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1059 "-------------------------------------------------------------------------------
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1060
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1061 func Test_interrupt_while_if()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1062 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1063 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1064 if 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1065 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1066 while 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1067 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1068 if 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1069 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1070 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1071 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1072 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1073 finish
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1074 endif | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1075 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1076 endwhile | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1077 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1078 endif | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1079 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1080 catch /^Vim:Interrupt$/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1081 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1082 endtry | Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1083 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1084 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1085 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1086 call assert_equal('abcdef', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1087 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1088 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1089 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1090
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1091 func Test_interrupt_try()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1092 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1093 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1094 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1095 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1096 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1097 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1098 endtry | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1099 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1100 catch /^Vim:Interrupt$/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1101 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1102 endtry | Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1103 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1104 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1105 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1106 call assert_equal('abcd', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1107 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1108 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1109 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1110
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1111 func Test_interrupt_func_while_if()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1112 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1113 func F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1114 if 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1115 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1116 while 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1117 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1118 if 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1119 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1120 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1121 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1122 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1123 return
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1124 endif | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1125 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1126 endwhile | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1127 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1128 endif | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1129 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1130 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1131
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1132 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1133 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1134 call F() | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1135 catch /^Vim:Interrupt$/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1136 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1137 endtry | Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1138 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1139 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1140 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1141 call assert_equal('dabcefg', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1142 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1143 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1144 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1145
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1146 func Test_interrupt_func_try()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1147 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1148 func G()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1149 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1150 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1151 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1152 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1153 endtry | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1154 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1155 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1156
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1157 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1158 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1159 call G() | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1160 catch /^Vim:Interrupt$/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1161 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1162 endtry | Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1163 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1164 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1165 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1166 call assert_equal('bacde', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1167 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1168 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1169 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1170
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1171 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1172 " Test 19: Aborting on errors inside :try/:endtry {{{1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1173 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1174 " An error in a command dynamically enclosed in a :try/:endtry region
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1175 " aborts script processing immediately. It does not matter whether
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1176 " the failing command is outside or inside a function and whether a
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1177 " function has an "abort" attribute.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1178 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1179
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1180 func Test_try_error_abort_1()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1181 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1182 func F() abort
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1183 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1184 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1185 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1186 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1187
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1188 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1189 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1190 call F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1191 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1192 endtry | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1193 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1194 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1195 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1196 call assert_equal('ba', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1197 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1198 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1199 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1200
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1201 func Test_try_error_abort_2()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1202 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1203 func G()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1204 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1205 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1206 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1207 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1208
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1209 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1210 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1211 call G()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1212 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1213 endtry | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1214 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1215 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1216 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1217 call assert_equal('ba', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1218 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1219 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1220 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1221
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1222 func Test_try_error_abort_3()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1223 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1224 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1225 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1226 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1227 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1228 endtry | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1229 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1230 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1231 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1232 call assert_equal('a', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1233 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1234 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1235 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1236
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1237 func Test_try_error_abort_4()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1238 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1239 if 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1240 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1241 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1242 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1243 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1244 endtry | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1245 endif | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1246 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1247 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1248 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1249 call assert_equal('a', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1250 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1251 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1252 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1253
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1254 func Test_try_error_abort_5()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1255 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1256 let p = 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1257 while p
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1258 let p = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1259 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1260 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1261 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1262 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1263 endtry | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1264 endwhile | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1265 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1266 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1267 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1268 call assert_equal('a', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1269 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1270 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1271 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1272
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1273 func Test_try_error_abort_6()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1274 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1275 let p = 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1276 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1277 while p
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1278 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1279 let p = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1280 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1281 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1282 endwhile | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1283 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1284 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1285 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1286 call assert_equal('abc', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1287 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1288 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1289 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1290
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1291 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1292 " Test 20: Aborting on errors after :try/:endtry {{{1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1293 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1294 " When an error occurs after the last active :try/:endtry region has
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1295 " been left, termination behavior is as if no :try/:endtry has been
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1296 " seen.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1297 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1298
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1299 func Test_error_after_try_1()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1300 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1301 let p = 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1302 while p
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1303 let p = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1304 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1305 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1306 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1307 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1308 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1309 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1310 endwhile | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1311 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1312 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1313 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1314 call assert_equal('abc', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1315 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1316 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1317 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1318
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1319 func Test_error_after_try_2()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1320 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1321 while 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1322 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1323 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1324 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1325 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1326 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1327 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1328 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1329 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1330 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1331 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1332 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1333 call assert_equal('abc', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1334 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1335 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1336 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1337
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1338 func Test_error_after_try_3()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1339 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1340 while 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1341 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1342 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1343 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1344 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1345 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1346 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1347 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1348 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1349 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1350 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1351 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1352 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1353 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1354 call assert_equal('abcd', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1355 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1356 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1357 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1358
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1359 func Test_error_after_try_4()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1360 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1361 while 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1362 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1363 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1364 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1365 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1366 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1367 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1368 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1369 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1370 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1371 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1372 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1373 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1374 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1375 call assert_equal('abcd', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1376 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1377 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1378 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1379
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1380 func Test_error_after_try_5()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1381 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1382 let p = 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1383 while p
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1384 let p = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1385 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1386 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1387 continue
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1388 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1389 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1390 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1391 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1392 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1393 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1394 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1395 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1396 call assert_equal('abc', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1397 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1398 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1399 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1400
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1401 func Test_error_after_try_6()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1402 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1403 let p = 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1404 while p
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1405 let p = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1406 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1407 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1408 continue
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1409 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1410 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1411 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1412 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1413 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1414 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1415 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1416 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1417 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1418 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1419 call assert_equal('abcd', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1420 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1421 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1422 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1423
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1424 func Test_error_after_try_7()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1425 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1426 let p = 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1427 while p
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1428 let p = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1429 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1430 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1431 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1432 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1433 continue
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1434 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1435 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1436 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1437 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1438 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1439 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1440 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1441 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1442 call assert_equal('abcd', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1443 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1444 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1445 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1446
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1447 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1448 " Test 21: :finally for :try after :continue/:break/:return/:finish {{{1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1449 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1450 " If a :try conditional stays inactive due to a preceding :continue,
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1451 " :break, :return, or :finish, its :finally clause should not be
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1452 " executed.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1453 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1454
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1455 func Test_finally_after_loop_ctrl_statement()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1456 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1457 func F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1458 let loops = 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1459 while loops > 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1460 XloopNEXT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1461 let loops = loops - 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1462 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1463 if loops == 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1464 Xloop 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1465 continue
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1466 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1467 elseif loops == 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1468 Xloop 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1469 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1470 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1471 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1472
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1473 try " inactive
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1474 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1475 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1476 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1477 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1478 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1479 Xloop 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1480 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1481 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1482 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1483
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1484 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1485 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1486 return
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1487 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1488 try " inactive
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1489 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1490 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1491 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1492 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1493 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1494 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1495 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1496 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1497 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1498
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1499 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1500 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1501 call F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1502 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1503 finish
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1504 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1505 try " inactive
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1506 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1507 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1508 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1509 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1510 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1511 Xpath 'h'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1512 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1513 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1514 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1515 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1516 call assert_equal('fa2c2b3c3degh', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1517 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1518 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1519 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1520
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1521 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1522 " Test 22: :finally for a :try after an error/interrupt/:throw {{{1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1523 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1524 " If a :try conditional stays inactive due to a preceding error or
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1525 " interrupt or :throw, its :finally clause should not be executed.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1526 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1527
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1528 func Test_finally_after_error_in_func()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1529 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1530 func Error()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1531 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1532 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1533 asdf " aborting error, triggering error exception
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1534 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1535 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1536 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1537 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1538
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1539 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1540 call Error()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1541 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1542
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1543 if 1 " not active due to error
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1544 try " not active since :if inactive
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1545 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1546 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1547 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1548 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1549 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1550
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1551 try " not active due to error
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1552 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1553 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1554 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1555 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1556 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1557 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1558 call assert_equal('ab', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1559 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1560 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1561 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1562
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1563 func Test_finally_after_interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1564 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1565 func Interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1566 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1567 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1568 call interrupt() " triggering interrupt exception
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1569 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1570 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1571 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1572
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1573 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1574 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1575 call Interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1576 catch /^Vim:Interrupt$/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1577 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1578 finish
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1579 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1580 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1581
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1582 if 1 " not active due to interrupt
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1583 try " not active since :if inactive
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1584 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1585 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1586 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1587 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1588 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1589
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1590 try " not active due to interrupt
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1591 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1592 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1593 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1594 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1595 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1596 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1597 call assert_equal('bac', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1598 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1599 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1600 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1601
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1602 func Test_finally_after_throw()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1603 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1604 func Throw()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1605 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1606 throw 'xyz'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1607 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1608
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1609 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1610 call Throw()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1611 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1612
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1613 if 1 " not active due to :throw
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1614 try " not active since :if inactive
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1615 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1616 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1617 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1618 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1619 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1620
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1621 try " not active due to :throw
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1622 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1623 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1624 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1625 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1626 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1627 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1628 call assert_equal('ba', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1629 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1630 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1631 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1633 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1634 " Test 23: :catch clauses for a :try after a :throw {{{1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1635 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1636 " If a :try conditional stays inactive due to a preceding :throw,
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1637 " none of its :catch clauses should be executed.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1638 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1639
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1640 func Test_catch_after_throw()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1641 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1642 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1643 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1644 throw "xyz"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1645 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1646
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1647 if 1 " not active due to :throw
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1648 try " not active since :if inactive
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1649 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1650 catch /xyz/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1651 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1652 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1653 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1654 catch /xyz/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1655 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1656 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1657
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1658 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1659 throw "abc"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1660 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1661
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1662 try " not active due to :throw
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1663 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1664 catch /abc/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1665 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1666 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1667 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1668 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1669 call assert_equal('abc', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1670 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1671 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1672 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1673
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1674 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1675 " Test 24: :endtry for a :try after a :throw {{{1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1676 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1677 " If a :try conditional stays inactive due to a preceding :throw,
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1678 " its :endtry should not rethrow the exception to the next surrounding
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1679 " active :try conditional.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1680 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1681
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1682 func Test_endtry_after_throw()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1683 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1684 try " try 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1685 try " try 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1686 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1687 throw "xyz" " makes try 2 inactive
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1688 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1689
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1690 try " try 3
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1691 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1692 endtry " no rethrow to try 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1693 catch /xyz/ " should catch although try 2 inactive
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1694 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1695 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1696 catch /xyz/ " try 1 active, but exception already caught
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1697 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1698 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1699 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1700 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1701 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1702 call assert_equal('abc', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1703 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1704 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1705 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1706
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1707 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1708 " Test 27: Executing :finally clauses after :return {{{1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1709 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1710 " For a :return command dynamically enclosed in a :try/:endtry region,
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1711 " :finally clauses are executed and the called function is ended.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1712 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1713
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1714 func T27_F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1715 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1716 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1717 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1718 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1719 return
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1720 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1721 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1722 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1723 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1724 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1725 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1726 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1727 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1728 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1729 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1730
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1731 func T27_G()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1732 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1733 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1734 return
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1735 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1736 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1737 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1738 call T27_F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1739 Xpath 'h'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1740 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1741 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1742 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1743
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1744 func T27_H()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1745 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1746 Xpath 'i'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1747 call T27_G()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1748 Xpath 'j'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1749 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1750 Xpath 'k'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1751 return
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1752 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1753 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1754 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1755 endfunction
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1756
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1757 func Test_finally_after_return()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1758 XpathINIT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1759 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1760 Xpath 'l'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1761 call T27_H()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1762 Xpath 'm'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1763 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1764 Xpath 'n'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1765 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1766 call assert_equal('lifgabcehjkmn', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1767 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1768
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1769 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1770 " Test 28: Executing :finally clauses after :finish {{{1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1771 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1772 " For a :finish command dynamically enclosed in a :try/:endtry region,
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1773 " :finally clauses are executed and the sourced file is finished.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1774 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1775 " This test executes the bodies of the functions F, G, and H from the
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1776 " previous test as script files (:return replaced by :finish).
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1777 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1778
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1779 func Test_finally_after_finish()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1780 XpathINIT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1781
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1782 let scriptF = MakeScript("T27_F")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1783 let scriptG = MakeScript("T27_G", scriptF)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1784 let scriptH = MakeScript("T27_H", scriptG)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1785
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1786 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1787 Xpath 'A'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1788 exec "source" scriptH
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1789 Xpath 'B'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1790 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1791 Xpath 'C'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1792 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1793 Xpath 'D'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1794 call assert_equal('AifgabcehjkBCD', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1795 call delete(scriptF)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1796 call delete(scriptG)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1797 call delete(scriptH)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1798 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1799
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1800 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1801 " Test 29: Executing :finally clauses on errors {{{1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1802 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1803 " After an error in a command dynamically enclosed in a :try/:endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1804 " region, :finally clauses are executed and the script processing is
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1805 " terminated.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1806 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1807
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1808 func Test_finally_after_error_1()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1809 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1810 func F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1811 while 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1812 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1813 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1814 while 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1815 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1816 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1817 asdf " error
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1818 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1819 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1820 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1821 endtry | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1822 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1823 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1824 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1825 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1826 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1827 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1828 endtry | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1829 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1830 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1831 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1832 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1833 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1834
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1835 while 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1836 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1837 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1838 while 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1839 call F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1840 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1841 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1842 endwhile | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1843 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1844 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1845 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1846 endtry | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1847 endwhile | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1848 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1849 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1850 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1851 call assert_equal('eabcdf', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1852 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1853 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1854 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1855
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1856 func Test_finally_after_error_2()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1857 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1858 func G() abort
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1859 if 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1860 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1861 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1862 asdf " error
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1863 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1864 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1865 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1866 endtry | Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1867 endif | Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1868 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1869 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1870
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1871 if 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1872 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1873 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1874 call G()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1875 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1876 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1877 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1878 endtry | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1879 endif | call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1880 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1881 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1882 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1883 call assert_equal('eabf', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1884 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1885 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1886 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1887
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1888 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1889 " Test 30: Executing :finally clauses on interrupt {{{1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1890 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1891 " After an interrupt in a command dynamically enclosed in
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1892 " a :try/:endtry region, :finally clauses are executed and the
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1893 " script processing is terminated.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1894 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1895
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1896 func Test_finally_on_interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1897 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1898 func F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1899 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1900 Xloop 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1901 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1902 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1903 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1904 Xloop 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1905 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1906 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1907 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1908
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1909 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1910 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1911 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1912 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1913 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1914 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1915 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1916 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1917 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1918 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1919 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1920 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1921 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1922 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1923 Xpath 'h'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1924 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1925 Xpath 'i'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1926 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1927 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1928 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1929 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1930 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1931 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1932 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1933 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1934 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1935 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1936 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1937 Xpath 'j'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1938 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1939 Xpath 'k'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1940 call F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1941 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1942 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1943 Xpath 'l'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1944 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1945 Xpath 'm'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1946 XloopNEXT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1947 ExecAsScript F
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1948 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1949 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1950 Xpath 'n'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1951 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1952 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1953 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1954 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1955 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1956 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1957 catch /^Vim:Interrupt$/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1958 Xpath 'o'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1959 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1960 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1961 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1962 call assert_equal('cdefghijka1b1lma2b2no', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1963 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1964 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1965 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1966
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1967 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1968 " Test 31: Executing :finally clauses after :throw {{{1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1969 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1970 " After a :throw dynamically enclosed in a :try/:endtry region,
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1971 " :finally clauses are executed and the script processing is
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1972 " terminated.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1973 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1974
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1975 func Test_finally_after_throw_2()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1976 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1977 func F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1978 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1979 Xloop 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1980 throw "exception"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1981 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1982 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1983 Xloop 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1984 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1985 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1986 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1987
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1988 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1989 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1990 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1991 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1992 throw "exception"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1993 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1994 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1995 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1996 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1997 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1998 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1999 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2000 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2001 Xpath 'h'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2002 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2003 Xpath 'i'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2004 throw "exception"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2005 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2006 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2007 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2008 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2009 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2010 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2011 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2012 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2013 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2014 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2015 Xpath 'j'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2016 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2017 Xpath 'k'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2018 call F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2019 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2020 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2021 Xpath 'l'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2022 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2023 Xpath 'm'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2024 XloopNEXT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2025 ExecAsScript F
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2026 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2027 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2028 Xpath 'n'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2029 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2030 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2031 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2032 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2033 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2034 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2035 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2036 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2037 call assert_equal('cdefghijka1b1lma2b2n', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2038 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2039 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2040 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2041
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2042 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2043 " Test 34: :finally reason discarded by :continue {{{1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2044 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2045 " When a :finally clause is executed due to a :continue, :break,
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2046 " :return, :finish, error, interrupt or :throw, the jump reason is
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2047 " discarded by a :continue in the finally clause.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2048 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2049
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2050 func Test_finally_after_continue()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2051 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2052 func C(jump)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2053 XloopNEXT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2054 let loop = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2055 while loop < 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2056 let loop = loop + 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2057 if loop == 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2058 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2059 if a:jump == "continue"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2060 continue
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2061 elseif a:jump == "break"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2062 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2063 elseif a:jump == "return" || a:jump == "finish"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2064 return
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2065 elseif a:jump == "error"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2066 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2067 elseif a:jump == "interrupt"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2068 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2069 let dummy = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2070 elseif a:jump == "throw"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2071 throw "abc"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2072 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2073 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2074 continue " discards jump that caused the :finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2075 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2076 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2077 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2078 elseif loop == 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2079 Xloop 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2080 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2081 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2082 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2083
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2084 call C("continue")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2085 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2086 call C("break")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2087 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2088 call C("return")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2089 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2090 let g:jump = "finish"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2091 ExecAsScript C
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2092 unlet g:jump
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2093 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2094 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2095 call C("error")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2096 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2097 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2098 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2099 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2100 call C("interrupt")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2101 Xpath 'h'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2102 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2103 Xpath 'i'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2104 call C("throw")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2105 Xpath 'j'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2106 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2107 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2108 Xpath 'k'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2109 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2110 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2111 call assert_equal('a2ba3ca4da5ea6fga7hia8jk', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2112 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2113 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2114 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2115
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2116 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2117 " Test 35: :finally reason discarded by :break {{{1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2118 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2119 " When a :finally clause is executed due to a :continue, :break,
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2120 " :return, :finish, error, interrupt or :throw, the jump reason is
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2121 " discarded by a :break in the finally clause.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2122 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2123
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2124 func Test_finally_discard_by_break()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2125 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2126 func B(jump)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2127 XloopNEXT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2128 let loop = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2129 while loop < 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2130 let loop = loop + 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2131 if loop == 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2132 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2133 if a:jump == "continue"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2134 continue
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2135 elseif a:jump == "break"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2136 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2137 elseif a:jump == "return" || a:jump == "finish"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2138 return
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2139 elseif a:jump == "error"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2140 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2141 elseif a:jump == "interrupt"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2142 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2143 let dummy = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2144 elseif a:jump == "throw"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2145 throw "abc"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2146 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2147 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2148 break " discards jump that caused the :finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2149 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2150 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2151 elseif loop == 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2152 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2153 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2154 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2155 Xloop 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2156 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2157
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2158 call B("continue")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2159 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2160 call B("break")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2161 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2162 call B("return")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2163 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2164 let g:jump = "finish"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2165 ExecAsScript B
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2166 unlet g:jump
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2167 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2168 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2169 call B("error")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2170 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2171 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2172 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2173 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2174 call B("interrupt")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2175 Xpath 'h'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2176 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2177 Xpath 'i'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2178 call B("throw")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2179 Xpath 'j'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2180 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2181 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2182 Xpath 'k'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2183 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2184 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2185 call assert_equal('a2ba3ca4da5ea6fga7hia8jk', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2186 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2187 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2188 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2189
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2190 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2191 " Test 36: :finally reason discarded by :return {{{1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2192 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2193 " When a :finally clause is executed due to a :continue, :break,
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2194 " :return, :finish, error, interrupt or :throw, the jump reason is
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2195 " discarded by a :return in the finally clause.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2196 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2197
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2198 func Test_finally_discard_by_return()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2199 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2200 func R(jump, retval) abort
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2201 let loop = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2202 while loop < 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2203 let loop = loop + 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2204 if loop == 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2205 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2206 if a:jump == "continue"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2207 continue
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2208 elseif a:jump == "break"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2209 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2210 elseif a:jump == "return"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2211 return
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2212 elseif a:jump == "error"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2213 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2214 elseif a:jump == "interrupt"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2215 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2216 let dummy = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2217 elseif a:jump == "throw"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2218 throw "abc"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2219 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2220 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2221 return a:retval " discards jump that caused the :finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2222 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2223 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2224 elseif loop == 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2225 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2226 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2227 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2228 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2229 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2230
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2231 let sum = -R("continue", -8)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2232 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2233 let sum = sum - R("break", -16)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2234 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2235 let sum = sum - R("return", -32)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2236 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2237 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2238 let sum = sum - R("error", -64)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2239 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2240 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2241 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2242 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2243 let sum = sum - R("interrupt", -128)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2244 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2245 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2246 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2247 let sum = sum - R("throw", -256)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2248 Xpath 'h'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2249 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2250 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2251 Xpath 'i'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2252
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2253 let expected = 8 + 16 + 32 + 64 + 128 + 256
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2254 call assert_equal(sum, expected)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2255 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2256 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2257 call assert_equal('abcdefghi', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2258 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2259 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2260 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2261
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2262 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2263 " Test 37: :finally reason discarded by :finish {{{1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2264 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2265 " When a :finally clause is executed due to a :continue, :break,
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2266 " :return, :finish, error, interrupt or :throw, the jump reason is
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2267 " discarded by a :finish in the finally clause.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2268 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2269
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2270 func Test_finally_discard_by_finish()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2271 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2272 func F(jump) " not executed as function, transformed to a script
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2273 let loop = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2274 while loop < 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2275 let loop = loop + 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2276 if loop == 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2277 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2278 if a:jump == "continue"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2279 continue
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2280 elseif a:jump == "break"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2281 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2282 elseif a:jump == "finish"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2283 finish
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2284 elseif a:jump == "error"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2285 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2286 elseif a:jump == "interrupt"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2287 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2288 let dummy = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2289 elseif a:jump == "throw"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2290 throw "abc"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2291 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2292 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2293 finish " discards jump that caused the :finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2294 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2295 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2296 elseif loop == 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2297 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2298 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2299 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2300 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2301 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2302
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2303 let scriptF = MakeScript("F")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2304 delfunction F
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2305
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2306 let g:jump = "continue"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2307 exec "source" scriptF
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2308 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2309 let g:jump = "break"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2310 exec "source" scriptF
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2311 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2312 let g:jump = "finish"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2313 exec "source" scriptF
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2314 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2315 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2316 let g:jump = "error"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2317 exec "source" scriptF
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2318 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2319 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2320 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2321 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2322 let g:jump = "interrupt"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2323 exec "source" scriptF
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2324 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2325 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2326 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2327 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2328 let g:jump = "throw"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2329 exec "source" scriptF
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2330 Xpath 'h'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2331 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2332 Xpath 'i'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2333 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2334 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2335 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2336 unlet g:jump
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2337 call delete(scriptF)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2338 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2339 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2340 call assert_equal('abcdefghi', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2341 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2342 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2343 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2344
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2345 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2346 " Test 38: :finally reason discarded by an error {{{1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2347 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2348 " When a :finally clause is executed due to a :continue, :break,
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2349 " :return, :finish, error, interrupt or :throw, the jump reason is
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2350 " discarded by an error in the finally clause.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2351 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2352
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2353 func Test_finally_discard_by_error()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2354 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2355 func E(jump)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2356 let loop = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2357 while loop < 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2358 let loop = loop + 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2359 if loop == 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2360 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2361 if a:jump == "continue"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2362 continue
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2363 elseif a:jump == "break"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2364 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2365 elseif a:jump == "return" || a:jump == "finish"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2366 return
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2367 elseif a:jump == "error"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2368 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2369 elseif a:jump == "interrupt"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2370 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2371 let dummy = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2372 elseif a:jump == "throw"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2373 throw "abc"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2374 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2375 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2376 asdf " error; discards jump that caused the :finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2377 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2378 elseif loop == 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2379 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2380 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2381 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2382 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2383 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2384
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2385 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2386 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2387 call E("continue")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2388 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2389 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2390 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2391 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2392 call E("break")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2393 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2394 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2395 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2396 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2397 call E("return")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2398 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2399 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2400 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2401 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2402 let g:jump = "finish"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2403 ExecAsScript E
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2404 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2405 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2406 unlet g:jump
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2407 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2408 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2409 call E("error")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2410 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2411 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2412 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2413 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2414 call E("interrupt")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2415 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2416 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2417 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2418 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2419 call E("throw")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2420 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2421 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2422 Xpath 'h'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2423 delfunction E
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2424 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2425 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2426 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2427 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2428 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2429 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2430 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2431 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2432 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2433 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2434 call assert_equal('abcdefgh', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2435 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2436 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2437 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2438
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2439 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2440 " Test 39: :finally reason discarded by an interrupt {{{1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2441 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2442 " When a :finally clause is executed due to a :continue, :break,
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2443 " :return, :finish, error, interrupt or :throw, the jump reason is
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2444 " discarded by an interrupt in the finally clause.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2445 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2446
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2447 func Test_finally_discarded_by_interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2448 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2449 func I(jump)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2450 let loop = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2451 while loop < 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2452 let loop = loop + 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2453 if loop == 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2454 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2455 if a:jump == "continue"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2456 continue
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2457 elseif a:jump == "break"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2458 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2459 elseif a:jump == "return" || a:jump == "finish"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2460 return
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2461 elseif a:jump == "error"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2462 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2463 elseif a:jump == "interrupt"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2464 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2465 let dummy = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2466 elseif a:jump == "throw"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2467 throw "abc"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2468 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2469 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2470 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2471 let dummy = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2472 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2473 elseif loop == 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2474 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2475 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2476 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2477 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2478 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2479
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2480 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2481 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2482 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2483 call I("continue")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2484 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2485 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2486 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2487 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2488 call I("break")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2489 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2490 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2491 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2492 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2493 call I("return")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2494 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2495 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2496 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2497 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2498 let g:jump = "finish"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2499 ExecAsScript I
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2500 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2501 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2502 unlet g:jump
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2503 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2504 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2505 call I("error")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2506 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2507 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2508 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2509 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2510 call I("interrupt")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2511 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2512 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2513 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2514 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2515 call I("throw")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2516 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2517 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2518 Xpath 'h'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2519 delfunction I
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2520 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2521 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2522 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2523 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2524 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2525 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2526 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2527 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2528 catch /^Vim:Interrupt$/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2529 Xpath 'A'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2530 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2531 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2532 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2533 call assert_equal('abcdefghA', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2534 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2535 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2536 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2537
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2538 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2539 " Test 40: :finally reason discarded by :throw {{{1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2540 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2541 " When a :finally clause is executed due to a :continue, :break,
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2542 " :return, :finish, error, interrupt or :throw, the jump reason is
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2543 " discarded by a :throw in the finally clause.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2544 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2545
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2546 func Test_finally_discard_by_throw()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2547 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2548 func T(jump)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2549 let loop = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2550 while loop < 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2551 let loop = loop + 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2552 if loop == 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2553 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2554 if a:jump == "continue"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2555 continue
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2556 elseif a:jump == "break"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2557 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2558 elseif a:jump == "return" || a:jump == "finish"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2559 return
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2560 elseif a:jump == "error"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2561 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2562 elseif a:jump == "interrupt"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2563 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2564 let dummy = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2565 elseif a:jump == "throw"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2566 throw "abc"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2567 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2568 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2569 throw "xyz" " discards jump that caused the :finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2570 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2571 elseif loop == 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2572 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2573 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2574 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2575 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2576 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2577
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2578 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2579 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2580 call T("continue")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2581 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2582 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2583 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2584 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2585 call T("break")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2586 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2587 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2588 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2589 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2590 call T("return")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2591 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2592 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2593 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2594 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2595 let g:jump = "finish"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2596 ExecAsScript T
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2597 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2598 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2599 unlet g:jump
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2600 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2601 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2602 call T("error")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2603 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2604 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2605 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2606 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2607 call T("interrupt")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2608 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2609 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2610 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2611 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2612 call T("throw")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2613 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2614 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2615 Xpath 'h'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2616 delfunction T
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2617 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2618 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2619 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2620 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2621 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2622 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2623 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2624 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2625 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2626 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2627 call assert_equal('abcdefgh', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2628 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2629 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2630 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2631
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2632 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2633 " Test 49: Throwing exceptions across functions {{{1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2634 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2635 " When an exception is thrown but not caught inside a function, the
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2636 " caller is checked for a matching :catch clause.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2637 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2638
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2639 func T49_C()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2640 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2641 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2642 throw "arrgh"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2643 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2644 catch /arrgh/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2645 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2646 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2647 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2648 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2649
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2650 func T49_T1()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2651 XloopNEXT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2652 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2653 Xloop 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2654 throw "arrgh"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2655 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2656 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2657 Xloop 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2658 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2659 Xloop 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2660 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2661
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2662 func T49_T2()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2663 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2664 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2665 call T49_T1()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2666 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2667 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2668 Xpath 'h'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2669 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2670 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2671 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2672
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2673 func Test_throw_exception_across_funcs()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2674 XpathINIT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2675 XloopINIT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2676 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2677 Xpath 'i'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2678 call T49_C() " throw and catch
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2679 Xpath 'j'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2680 catch /.*/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2681 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2682 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2683
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2684 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2685 Xpath 'k'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2686 call T49_T1() " throw, one level
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2687 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2688 catch /arrgh/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2689 Xpath 'l'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2690 catch /.*/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2691 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2692 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2693
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2694 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2695 Xpath 'm'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2696 call T49_T2() " throw, two levels
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2697 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2698 catch /arrgh/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2699 Xpath 'n'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2700 catch /.*/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2701 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2702 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2703 Xpath 'o'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2704
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2705 call assert_equal('iabcjkd2e2lmgd3e3hno', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2706 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2707
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2708 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2709 " Test 50: Throwing exceptions across script files {{{1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2710 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2711 " When an exception is thrown but not caught inside a script file,
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2712 " the sourcing script or function is checked for a matching :catch
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2713 " clause.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2714 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2715 " This test executes the bodies of the functions C, T1, and T2 from
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2716 " the previous test as script files (:return replaced by :finish).
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2717 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2718
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2719 func T50_F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2720 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2721 Xpath 'A'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2722 exec "source" g:scriptC
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2723 Xpath 'B'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2724 catch /.*/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2725 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2726 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2727
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2728 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2729 Xpath 'C'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2730 exec "source" g:scriptT1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2731 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2732 catch /arrgh/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2733 Xpath 'D'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2734 catch /.*/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2735 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2736 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2737 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2738
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2739 func Test_throw_across_script()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2740 XpathINIT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2741 XloopINIT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2742 let g:scriptC = MakeScript("T49_C")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2743 let g:scriptT1 = MakeScript("T49_T1")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2744 let scriptT2 = MakeScript("T49_T2", g:scriptT1)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2745
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2746 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2747 Xpath 'E'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2748 call T50_F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2749 Xpath 'F'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2750 exec "source" scriptT2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2751 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2752 catch /arrgh/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2753 Xpath 'G'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2754 catch /.*/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2755 call assert_report('should not get here')
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2756 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2757 Xpath 'H'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2758 call assert_equal('EAabcBCd2e2DFgd3e3hGH', g:Xpath)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2759
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2760 call delete(g:scriptC)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2761 call delete(g:scriptT1)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2762 call delete(scriptT2)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2763 unlet g:scriptC g:scriptT1 scriptT2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2764 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2765
18504
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
2766 "-------------------------------------------------------------------------------
21666
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2767 " Test 52: Uncaught exceptions {{{1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2768 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2769 " When an exception is thrown but not caught, an error message is
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2770 " displayed when the script is terminated. In case of an interrupt
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2771 " or error exception, the normal interrupt or error message(s) are
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2772 " displayed.
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2773 "-------------------------------------------------------------------------------
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2774
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2775 func Test_uncaught_exception_1()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2776 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2777
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2778 let test =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2779 Xpath 'a'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2780 throw "arrgh"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2781 call assert_report('should not get here')`
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2782 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2783 let verify =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2784 call assert_equal('E605: Exception not caught: arrgh', v:errmsg)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2785 call assert_equal('a', g:Xpath)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2786 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2787 call RunInNewVim(test, verify)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2788 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2789
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2790 func Test_uncaught_exception_2()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2791 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2792
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2793 let test =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2794 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2795 Xpath 'a'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2796 throw "oops"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2797 call assert_report('should not get here')`
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2798 catch /arrgh/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2799 call assert_report('should not get here')`
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2800 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2801 call assert_report('should not get here')`
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2802 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2803 let verify =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2804 call assert_equal('E605: Exception not caught: oops', v:errmsg)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2805 call assert_equal('a', g:Xpath)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2806 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2807 call RunInNewVim(test, verify)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2808 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2809
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2810 func Test_uncaught_exception_3()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2811 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2812
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2813 let test =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2814 func T()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2815 Xpath 'c'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2816 throw "brrr"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2817 call assert_report('should not get here')`
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2818 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2819
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2820 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2821 Xpath 'a'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2822 throw "arrgh"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2823 call assert_report('should not get here')`
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2824 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2825 Xpath 'b'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2826 call T()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2827 call assert_report('should not get here')`
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2828 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2829 call assert_report('should not get here')`
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2830 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2831 let verify =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2832 call assert_equal('E605: Exception not caught: brrr', v:errmsg)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2833 call assert_equal('abc', g:Xpath)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2834 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2835 call RunInNewVim(test, verify)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2836 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2837
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2838 func Test_uncaught_exception_4()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2839 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2840
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2841 let test =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2842 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2843 Xpath 'a'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2844 throw "arrgh"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2845 call assert_report('should not get here')`
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2846 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2847 Xpath 'b'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2848 throw "brrr"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2849 call assert_report('should not get here')`
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2850 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2851 call assert_report('should not get here')`
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2852 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2853 let verify =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2854 call assert_equal('E605: Exception not caught: brrr', v:errmsg)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2855 call assert_equal('ab', g:Xpath)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2856 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2857 call RunInNewVim(test, verify)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2858 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2859
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2860 func Test_uncaught_exception_5()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2861 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2862
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2863 " Need to catch and handle interrupt, otherwise the test will wait for the
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2864 " user to press <Enter> to continue
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2865 let test =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2866 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2867 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2868 Xpath 'a'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2869 call interrupt()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2870 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2871 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2872 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2873 catch /^Vim:Interrupt$/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2874 Xpath 'b'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2875 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2876 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2877 let verify =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2878 call assert_equal('ab', g:Xpath)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2879 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2880 call RunInNewVim(test, verify)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2881 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2882
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2883 func Test_uncaught_exception_6()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2884 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2885
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2886 let test =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2887 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2888 Xpath 'a'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2889 let x = novar " error E121; exception: E121
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2890 catch /E15:/ " should not catch
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2891 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2892 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2893 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2894 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2895 let verify =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2896 call assert_equal('a', g:Xpath)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2897 call assert_equal('E121: Undefined variable: novar', v:errmsg)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2898 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2899 call RunInNewVim(test, verify)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2900 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2901
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2902 func Test_uncaught_exception_7()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2903 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2904
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2905 let test =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2906 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2907 Xpath 'a'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2908 " error E108/E488; exception: E488
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2909 unlet novar #
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2910 catch /E108:/ " should not catch
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2911 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2912 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2913 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2914 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2915 let verify =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2916 call assert_equal('a', g:Xpath)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2917 call assert_equal('E488: Trailing characters: #', v:errmsg)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2918 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2919 call RunInNewVim(test, verify)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2920 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2921
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2922 "-------------------------------------------------------------------------------
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2923 " Test 53: Nesting errors: :endif/:else/:elseif {{{1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2924 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2925 " For nesting errors of :if conditionals the correct error messages
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2926 " should be given.
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2927 "-------------------------------------------------------------------------------
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2928
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2929 func Test_nested_if_else_errors()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2930 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2931
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2932 " :endif without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2933 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2934 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2935 END
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
2936 call writefile(code, 'Xtest', 'D')
21666
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2937 call AssertException(['source Xtest'], 'Vim(endif):E580: :endif without :if')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2938
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2939 " :endif without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2940 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2941 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2942 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2943 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2944 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2945 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2946 call AssertException(['source Xtest'], 'Vim(endif):E580: :endif without :if')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2947
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2948 " :endif without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2949 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2950 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2951 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2952 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2953 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2954 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2955 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2956 call AssertException(['source Xtest'], 'Vim(endif):E580: :endif without :if')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2957
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2958 " :endif without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2959 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2960 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2961 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2962 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2963 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2964 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2965 call AssertException(['source Xtest'], 'Vim(endif):E580: :endif without :if')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2966
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2967 " :endif without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2968 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2969 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2970 throw "a"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2971 catch /a/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2972 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2973 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2974 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2975 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2976 call AssertException(['source Xtest'], 'Vim(endif):E580: :endif without :if')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2977
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2978 " :else without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2979 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2980 else
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2981 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2982 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2983 call AssertException(['source Xtest'], 'Vim(else):E581: :else without :if')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2984
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2985 " :else without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2986 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2987 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2988 else
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2989 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2990 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2991 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2992 call AssertException(['source Xtest'], 'Vim(else):E581: :else without :if')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2993
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2994 " :else without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2995 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2996 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2997 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2998 else
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2999 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3000 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3001 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3002 call AssertException(['source Xtest'], 'Vim(else):E581: :else without :if')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3003
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3004 " :else without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3005 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3006 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3007 else
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3008 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3009 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3010 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3011 call AssertException(['source Xtest'], 'Vim(else):E581: :else without :if')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3012
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3013 " :else without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3014 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3015 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3016 throw "a"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3017 catch /a/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3018 else
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3019 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3020 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3021 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3022 call AssertException(['source Xtest'], 'Vim(else):E581: :else without :if')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3023
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3024 " :elseif without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3025 let code =<< trim END
28301
ebe0eeea501a patch 8.2.4676: test fails with different error
Bram Moolenaar <Bram@vim.org>
parents: 28171
diff changeset
3026 elseif 1
21666
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3027 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3028 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3029 call AssertException(['source Xtest'], 'Vim(elseif):E582: :elseif without :if')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3030
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3031 " :elseif without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3032 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3033 while 1
28301
ebe0eeea501a patch 8.2.4676: test fails with different error
Bram Moolenaar <Bram@vim.org>
parents: 28171
diff changeset
3034 elseif 1
21666
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3035 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3036 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3037 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3038 call AssertException(['source Xtest'], 'Vim(elseif):E582: :elseif without :if')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3039
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3040 " :elseif without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3041 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3042 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3043 finally
28301
ebe0eeea501a patch 8.2.4676: test fails with different error
Bram Moolenaar <Bram@vim.org>
parents: 28171
diff changeset
3044 elseif 1
21666
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3045 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3046 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3047 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3048 call AssertException(['source Xtest'], 'Vim(elseif):E582: :elseif without :if')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3049
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3050 " :elseif without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3051 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3052 try
28301
ebe0eeea501a patch 8.2.4676: test fails with different error
Bram Moolenaar <Bram@vim.org>
parents: 28171
diff changeset
3053 elseif 1
21666
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3054 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3055 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3056 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3057 call AssertException(['source Xtest'], 'Vim(elseif):E582: :elseif without :if')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3058
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3059 " :elseif without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3060 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3061 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3062 throw "a"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3063 catch /a/
28301
ebe0eeea501a patch 8.2.4676: test fails with different error
Bram Moolenaar <Bram@vim.org>
parents: 28171
diff changeset
3064 elseif 1
21666
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3065 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3066 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3067 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3068 call AssertException(['source Xtest'], 'Vim(elseif):E582: :elseif without :if')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3069
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3070 " multiple :else
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3071 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3072 if 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3073 else
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3074 else
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3075 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3076 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3077 call writefile(code, 'Xtest')
28735
c428a4e53b9c patch 8.2.4892: test failures because of changed error messages
Bram Moolenaar <Bram@vim.org>
parents: 28301
diff changeset
3078 call AssertException(['source Xtest'], 'Vim(else):E583: Multiple :else')
21666
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3079
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3080 " :elseif after :else
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3081 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3082 if 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3083 else
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3084 elseif 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3085 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3086 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3087 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3088 call AssertException(['source Xtest'], 'Vim(elseif):E584: :elseif after :else')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3089 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3090
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3091 "-------------------------------------------------------------------------------
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3092 " Test 54: Nesting errors: :while/:endwhile {{{1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3093 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3094 " For nesting errors of :while conditionals the correct error messages
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3095 " should be given.
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3096 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3097 " This test reuses the function MESSAGES() from the previous test.
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3098 " This functions checks the messages in g:msgfile.
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3099 "-------------------------------------------------------------------------------
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3100
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3101 func Test_nested_while_error()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3102 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3103
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3104 " :endwhile without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3105 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3106 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3107 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3108 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3109 call AssertException(['source Xtest'], 'Vim(endwhile):E588: :endwhile without :while')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3110
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3111 " :endwhile without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3112 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3113 if 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3114 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3115 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3116 END
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
3117 call writefile(code, 'Xtest', 'D')
21666
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3118 call AssertException(['source Xtest'], 'Vim(endwhile):E588: :endwhile without :while')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3119
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3120 " Missing :endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3121 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3122 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3123 if 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3124 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3125 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3126 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3127 call AssertException(['source Xtest'], 'Vim(endwhile):E171: Missing :endif')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3128
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3129 " :endwhile without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3130 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3131 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3132 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3133 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3134 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3135 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3136 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3137 call AssertException(['source Xtest'], 'Vim(endwhile):E588: :endwhile without :while')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3138
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3139 " Missing :endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3140 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3141 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3142 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3143 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3144 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3145 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3146 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3147 call AssertException(['source Xtest'], 'Vim(endwhile):E600: Missing :endtry')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3148
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3149 " Missing :endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3150 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3151 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3152 if 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3153 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3154 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3155 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3156 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3157 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3158 call AssertException(['source Xtest'], 'Vim(endwhile):E600: Missing :endtry')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3159
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3160 " Missing :endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3161 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3162 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3163 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3164 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3165 if 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3166 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3167 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3168 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3169 call AssertException(['source Xtest'], 'Vim(endwhile):E171: Missing :endif')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3170
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3171 " :endwhile without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3172 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3173 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3174 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3175 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3176 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3177 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3178 call AssertException(['source Xtest'], 'Vim(endwhile):E588: :endwhile without :while')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3179
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3180 " :endwhile without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3181 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3182 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3183 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3184 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3185 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3186 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3187 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3188 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3189 call AssertException(['source Xtest'], 'Vim(endwhile):E588: :endwhile without :while')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3190
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3191 " :endwhile without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3192 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3193 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3194 throw "a"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3195 catch /a/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3196 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3197 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3198 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3199 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3200 call AssertException(['source Xtest'], 'Vim(endwhile):E588: :endwhile without :while')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3201
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3202 " :endwhile without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3203 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3204 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3205 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3206 throw "a"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3207 catch /a/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3208 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3209 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3210 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3211 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3212 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3213 call AssertException(['source Xtest'], 'Vim(endwhile):E588: :endwhile without :while')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3214 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3215
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3216 "-------------------------------------------------------------------------------
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3217 " Test 55: Nesting errors: :continue/:break {{{1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3218 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3219 " For nesting errors of :continue and :break commands the correct
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3220 " error messages should be given.
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3221 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3222 " This test reuses the function MESSAGES() from the previous test.
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3223 " This functions checks the messages in g:msgfile.
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3224 "-------------------------------------------------------------------------------
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3225
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3226 func Test_nested_cont_break_error()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3227 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3228
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3229 " :continue without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3230 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3231 continue
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3232 END
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
3233 call writefile(code, 'Xtest', 'D')
21666
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3234 call AssertException(['source Xtest'], 'Vim(continue):E586: :continue without :while or :for')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3235
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3236 " :continue without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3237 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3238 if 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3239 continue
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3240 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3241 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3242 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3243 call AssertException(['source Xtest'], 'Vim(continue):E586: :continue without :while or :for')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3244
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3245 " :continue without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3246 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3247 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3248 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3249 continue
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3250 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3251 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3252 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3253 call AssertException(['source Xtest'], 'Vim(continue):E586: :continue without :while or :for')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3254
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3255 " :continue without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3256 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3257 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3258 continue
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3259 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3260 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3261 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3262 call AssertException(['source Xtest'], 'Vim(continue):E586: :continue without :while or :for')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3263
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3264 " :continue without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3265 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3266 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3267 throw "a"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3268 catch /a/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3269 continue
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3270 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3271 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3272 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3273 call AssertException(['source Xtest'], 'Vim(continue):E586: :continue without :while or :for')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3274
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3275 " :break without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3276 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3277 break
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3278 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3279 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3280 call AssertException(['source Xtest'], 'Vim(break):E587: :break without :while or :for')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3281
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3282 " :break without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3283 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3284 if 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3285 break
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3286 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3287 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3288 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3289 call AssertException(['source Xtest'], 'Vim(break):E587: :break without :while or :for')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3290
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3291 " :break without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3292 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3293 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3294 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3295 break
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3296 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3297 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3298 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3299 call AssertException(['source Xtest'], 'Vim(break):E587: :break without :while or :for')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3300
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3301 " :break without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3302 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3303 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3304 break
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3305 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3306 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3307 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3308 call AssertException(['source Xtest'], 'Vim(break):E587: :break without :while or :for')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3309
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3310 " :break without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3311 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3312 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3313 throw "a"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3314 catch /a/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3315 break
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3316 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3317 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3318 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3319 call AssertException(['source Xtest'], 'Vim(break):E587: :break without :while or :for')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3320 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3321
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3322 "-------------------------------------------------------------------------------
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3323 " Test 56: Nesting errors: :endtry {{{1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3324 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3325 " For nesting errors of :try conditionals the correct error messages
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3326 " should be given.
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3327 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3328 " This test reuses the function MESSAGES() from the previous test.
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3329 " This functions checks the messages in g:msgfile.
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3330 "-------------------------------------------------------------------------------
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3331
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3332 func Test_nested_endtry_error()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3333 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3334
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3335 " :endtry without :try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3336 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3337 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3338 END
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
3339 call writefile(code, 'Xtest', 'D')
21666
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3340 call AssertException(['source Xtest'], 'Vim(endtry):E602: :endtry without :try')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3341
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3342 " :endtry without :try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3343 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3344 if 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3345 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3346 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3347 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3348 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3349 call AssertException(['source Xtest'], 'Vim(endtry):E602: :endtry without :try')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3350
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3351 " :endtry without :try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3352 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3353 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3354 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3355 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3356 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3357 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3358 call AssertException(['source Xtest'], 'Vim(endtry):E602: :endtry without :try')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3359
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3360 " Missing :endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3361 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3362 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3363 if 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3364 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3365 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3366 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3367 call AssertException(['source Xtest'], 'Vim(endtry):E171: Missing :endif')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3368
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3369 " Missing :endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3370 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3371 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3372 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3373 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3374 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3375 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3376 call AssertException(['source Xtest'], 'Vim(endtry):E170: Missing :endwhile')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3377
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3378 " Missing :endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3379 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3380 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3381 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3382 if 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3383 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3384 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3385 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3386 call AssertException(['source Xtest'], 'Vim(endtry):E171: Missing :endif')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3387
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3388 " Missing :endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3389 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3390 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3391 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3392 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3393 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3394 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3395 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3396 call AssertException(['source Xtest'], 'Vim(endtry):E170: Missing :endwhile')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3397
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3398 " Missing :endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3399 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3400 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3401 throw "a"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3402 catch /a/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3403 if 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3404 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3405 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3406 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3407 call AssertException(['source Xtest'], 'Vim(endtry):E171: Missing :endif')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3408
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3409 " Missing :endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3410 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3411 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3412 throw "a"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3413 catch /a/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3414 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3415 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3416 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3417 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3418 call AssertException(['source Xtest'], 'Vim(endtry):E170: Missing :endwhile')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3419 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3420
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3421 "-------------------------------------------------------------------------------
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3422 " Test 57: v:exception and v:throwpoint for user exceptions {{{1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3423 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3424 " v:exception evaluates to the value of the exception that was caught
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3425 " most recently and is not finished. (A caught exception is finished
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3426 " when the next ":catch", ":finally", or ":endtry" is reached.)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3427 " v:throwpoint evaluates to the script/function name and line number
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3428 " where that exception has been thrown.
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3429 "-------------------------------------------------------------------------------
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3430
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3431 func Test_user_exception_info()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3432 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3433
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3434 XpathINIT
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3435 XloopINIT
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3436
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3437 func FuncException()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3438 let g:exception = v:exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3439 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3440
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3441 func FuncThrowpoint()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3442 let g:throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3443 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3444
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3445 let scriptException = MakeScript("FuncException")
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3446 let scriptThrowPoint = MakeScript("FuncThrowpoint")
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3447
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3448 command! CmdException let g:exception = v:exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3449 command! CmdThrowpoint let g:throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3450
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3451 func T(arg, line)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3452 if a:line == 2
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3453 throw a:arg " in line 2
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3454 elseif a:line == 4
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3455 throw a:arg " in line 4
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3456 elseif a:line == 6
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3457 throw a:arg " in line 6
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3458 elseif a:line == 8
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3459 throw a:arg " in line 8
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3460 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3461 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3462
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3463 func G(arg, line)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3464 call T(a:arg, a:line)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3465 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3466
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3467 func F(arg, line)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3468 call G(a:arg, a:line)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3469 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3470
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3471 let scriptT = MakeScript("T")
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3472 let scriptG = MakeScript("G", scriptT)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3473 let scriptF = MakeScript("F", scriptG)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3474
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3475 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3476 Xpath 'a'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3477 call F("oops", 2)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3478 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3479 Xpath 'b'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3480 let exception = v:exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3481 let throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3482 call assert_equal("oops", v:exception)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3483 call assert_match('\<F\[1]\.\.G\[1]\.\.T\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3484 call assert_match('\<2\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3485
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3486 exec "let exception = v:exception"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3487 exec "let throwpoint = v:throwpoint"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3488 call assert_equal("oops", v:exception)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3489 call assert_match('\<F\[1]\.\.G\[1]\.\.T\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3490 call assert_match('\<2\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3491
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3492 CmdException
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3493 CmdThrowpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3494 call assert_equal("oops", v:exception)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3495 call assert_match('\<F\[1]\.\.G\[1]\.\.T\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3496 call assert_match('\<2\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3497
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3498 call FuncException()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3499 call FuncThrowpoint()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3500 call assert_equal("oops", v:exception)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3501 call assert_match('\<F\[1]\.\.G\[1]\.\.T\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3502 call assert_match('\<2\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3503
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3504 exec "source" scriptException
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3505 exec "source" scriptThrowPoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3506 call assert_equal("oops", v:exception)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3507 call assert_match('\<F\[1]\.\.G\[1]\.\.T\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3508 call assert_match('\<2\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3509
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3510 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3511 Xpath 'c'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3512 call G("arrgh", 4)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3513 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3514 Xpath 'd'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3515 let exception = v:exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3516 let throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3517 call assert_equal("arrgh", v:exception)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3518 call assert_match('\<G\[1]\.\.T\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3519 call assert_match('\<4\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3520
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3521 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3522 Xpath 'e'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3523 let g:arg = "autsch"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3524 let g:line = 6
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3525 exec "source" scriptF
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3526 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3527 Xpath 'f'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3528 let exception = v:exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3529 let throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3530 call assert_equal("autsch", v:exception)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3531 call assert_match(fnamemodify(scriptT, ':t'), v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3532 call assert_match('\<6\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3533 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3534 Xpath 'g'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3535 let exception = v:exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3536 let throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3537 call assert_equal("arrgh", v:exception)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3538 call assert_match('\<G\[1]\.\.T\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3539 call assert_match('\<4\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3540 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3541 Xpath 'h'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3542 let g:arg = "brrrr"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3543 let g:line = 8
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3544 exec "source" scriptG
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3545 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3546 Xpath 'i'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3547 let exception = v:exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3548 let throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3549 " Resolve scriptT for matching it against v:throwpoint.
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3550 call assert_equal("brrrr", v:exception)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3551 call assert_match(fnamemodify(scriptT, ':t'), v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3552 call assert_match('\<8\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3553 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3554 Xpath 'j'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3555 let exception = v:exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3556 let throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3557 call assert_equal("arrgh", v:exception)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3558 call assert_match('\<G\[1]\.\.T\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3559 call assert_match('\<4\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3560 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3561 Xpath 'k'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3562 let exception = v:exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3563 let throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3564 call assert_equal("arrgh", v:exception)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3565 call assert_match('\<G\[1]\.\.T\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3566 call assert_match('\<4\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3567 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3568 Xpath 'l'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3569 let exception = v:exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3570 let throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3571 call assert_equal("arrgh", v:exception)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3572 call assert_match('\<G\[1]\.\.T\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3573 call assert_match('\<4\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3574 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3575 Xpath 'm'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3576 let exception = v:exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3577 let throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3578 call assert_equal("oops", v:exception)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3579 call assert_match('\<F\[1]\.\.G\[1]\.\.T\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3580 call assert_match('\<2\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3581 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3582 Xpath 'n'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3583 let exception = v:exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3584 let throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3585 call assert_equal("oops", v:exception)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3586 call assert_match('\<F\[1]\.\.G\[1]\.\.T\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3587 call assert_match('\<2\>', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3588 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3589 Xpath 'o'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3590 let exception = v:exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3591 let throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3592 call assert_equal("", v:exception)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3593 call assert_match('^$', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3594 call assert_match('^$', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3595 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3596
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3597 call assert_equal('abcdefghijklmno', g:Xpath)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3598
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3599 unlet exception throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3600 delfunction FuncException
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3601 delfunction FuncThrowpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3602 call delete(scriptException)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3603 call delete(scriptThrowPoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3604 unlet scriptException scriptThrowPoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3605 delcommand CmdException
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3606 delcommand CmdThrowpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3607 delfunction T
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3608 delfunction G
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3609 delfunction F
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3610 call delete(scriptT)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3611 call delete(scriptG)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3612 call delete(scriptF)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3613 unlet scriptT scriptG scriptF
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3614 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3615
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3616 "-------------------------------------------------------------------------------
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3617 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3618 " Test 58: v:exception and v:throwpoint for error/interrupt exceptions {{{1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3619 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3620 " v:exception and v:throwpoint work also for error and interrupt
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3621 " exceptions.
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3622 "-------------------------------------------------------------------------------
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3623
28171
b4c111ea83b1 patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents: 28008
diff changeset
3624 func Test_exception_info_for_error()
21666
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3625 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3626
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3627 let test =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3628 func T(line)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3629 if a:line == 2
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3630 delfunction T " error (function in use) in line 2
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3631 elseif a:line == 4
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3632 call interrupt()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3633 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3634 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3635
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3636 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3637 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3638 Xpath 'a'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3639 call T(2)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3640 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3641 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3642 Xpath 'b'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3643 if v:exception !~ 'Vim(delfunction):'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3644 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3645 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3646 if v:throwpoint !~ '\<T\>'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3647 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3648 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3649 if v:throwpoint !~ '\<2\>'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3650 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3651 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3652 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3653 Xpath 'c'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3654 if v:exception != ""
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3655 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3656 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3657 if v:throwpoint != ""
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3658 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3659 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3660 break
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3661 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3662 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3663
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3664 Xpath 'd'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3665 if v:exception != ""
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3666 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3667 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3668 if v:throwpoint != ""
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3669 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3670 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3671
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3672 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3673 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3674 Xpath 'e'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3675 call T(4)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3676 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3677 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3678 Xpath 'f'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3679 if v:exception != 'Vim:Interrupt'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3680 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3681 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3682 if v:throwpoint !~ 'function T'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3683 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3684 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3685 if v:throwpoint !~ '\<4\>'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3686 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3687 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3688 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3689 Xpath 'g'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3690 if v:exception != ""
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3691 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3692 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3693 if v:throwpoint != ""
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3694 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3695 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3696 break
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3697 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3698 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3699
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3700 Xpath 'h'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3701 if v:exception != ""
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3702 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3703 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3704 if v:throwpoint != ""
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3705 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3706 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3707 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3708 let verify =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3709 call assert_equal('abcdefgh', g:Xpath)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3710 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3711 call RunInNewVim(test, verify)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3712 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3713
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3714 "-------------------------------------------------------------------------------
21735
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3715 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3716 " Test 59: v:exception and v:throwpoint when discarding exceptions {{{1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3717 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3718 " When a :catch clause is left by a ":break" etc or an error or
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3719 " interrupt exception, v:exception and v:throwpoint are reset. They
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3720 " are not affected by an exception that is discarded before being
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3721 " caught.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3722 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3723 func Test_exception_info_on_discard()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3724 CheckEnglish
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3725
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3726 let test =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3727 let sfile = expand("<sfile>")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3728
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3729 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3730 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3731 throw "x1"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3732 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3733 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3734 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3735 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3736 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3737 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3738
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3739 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3740 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3741 throw "x2"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3742 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3743 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3744 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3745 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3746 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3747 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3748 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3749 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3750 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3751 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3752
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3753 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3754 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3755 let errcaught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3756 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3757 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3758 throw "x3"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3759 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3760 let lnum = expand("<sflnum>")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3761 asdf
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3762 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3763 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3764 let errcaught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3765 call assert_match('Vim:E492: Not an editor command:', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3766 call assert_match('line ' .. (lnum + 1), v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3767 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3768 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3769 call assert_equal(1, errcaught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3770 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3771 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3772 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3773 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3774 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3775
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3776 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3777
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3778 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3779 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3780 let intcaught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3781 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3782 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3783 throw "x4"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3784 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3785 let lnum = expand("<sflnum>")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3786 call interrupt()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3787 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3788 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3789 let intcaught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3790 call assert_match('Vim:Interrupt', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3791 call assert_match('line ' .. (lnum + 1), v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3792 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3793 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3794 call assert_equal(1, intcaught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3795 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3796 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3797 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3798 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3799 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3800
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3801 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3802
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3803 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3804 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3805 let errcaught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3806 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3807 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3808 if 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3809 let lnum = expand("<sflnum>")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3810 throw "x5"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3811 " missing endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3812 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3813 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3814 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3815 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3816 let errcaught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3817 call assert_match('Vim(catch):E171: Missing :endif:', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3818 call assert_match('line ' .. (lnum + 3), v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3819 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3820 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3821 call assert_equal(1, errcaught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3822 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3823 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3824 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3825 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3826 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3827
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3828 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3829
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3830 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3831 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3832 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3833 throw "x6"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3834 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3835 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3836 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3837 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3838 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3839 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3840 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3841 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3842 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3843 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3844
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3845 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3846 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3847 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3848 throw "x7"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3849 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3850 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3851 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3852 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3853 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3854 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3855 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3856 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3857 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3858 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3859 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3860 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3861 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3862
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3863 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3864 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3865 let errcaught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3866 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3867 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3868 throw "x8"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3869 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3870 let lnum = expand("<sflnum>")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3871 asdf
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3872 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3873 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3874 let errcaught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3875 call assert_match('Vim:E492: Not an editor command:', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3876 call assert_match('line ' .. (lnum + 1), v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3877 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3878 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3879 call assert_equal(1, errcaught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3880 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3881 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3882 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3883 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3884 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3885
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3886 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3887
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3888 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3889 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3890 let intcaught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3891 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3892 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3893 throw "x9"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3894 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3895 let lnum = expand("<sflnum>")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3896 call interrupt()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3897 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3898 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3899 let intcaught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3900 call assert_match('Vim:Interrupt', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3901 call assert_match('line ' .. (lnum + 1), v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3902 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3903 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3904 call assert_equal(1, intcaught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3905 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3906 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3907 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3908 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3909 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3910
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3911 Xpath 'e'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3912
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3913 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3914 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3915 let errcaught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3916 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3917 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3918 if 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3919 let lnum = expand("<sflnum>")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3920 throw "x10"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3921 " missing endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3922 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3923 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3924 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3925 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3926 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3927 let errcaught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3928 call assert_match('Vim(finally):E171: Missing :endif:', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3929 call assert_match('line ' .. (lnum + 3), v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3930 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3931 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3932 call assert_equal(1, errcaught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3933 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3934 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3935 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3936 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3937 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3938
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3939 Xpath 'f'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3940
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3941 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3942 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3943 let errcaught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3944 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3945 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3946 if 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3947 let lnum = expand("<sflnum>")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3948 throw "x11"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3949 " missing endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3950 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3951 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3952 let errcaught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3953 call assert_match('Vim(endtry):E171: Missing :endif:', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3954 call assert_match('line ' .. (lnum + 3), v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3955 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3956 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3957 call assert_equal(1, errcaught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3958 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3959 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3960 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3961 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3962 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3963
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3964 Xpath 'g'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3965 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3966 let verify =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3967 call assert_equal('abcdefg', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3968 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3969 call RunInNewVim(test, verify)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3970 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3971
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3972 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3973 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3974 " Test 60: (Re)throwing v:exception; :echoerr. {{{1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3975 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3976 " A user exception can be rethrown after catching by throwing
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3977 " v:exception. An error or interrupt exception cannot be rethrown
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3978 " because Vim exceptions cannot be faked. A Vim exception using the
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3979 " value of v:exception can, however, be triggered by the :echoerr
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3980 " command.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3981 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3982
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3983 func Test_rethrow_exception_1()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3984 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3985 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3986 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3987 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3988 throw "oops"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3989 catch /oops/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3990 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3991 throw v:exception " rethrow user exception
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3992 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3993 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3994 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3995 catch /^oops$/ " catches rethrown user exception
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3996 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3997 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3998 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3999 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4000 call assert_equal('abc', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4001 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4002
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4003 func Test_rethrow_exception_2()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4004 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4005 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4006 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4007 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4008 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4009 write /n/o/n/w/r/i/t/a/b/l/e/_/f/i/l/e
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4010 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4011 catch /^Vim(write):/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4012 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4013 throw v:exception " throw error: cannot fake Vim exception
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4014 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4015 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4016 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4017 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4018 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4019 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4020 catch /^Vim(throw):/ " catches throw error
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4021 let caught = caught + 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4022 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4023 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4024 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4025 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4026 call assert_equal(2, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4027 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4028 call assert_equal('abc', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4029 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4030
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4031 func Test_rethrow_exception_3()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4032 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4033 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4034 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4035 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4036 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4037 asdf
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4038 catch /^Vim/ " catch error exception
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4039 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4040 " Trigger Vim error exception with value specified after :echoerr
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4041 let value = substitute(v:exception, '^Vim\((.*)\)\=:', '', "")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4042 echoerr value
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4043 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4044 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4045 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4046 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4047 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4048 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4049 catch /^Vim(echoerr):/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4050 let caught = caught + 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4051 call assert_match(value, v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4052 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4053 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4054 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4055 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4056 call assert_equal(2, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4057 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4058 call assert_equal('abc', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4059 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4060
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4061 func Test_rethrow_exception_3()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4062 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4063 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4064 let errcaught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4065 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4066 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4067 let intcaught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4068 call interrupt()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4069 catch /^Vim:/ " catch interrupt exception
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4070 let intcaught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4071 " Trigger Vim error exception with value specified after :echoerr
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4072 echoerr substitute(v:exception, '^Vim\((.*)\)\=:', '', "")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4073 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4074 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4075 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4076 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4077 call assert_equal(1, intcaught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4078 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4079 catch /^Vim(echoerr):/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4080 let errcaught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4081 call assert_match('Interrupt', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4082 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4083 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4084 call assert_equal(1, errcaught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4085 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4086 call assert_equal('abc', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4087 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4088
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4089 "-------------------------------------------------------------------------------
21666
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4090 " Test 61: Catching interrupt exceptions {{{1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4091 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4092 " When an interrupt occurs inside a :try/:endtry region, an
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4093 " interrupt exception is thrown and can be caught. Its value is
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4094 " "Vim:Interrupt". If the interrupt occurs after an error or a :throw
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4095 " but before a matching :catch is reached, all following :catches of
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4096 " that try block are ignored, but the interrupt exception can be
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4097 " caught by the next surrounding try conditional. An interrupt is
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4098 " ignored when there is a previous interrupt that has not been caught
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4099 " or causes a :finally clause to be executed.
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4100 "-------------------------------------------------------------------------------
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4101
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4102 func Test_catch_intr_exception()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4103 let test =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4104 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4105 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4106 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4107 Xpath 'a'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4108 call interrupt()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4109 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4110 catch /^Vim:Interrupt$/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4111 Xpath 'b'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4112 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4113 Xpath 'c'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4114 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4115 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4116 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4117 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4118 Xpath 'd'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4119 break
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4120 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4121 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4122
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4123 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4124 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4125 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4126 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4127 Xpath 'e'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4128 asdf
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4129 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4130 catch /do_not_catch/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4131 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4132 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4133 Xpath 'f'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4134 call interrupt()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4135 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4136 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4137 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4138 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4139 Xpath 'g'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4140 call interrupt()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4141 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4142 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4143 catch /^Vim:Interrupt$/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4144 Xpath 'h'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4145 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4146 Xpath 'i'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4147 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4148 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4149 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4150 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4151 Xpath 'j'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4152 break
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4153 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4154 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4155
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4156 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4157 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4158 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4159 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4160 Xpath 'k'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4161 throw "x"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4162 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4163 catch /do_not_catch/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4164 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4165 catch /x/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4166 Xpath 'l'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4167 call interrupt()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4168 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4169 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4170 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4171 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4172 catch /^Vim:Interrupt$/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4173 Xpath 'm'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4174 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4175 Xpath 'n'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4176 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4177 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4178 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4179 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4180 Xpath 'o'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4181 break
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4182 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4183 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4184
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4185 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4186 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4187 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4188 Xpath 'p'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4189 call interrupt()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4190 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4191 catch /do_not_catch/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4192 call interrupt()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4193 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4194 catch /^Vim:Interrupt$/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4195 Xpath 'q'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4196 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4197 Xpath 'r'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4198 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4199 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4200 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4201 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4202 Xpath 's'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4203 break
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4204 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4205 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4206
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4207 Xpath 't'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4208 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4209 let verify =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4210 call assert_equal('abcdefghijklmnopqrst', g:Xpath)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4211 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4212 call RunInNewVim(test, verify)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4213 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4214
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4215 "-------------------------------------------------------------------------------
21735
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4216 " Test 62: Catching error exceptions {{{1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4217 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4218 " An error inside a :try/:endtry region is converted to an exception
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4219 " and can be caught. The error exception has a "Vim(cmdname):" prefix
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4220 " where cmdname is the name of the failing command, or a "Vim:" prefix
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4221 " if no command name is known. The "Vim" prefixes cannot be faked.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4222 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4223
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4224 func Test_catch_err_exception_1()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4225 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4226 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4227 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4228 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4229 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4230 unlet novar
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4231 catch /^Vim(unlet):/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4232 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4233 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4234 let v:errmsg = substitute(v:exception, '^Vim(unlet):', '', "")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4235 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4236 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4237 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4238 call assert_match('E108: No such variable: "novar"', v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4239 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4240 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4241 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4242 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4243 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4244 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4245 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4246 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4247 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4248 call assert_equal('abc', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4249 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4250
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4251 func Test_catch_err_exception_2()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4252 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4253 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4254 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4255 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4256 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4257 throw novar " error in :throw
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4258 catch /^Vim(throw):/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4259 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4260 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4261 let v:errmsg = substitute(v:exception, '^Vim(throw):', '', "")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4262 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4263 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4264 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4265 call assert_match('E121: Undefined variable: novar', v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4266 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4267 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4268 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4269 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4270 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4271 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4272 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4273 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4274 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4275 call assert_equal('abc', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4276 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4277
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4278 func Test_catch_err_exception_3()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4279 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4280 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4281 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4282 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4283 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4284 throw "Vim:faked" " error: cannot fake Vim exception
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4285 catch /^Vim(throw):/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4286 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4287 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4288 let v:errmsg = substitute(v:exception, '^Vim(throw):', '', "")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4289 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4290 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4291 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4292 call assert_match("E608: Cannot :throw exceptions with 'Vim' prefix",
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4293 \ v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4294 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4295 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4296 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4297 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4298 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4299 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4300 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4301 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4302 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4303 call assert_equal('abc', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4304 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4305
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4306 func Test_catch_err_exception_4()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4307 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4308 func F()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4309 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4310 " Missing :endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4311 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4312
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4313 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4314 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4315 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4316 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4317 call F()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4318 catch /^Vim(endfunction):/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4319 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4320 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4321 let v:errmsg = substitute(v:exception, '^Vim(endfunction):', '', "")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4322 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4323 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4324 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4325 call assert_match("E170: Missing :endwhile", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4326 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4327 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4328 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4329 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4330 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4331 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4332 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4333 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4334 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4335 call assert_equal('abc', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4336 delfunc F
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4337 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4338
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4339 func Test_catch_err_exception_5()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4340 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4341 func F()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4342 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4343 " Missing :endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4344 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4345
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4346 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4347 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4348 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4349 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4350 ExecAsScript F
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4351 catch /^Vim:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4352 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4353 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4354 let v:errmsg = substitute(v:exception, '^Vim:', '', "")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4355 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4356 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4357 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4358 call assert_match("E170: Missing :endwhile", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4359 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4360 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4361 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4362 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4363 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4364 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4365 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4366 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4367 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4368 call assert_equal('abc', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4369 delfunc F
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4370 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4371
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4372 func Test_catch_err_exception_6()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4373 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4374 func G()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4375 call G()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4376 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4377
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4378 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4379 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4380 let mfd_save = &mfd
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4381 set mfd=3
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4382 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4383 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4384 call G()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4385 catch /^Vim(call):/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4386 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4387 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4388 let v:errmsg = substitute(v:exception, '^Vim(call):', '', "")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4389 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4390 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4391 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4392 call assert_match("E132: Function call depth is higher than 'maxfuncdepth'", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4393 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4394 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4395 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4396 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4397 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4398 let &mfd = mfd_save
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4399 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4400 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4401 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4402 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4403 call assert_equal('abc', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4404 delfunc G
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4405 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4406
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4407 func Test_catch_err_exception_7()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4408 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4409 func H()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4410 return H()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4411 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4412
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4413 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4414 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4415 let mfd_save = &mfd
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4416 set mfd=3
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4417 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4418 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4419 call H()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4420 catch /^Vim(return):/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4421 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4422 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4423 let v:errmsg = substitute(v:exception, '^Vim(return):', '', "")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4424 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4425 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4426 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4427 call assert_match("E132: Function call depth is higher than 'maxfuncdepth'", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4428 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4429 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4430 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4431 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4432 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4433 let &mfd = mfd_save
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4434 break " discard error for $VIMNOERRTHROW
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4435 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4436 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4437 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4438
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4439 call assert_equal('abc', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4440 delfunc H
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4441 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4442
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4443 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4444 " Test 63: Suppressing error exceptions by :silent!. {{{1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4445 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4446 " A :silent! command inside a :try/:endtry region suppresses the
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4447 " conversion of errors to an exception and the immediate abortion on
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4448 " error. When the commands executed by the :silent! themselves open
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4449 " a new :try/:endtry region, conversion of errors to exception and
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4450 " immediate abortion is switched on again - until the next :silent!
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4451 " etc. The :silent! has the effect of setting v:errmsg to the error
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4452 " message text (without displaying it) and continuing with the next
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4453 " script line.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4454 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4455 " When a command triggering autocommands is executed by :silent!
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4456 " inside a :try/:endtry, the autocommand execution is not suppressed
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4457 " on error.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4458 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4459 " This test reuses the function MSG() from the previous test.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4460 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4461
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4462 func Test_silent_exception()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4463 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4464 XloopINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4465 let g:taken = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4466
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4467 func S(n) abort
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4468 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4469 let g:taken = g:taken . "E" . a:n
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4470 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4471 exec "asdf" . a:n
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4472
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4473 " Check that ":silent!" continues:
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4474 Xloop 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4475
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4476 " Check that ":silent!" sets "v:errmsg":
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4477 call assert_match("E492: Not an editor command", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4478 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4479
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4480 func Foo()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4481 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4482 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4483 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4484 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4485 " This is not silent:
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4486 call S(3)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4487 catch /^Vim:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4488 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4489 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4490 let errmsg3 = substitute(v:exception, '^Vim:', '', "")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4491 silent! call S(4)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4492 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4493 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4494 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4495 call assert_match("E492: Not an editor command", errmsg3)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4496 silent! call S(5)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4497 " Break out of try conditionals that cover ":silent!". This also
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4498 " discards the aborting error when $VIMNOERRTHROW is non-zero.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4499 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4500 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4501 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4502 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4503 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4504 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4505 " This is a double ":silent!" (see caller).
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4506 silent! call S(6)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4507 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4508
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4509 func Bar()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4510 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4511 silent! call S(2)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4512 silent! execute "call Foo() | call S(7)"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4513 silent! call S(8)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4514 endtry " normal end of try cond that covers ":silent!"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4515 " This has a ":silent!" from the caller:
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4516 call S(9)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4517 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4518
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4519 silent! call S(1)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4520 silent! call Bar()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4521 silent! call S(10)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4522
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4523 call assert_equal("E1E2E3E4E5E6E7E8E9E10", g:taken)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4524
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4525 augroup TMP
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4526 au!
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4527 autocmd BufWritePost * Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4528 augroup END
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4529
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4530 Xpath 'e'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4531 silent! write /i/m/p/o/s/s/i/b/l/e
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4532 Xpath 'f'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4533
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4534 call assert_equal('a2a3ba5ca6a7a8a9a10a11edf', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4535
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4536 augroup TMP
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4537 au!
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4538 augroup END
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4539 augroup! TMP
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4540 delfunction S
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4541 delfunction Foo
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4542 delfunction Bar
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4543 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4544
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4545 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4546 " Test 64: Error exceptions after error, interrupt or :throw {{{1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4547 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4548 " When an error occurs after an interrupt or a :throw but before
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4549 " a matching :catch is reached, all following :catches of that try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4550 " block are ignored, but the error exception can be caught by the next
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4551 " surrounding try conditional. Any previous error exception is
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4552 " discarded. An error is ignored when there is a previous error that
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4553 " has not been caught.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4554 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4555
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4556 func Test_exception_after_error_1()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4557 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4558 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4559 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4560 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4561 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4562 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4563 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4564 if 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4565 " Missing :endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4566 endwhile " throw error exception
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4567 catch /^Vim(/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4568 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4569 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4570 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4571 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4572 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4573 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4574 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4575 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4576 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4577 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4578 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4579 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4580 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4581 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4582 call assert_equal('abcd', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4583 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4584
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4585 func Test_exception_after_error_2()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4586 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4587 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4588 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4589 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4590 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4591 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4592 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4593 if 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4594 " Missing :endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4595 catch /.*/ " throw error exception
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4596 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4597 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4598 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4599 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4600 catch /^Vim(/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4601 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4602 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4603 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4604 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4605 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4606 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4607 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4608 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4609 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4610 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4611 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4612 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4613 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4614 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4615 call assert_equal('abcd', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4616 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4617
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4618 func Test_exception_after_error_3()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4619 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4620 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4621 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4622 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4623 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4624 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4625 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4626 call interrupt()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4627 catch /do_not_catch/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4628 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4629 if 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4630 " Missing :endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4631 catch /.*/ " throw error exception
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4632 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4633 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4634 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4635 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4636 catch /^Vim(/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4637 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4638 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4639 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4640 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4641 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4642 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4643 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4644 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4645 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4646 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4647 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4648 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4649 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4650 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4651 call assert_equal('abcd', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4652 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4653
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4654 func Test_exception_after_error_4()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4655 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4656 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4657 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4658 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4659 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4660 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4661 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4662 throw "x"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4663 catch /do_not_catch/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4664 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4665 if 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4666 " Missing :endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4667 catch /x/ " throw error exception
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4668 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4669 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4670 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4671 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4672 catch /^Vim(/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4673 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4674 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4675 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4676 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4677 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4678 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4679 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4680 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4681 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4682 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4683 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4684 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4685 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4686 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4687 call assert_equal('abcd', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4688 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4689
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4690 func Test_exception_after_error_5()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4691 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4692 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4693 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4694 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4695 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4696 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4697 endif " :endif without :if; throw error exception
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4698 if 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4699 " Missing :endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4700 catch /do_not_catch/ " ignore new error
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4701 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4702 catch /^Vim(endif):/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4703 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4704 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4705 catch /^Vim(/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4706 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4707 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4708 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4709 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4710 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4711 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4712 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4713 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4714 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4715 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4716 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4717 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4718 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4719 call assert_equal('abcd', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4720 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4721
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4722 "-------------------------------------------------------------------------------
21666
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4723 " Test 65: Errors in the /pattern/ argument of a :catch {{{1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4724 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4725 " On an error in the /pattern/ argument of a :catch, the :catch does
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4726 " not match. Any following :catches of the same :try/:endtry don't
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4727 " match either. Finally clauses are executed.
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4728 "-------------------------------------------------------------------------------
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4729
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4730 func Test_catch_pattern_error()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4731 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4732 XpathINIT
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4733
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4734 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4735 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4736 Xpath 'a'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4737 throw "oops"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4738 catch /^oops$/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4739 Xpath 'b'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4740 catch /\)/ " not checked; exception has already been caught
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4741 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4742 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4743 Xpath 'c'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4744 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4745 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4746 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4747 call assert_equal('abc', g:Xpath)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4748
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4749 XpathINIT
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4750 func F()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4751 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4752 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4753 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4754 Xpath 'a'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4755 throw "ab"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4756 catch /abc/ " does not catch
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4757 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4758 catch /\)/ " error; discards exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4759 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4760 catch /.*/ " not checked
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4761 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4762 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4763 Xpath 'b'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4764 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4765 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4766 catch /^ab$/ " checked, but original exception is discarded
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4767 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4768 catch /^Vim(catch):/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4769 Xpath 'c'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4770 call assert_match('Vim(catch):E475: Invalid argument:', v:exception)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4771 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4772 Xpath 'd'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4773 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4774 Xpath 'e'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4775 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4776 call assert_report('should not get here')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4777 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4778 Xpath 'f'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4779 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4780
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4781 call F()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4782 call assert_equal('abcdef', g:Xpath)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4783
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4784 delfunc F
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4785 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4786
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4787 "-------------------------------------------------------------------------------
21735
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4788 " Test 66: Stop range :call on error, interrupt, or :throw {{{1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4789 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4790 " When a function which is multiply called for a range since it
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4791 " doesn't handle the range itself has an error in a command
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4792 " dynamically enclosed by :try/:endtry or gets an interrupt or
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4793 " executes a :throw, no more calls for the remaining lines in the
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4794 " range are made. On an error in a command not dynamically enclosed
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4795 " by :try/:endtry, the function is executed again for the remaining
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4796 " lines in the range.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4797 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4798
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4799 func Test_stop_range_on_error()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4800 let test =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4801 let file = tempname()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4802 exec "edit" file
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4803 call setline(1, ['line 1', 'line 2', 'line 3'])
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4804 let taken = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4805 let expected = "G1EF1E(1)F1E(2)F1E(3)G2EF2E(1)G3IF3I(1)G4TF4T(1)G5AF5A(1)"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4806
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4807 func F(reason, n) abort
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4808 let g:taken = g:taken .. "F" .. a:n ..
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4809 \ substitute(a:reason, '\(\l\).*', '\u\1', "") ..
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4810 \ "(" .. line(".") .. ")"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4811
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4812 if a:reason == "error"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4813 asdf
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4814 elseif a:reason == "interrupt"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4815 call interrupt()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4816 elseif a:reason == "throw"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4817 throw "xyz"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4818 elseif a:reason == "aborting error"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4819 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4820 call assert_equal(g:taken, g:expected)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4821 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4822 bwipeout!
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4823 call delete(g:file)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4824 asdf
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4825 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4826 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4827 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4828
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4829 func G(reason, n)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4830 let g:taken = g:taken .. "G" .. a:n ..
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4831 \ substitute(a:reason, '\(\l\).*', '\u\1', "")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4832 1,3call F(a:reason, a:n)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4833 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4834
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4835 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4836 call G("error", 1)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4837 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4838 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4839 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4840 call G("error", 2)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4841 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4842 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4843 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4844 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4845 call G("interrupt", 3)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4846 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4847 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4848 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4849 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4850 call G("throw", 4)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4851 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4852 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4853 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4854 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4855 catch /xyz/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4856 Xpath 'e'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4857 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4858 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4859 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4860 Xpath 'f'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4861 call G("aborting error", 5)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4862 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4863 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4864 let verify =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4865 call assert_equal('abcdef', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4866 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4867 call RunInNewVim(test, verify)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4868 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4869
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4870 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4871 " Test 67: :throw across :call command {{{1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4872 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4873 " On a call command, an exception might be thrown when evaluating the
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4874 " function name, during evaluation of the arguments, or when the
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4875 " function is being executed. The exception can be caught by the
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4876 " caller.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4877 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4878
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4879 func THROW(x, n)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4880 if a:n == 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4881 Xpath 'A'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4882 elseif a:n == 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4883 Xpath 'B'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4884 elseif a:n == 3
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4885 Xpath 'C'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4886 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4887 throw a:x
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4888 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4889
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4890 func NAME(x, n)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4891 if a:n == 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4892 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4893 elseif a:n == 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4894 Xpath 'D'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4895 elseif a:n == 3
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4896 Xpath 'E'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4897 elseif a:n == 4
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4898 Xpath 'F'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4899 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4900 return a:x
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4901 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4902
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4903 func ARG(x, n)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4904 if a:n == 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4905 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4906 elseif a:n == 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4907 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4908 elseif a:n == 3
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4909 Xpath 'G'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4910 elseif a:n == 4
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4911 Xpath 'I'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4912 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4913 return a:x
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4914 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4915
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4916 func Test_throw_across_call_cmd()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4917 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4918
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4919 func F(x, n)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4920 if a:n == 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4921 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4922 elseif a:n == 4
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4923 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4924 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4925 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4926
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4927 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4928 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4929 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4930
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4931 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4932 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4933 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4934 call {NAME(THROW("name", 1), 1)}(ARG(4711, 1), 1)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4935 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4936 catch /^name$/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4937 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4938 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4939 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4940 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4941 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4942 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4943 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4944 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4945 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4946
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4947 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4948 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4949 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4950 call {NAME("F", 2)}(ARG(THROW("arg", 2), 2), 2)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4951 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4952 catch /^arg$/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4953 Xpath 'e'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4954 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4955 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4956 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4957 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4958 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4959 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4960 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4961 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4962
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4963 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4964 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4965 Xpath 'f'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4966 call {NAME("THROW", 3)}(ARG("call", 3), 3)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4967 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4968 catch /^call$/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4969 Xpath 'g'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4970 catch /^0$/ " default return value
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4971 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4972 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4973 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4974 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4975 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4976 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4977 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4978 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4979 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4980
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4981 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4982 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4983 Xpath 'h'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4984 call {NAME("F", 4)}(ARG(4711, 4), 4)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4985 Xpath 'i'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4986 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4987 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4988 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4989 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4990 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4991 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4992 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4993 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4994
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4995 catch /^0$/ " default return value
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4996 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4997 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4998 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4999 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5000 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5001 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5002 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5003 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5004 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5005
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5006 call assert_equal('bAcdDBefEGCghFIai', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5007 delfunction F
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5008 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5009
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5010 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5011 " Test 68: :throw across function calls in expressions {{{1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5012 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5013 " On a function call within an expression, an exception might be
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5014 " thrown when evaluating the function name, during evaluation of the
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5015 " arguments, or when the function is being executed. The exception
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5016 " can be caught by the caller.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5017 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5018 " This test reuses the functions THROW(), NAME(), and ARG() from the
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5019 " previous test.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5020 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5021
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5022 func Test_throw_across_call_expr()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5023 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5024
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5025 func F(x, n)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5026 if a:n == 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5027 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5028 elseif a:n == 4
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5029 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5030 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5031 return a:x
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5032 endfunction
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5033
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5034 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5035 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5036 let error = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5037 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5038
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5039 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5040 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5041 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5042 let var1 = {NAME(THROW("name", 1), 1)}(ARG(4711, 1), 1)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5043 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5044 catch /^name$/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5045 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5046 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5047 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5048 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5049 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5050 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5051 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5052 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5053 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5054 call assert_true(!exists('var1'))
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5055
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5056 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5057 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5058 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5059 let var2 = {NAME("F", 2)}(ARG(THROW("arg", 2), 2), 2)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5060 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5061 catch /^arg$/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5062 Xpath 'e'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5063 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5064 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5065 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5066 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5067 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5068 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5069 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5070 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5071 call assert_true(!exists('var2'))
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5072
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5073 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5074 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5075 Xpath 'f'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5076 let var3 = {NAME("THROW", 3)}(ARG("call", 3), 3)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5077 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5078 catch /^call$/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5079 Xpath 'g'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5080 catch /^0$/ " default return value
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5081 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5082 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5083 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5084 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5085 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5086 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5087 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5088 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5089 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5090 call assert_true(!exists('var3'))
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5091
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5092 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5093 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5094 Xpath 'h'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5095 let var4 = {NAME("F", 4)}(ARG(4711, 4), 4)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5096 Xpath 'i'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5097 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5098 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5099 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5100 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5101 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5102 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5103 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5104 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5105 call assert_true(exists('var4') && var4 == 4711)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5106
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5107 catch /^0$/ " default return value
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5108 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5109 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5110 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5111 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5112 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5113 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5114 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5115 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5116
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5117 call assert_equal('bAcdDBefEGCghFIai', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5118 delfunc F
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5119 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5120
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5121 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5122 " Test 76: Errors, interrupts, :throw during expression evaluation {{{1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5123 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5124 " When a function call made during expression evaluation is aborted
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5125 " due to an error inside a :try/:endtry region or due to an interrupt
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5126 " or a :throw, the expression evaluation is aborted as well. No
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5127 " message is displayed for the cancelled expression evaluation. On an
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5128 " error not inside :try/:endtry, the expression evaluation continues.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5129 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5130
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5131 func Test_expr_eval_error()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5132 let test =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5133 let taken = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5134
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5135 func ERR(n)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5136 let g:taken = g:taken .. "E" .. a:n
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5137 asdf
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5138 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5139
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5140 func ERRabort(n) abort
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5141 let g:taken = g:taken .. "A" .. a:n
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5142 asdf
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5143 endfunc " returns -1; may cause follow-up msg for illegal var/func name
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5144
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5145 func WRAP(n, arg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5146 let g:taken = g:taken .. "W" .. a:n
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5147 let g:saved_errmsg = v:errmsg
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5148 return arg
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5149 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5150
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5151 func INT(n)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5152 let g:taken = g:taken .. "I" .. a:n
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5153 call interrupt()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5154 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5155
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5156 func THR(n)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5157 let g:taken = g:taken .. "T" .. a:n
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5158 throw "should not be caught"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5159 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5160
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5161 func CONT(n)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5162 let g:taken = g:taken .. "C" .. a:n
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5163 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5164
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5165 func MSG(n)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5166 let g:taken = g:taken .. "M" .. a:n
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5167 let errmsg = (a:n >= 37 && a:n <= 44) ? g:saved_errmsg : v:errmsg
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5168 let msgptn = (a:n >= 10 && a:n <= 27) ? "^$" : "asdf"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5169 call assert_match(msgptn, errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5170 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5171 let g:saved_errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5172 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5173
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5174 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5175
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5176 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5177 let t = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5178 while t <= 9
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5179 Xloop 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5180 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5181 if t == 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5182 let v{ERR(t) + CONT(t)} = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5183 elseif t == 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5184 let v{ERR(t) + CONT(t)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5185 elseif t == 3
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5186 let var = exists('v{ERR(t) + CONT(t)}')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5187 elseif t == 4
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5188 unlet v{ERR(t) + CONT(t)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5189 elseif t == 5
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5190 function F{ERR(t) + CONT(t)}()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5191 endfunction
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5192 elseif t == 6
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5193 function F{ERR(t) + CONT(t)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5194 elseif t == 7
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5195 let var = exists('*F{ERR(t) + CONT(t)}')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5196 elseif t == 8
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5197 delfunction F{ERR(t) + CONT(t)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5198 elseif t == 9
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5199 let var = ERR(t) + CONT(t)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5200 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5201 catch /asdf/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5202 " v:errmsg is not set when the error message is converted to an
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5203 " exception. Set it to the original error message.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5204 let v:errmsg = substitute(v:exception, '^Vim:', '', "")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5205 catch /^Vim\((\a\+)\)\=:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5206 " An error exception has been thrown after the original error.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5207 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5208 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5209 call MSG(t)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5210 let t = t + 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5211 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5212 continue " discard an aborting error
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5213 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5214 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5215 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5216 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5217 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5218
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5219 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5220 let t = 10
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5221 while t <= 18
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5222 Xloop 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5223 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5224 if t == 10
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5225 let v{INT(t) + CONT(t)} = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5226 elseif t == 11
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5227 let v{INT(t) + CONT(t)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5228 elseif t == 12
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5229 let var = exists('v{INT(t) + CONT(t)}')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5230 elseif t == 13
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5231 unlet v{INT(t) + CONT(t)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5232 elseif t == 14
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5233 function F{INT(t) + CONT(t)}()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5234 endfunction
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5235 elseif t == 15
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5236 function F{INT(t) + CONT(t)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5237 elseif t == 16
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5238 let var = exists('*F{INT(t) + CONT(t)}')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5239 elseif t == 17
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5240 delfunction F{INT(t) + CONT(t)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5241 elseif t == 18
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5242 let var = INT(t) + CONT(t)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5243 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5244 catch /^Vim\((\a\+)\)\=:\(Interrupt\)\@!/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5245 " An error exception has been triggered after the interrupt.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5246 let v:errmsg = substitute(v:exception, '^Vim\((\a\+)\)\=:', '', "")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5247 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5248 call MSG(t)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5249 let t = t + 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5250 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5251 continue " discard interrupt
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5252 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5253 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5254 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5255 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5256 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5257
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5258 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5259 let t = 19
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5260 while t <= 27
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5261 Xloop 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5262 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5263 if t == 19
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5264 let v{THR(t) + CONT(t)} = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5265 elseif t == 20
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5266 let v{THR(t) + CONT(t)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5267 elseif t == 21
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5268 let var = exists('v{THR(t) + CONT(t)}')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5269 elseif t == 22
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5270 unlet v{THR(t) + CONT(t)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5271 elseif t == 23
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5272 function F{THR(t) + CONT(t)}()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5273 endfunction
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5274 elseif t == 24
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5275 function F{THR(t) + CONT(t)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5276 elseif t == 25
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5277 let var = exists('*F{THR(t) + CONT(t)}')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5278 elseif t == 26
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5279 delfunction F{THR(t) + CONT(t)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5280 elseif t == 27
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5281 let var = THR(t) + CONT(t)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5282 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5283 catch /^Vim\((\a\+)\)\=:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5284 " An error exception has been triggered after the :throw.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5285 let v:errmsg = substitute(v:exception, '^Vim\((\a\+)\)\=:', '', "")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5286 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5287 call MSG(t)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5288 let t = t + 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5289 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5290 continue " discard exception
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5291 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5292 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5293 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5294 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5295 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5296
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5297 let v{ERR(28) + CONT(28)} = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5298 call MSG(28)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5299 let v{ERR(29) + CONT(29)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5300 call MSG(29)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5301 let var = exists('v{ERR(30) + CONT(30)}')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5302 call MSG(30)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5303 unlet v{ERR(31) + CONT(31)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5304 call MSG(31)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5305 function F{ERR(32) + CONT(32)}()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5306 endfunction
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5307 call MSG(32)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5308 function F{ERR(33) + CONT(33)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5309 call MSG(33)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5310 let var = exists('*F{ERR(34) + CONT(34)}')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5311 call MSG(34)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5312 delfunction F{ERR(35) + CONT(35)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5313 call MSG(35)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5314 let var = ERR(36) + CONT(36)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5315 call MSG(36)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5316
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5317 let saved_errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5318
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5319 let v{WRAP(37, ERRabort(37)) + CONT(37)} = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5320 call MSG(37)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5321 let v{WRAP(38, ERRabort(38)) + CONT(38)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5322 call MSG(38)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5323 let var = exists('v{WRAP(39, ERRabort(39)) + CONT(39)}')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5324 call MSG(39)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5325 unlet v{WRAP(40, ERRabort(40)) + CONT(40)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5326 call MSG(40)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5327 function F{WRAP(41, ERRabort(41)) + CONT(41)}()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5328 endfunction
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5329 call MSG(41)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5330 function F{WRAP(42, ERRabort(42)) + CONT(42)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5331 call MSG(42)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5332 let var = exists('*F{WRAP(43, ERRabort(43)) + CONT(43)}')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5333 call MSG(43)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5334 delfunction F{WRAP(44, ERRabort(44)) + CONT(44)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5335 call MSG(44)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5336 let var = ERRabort(45) + CONT(45)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5337 call MSG(45)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5338 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5339
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5340 let expected = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5341 \ .. "E1M1E2M2E3M3E4M4E5M5E6M6E7M7E8M8E9M9"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5342 \ .. "I10M10I11M11I12M12I13M13I14M14I15M15I16M16I17M17I18M18"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5343 \ .. "T19M19T20M20T21M21T22M22T23M23T24M24T25M25T26M26T27M27"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5344 \ .. "E28C28M28E29C29M29E30C30M30E31C31M31E32C32M32E33C33M33"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5345 \ .. "E34C34M34E35C35M35E36C36M36"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5346 \ .. "A37W37C37M37A38W38C38M38A39W39C39M39A40W40C40M40A41W41C41M41"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5347 \ .. "A42W42C42M42A43W43C43M43A44W44C44M44A45C45M45"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5348 call assert_equal(expected, taken)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5349 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5350 let verify =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5351 let expected = "a1a2a3a4a5a6a7a8a9"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5352 \ .. "b10b11b12b13b14b15b16b17b18"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5353 \ .. "c19c20c21c22c23c24c25c26c27d"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5354 call assert_equal(expected, g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5355 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5356 call RunInNewVim(test, verify)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5357 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5358
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5359 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5360 " Test 77: Errors, interrupts, :throw in name{brace-expression} {{{1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5361 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5362 " When a function call made during evaluation of an expression in
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5363 " braces as part of a function name after ":function" is aborted due
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5364 " to an error inside a :try/:endtry region or due to an interrupt or
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5365 " a :throw, the expression evaluation is aborted as well, and the
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5366 " function definition is ignored, skipping all commands to the
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5367 " ":endfunction". On an error not inside :try/:endtry, the expression
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5368 " evaluation continues and the function gets defined, and can be
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5369 " called and deleted.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5370 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5371 func Test_brace_expr_error()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5372 let test =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5373 func ERR() abort
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5374 Xloop 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5375 asdf
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5376 endfunc " returns -1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5377
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5378 func OK()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5379 Xloop 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5380 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5381 return 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5382 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5383
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5384 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5385
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5386 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5387 func F{1 + ERR() + OK()}(arg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5388 " F0 should be defined.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5389 if exists("a:arg") && a:arg == "calling"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5390 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5391 else
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5392 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5393 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5394 endfunction
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5395 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5396 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5397
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5398 Xpath 'e'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5399 call F{1 + ERR() + OK()}("calling")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5400 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5401 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5402
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5403 Xpath 'f'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5404 delfunction F{1 + ERR() + OK()}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5405 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5406 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5407
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5408 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5409 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5410 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5411 Xpath 'g'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5412 func G{1 + ERR() + OK()}(arg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5413 " G0 should not be defined, and the function body should be
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5414 " skipped.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5415 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5416 " Use an unmatched ":finally" to check whether the body is
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5417 " skipped when an error occurs in ERR(). This works whether or
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5418 " not the exception is converted to an exception.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5419 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5420 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5421 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5422 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5423 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5424 endfunction
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5425
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5426 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5427 catch /asdf/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5428 " Jumped to when the function is not defined and the body is
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5429 " skipped.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5430 Xpath 'h'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5431 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5432 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5433 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5434 Xpath 'i'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5435 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5436 endtry " jumped to when the body is not skipped
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5437 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5438 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5439 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5440 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5441 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5442 let verify =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5443 call assert_equal('ca1b1ea2b2dfa3b3ga4hi', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5444 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5445 call RunInNewVim(test, verify)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5446 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5447
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5448 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5449 " Test 78: Messages on parsing errors in expression evaluation {{{1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5450 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5451 " When an expression evaluation detects a parsing error, an error
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5452 " message is given and converted to an exception, and the expression
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5453 " evaluation is aborted.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5454 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5455 func Test_expr_eval_error_msg()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5456 CheckEnglish
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5457
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5458 let test =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5459 let taken = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5460
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5461 func F(n)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5462 let g:taken = g:taken . "F" . a:n
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5463 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5464
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5465 func MSG(n, enr, emsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5466 let g:taken = g:taken . "M" . a:n
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5467 call assert_match('^' .. a:enr .. ':', v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5468 call assert_match(a:emsg, v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5469 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5470
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5471 func CONT(n)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5472 let g:taken = g:taken . "C" . a:n
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5473 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5474
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5475 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5476 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5477 let t = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5478 while t <= 14
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5479 let g:taken = g:taken . "T" . t
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5480 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5481 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5482 if t == 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5483 let v{novar + CONT(t)} = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5484 elseif t == 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5485 let v{novar + CONT(t)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5486 elseif t == 3
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5487 let var = exists('v{novar + CONT(t)}')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5488 elseif t == 4
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5489 unlet v{novar + CONT(t)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5490 elseif t == 5
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5491 function F{novar + CONT(t)}()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5492 endfunction
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5493 elseif t == 6
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5494 function F{novar + CONT(t)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5495 elseif t == 7
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5496 let var = exists('*F{novar + CONT(t)}')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5497 elseif t == 8
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5498 delfunction F{novar + CONT(t)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5499 elseif t == 9
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5500 echo novar + CONT(t)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5501 elseif t == 10
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5502 echo v{novar + CONT(t)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5503 elseif t == 11
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5504 echo F{novar + CONT(t)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5505 elseif t == 12
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5506 let var = novar + CONT(t)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5507 elseif t == 13
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5508 let var = v{novar + CONT(t)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5509 elseif t == 14
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5510 let var = F{novar + CONT(t)}()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5511 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5512 catch /^Vim\((\a\+)\)\=:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5513 Xloop 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5514 " v:errmsg is not set when the error message is converted to an
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5515 " exception. Set it to the original error message.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5516 let v:errmsg = substitute(v:exception, '^Vim\((\a\+)\)\=:', '', "")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5517 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5518 Xloop 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5519 if t <= 8 && t != 3 && t != 7
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5520 call MSG(t, 'E475', 'Invalid argument\>')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5521 else
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5522 call MSG(t, 'E121', "Undefined variable")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5523 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5524 let t = t + 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5525 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5526 continue " discard an aborting error
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5527 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5528 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5529 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5530 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5531 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5532
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5533 func T(n, expr, enr, emsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5534 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5535 let g:taken = g:taken . "T" . a:n
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5536 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5537 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5538 execute "let var = " . a:expr
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5539 catch /^Vim\((\a\+)\)\=:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5540 Xloop 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5541 " v:errmsg is not set when the error message is converted to an
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5542 " exception. Set it to the original error message.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5543 let v:errmsg = substitute(v:exception, '^Vim\((\a\+)\)\=:', '', "")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5544 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5545 Xloop 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5546 call MSG(a:n, a:enr, a:emsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5547 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5548 " Discard an aborting error:
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5549 return
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5550 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5551 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5552 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5553 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5554 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5555
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5556 call T(15, 'Nofunc() + CONT(15)', 'E117', "Unknown function")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5557 call T(16, 'F(1 2 + CONT(16))', 'E116', "Invalid arguments")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5558 call T(17, 'F(1, 2) + CONT(17)', 'E118', "Too many arguments")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5559 call T(18, 'F() + CONT(18)', 'E119', "Not enough arguments")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5560 call T(19, '{(1} + CONT(19)', 'E110', "Missing ')'")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5561 call T(20, '("abc"[1) + CONT(20)', 'E111', "Missing ']'")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5562 call T(21, '(1 +) + CONT(21)', 'E15', "Invalid expression")
24958
21ec48d542a8 patch 8.2.3016: confusing error when expression is followed by comma
Bram Moolenaar <Bram@vim.org>
parents: 24862
diff changeset
5563 call T(22, '1 2 + CONT(22)', 'E488', "Trailing characters: 2 +")
21735
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5564 call T(23, '(1 ? 2) + CONT(23)', 'E109', "Missing ':' after '?'")
26606
c40554dfe03e patch 8.2.3832: test fails because of changed error message
Bram Moolenaar <Bram@vim.org>
parents: 25615
diff changeset
5565 call T(24, '("abc) + CONT(24)', 'E114', "Missing double quote")
c40554dfe03e patch 8.2.3832: test fails because of changed error message
Bram Moolenaar <Bram@vim.org>
parents: 25615
diff changeset
5566 call T(25, "('abc) + CONT(25)", 'E115', "Missing single quote")
21735
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5567 call T(26, '& + CONT(26)', 'E112', "Option name missing")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5568 call T(27, '&asdf + CONT(27)', 'E113', "Unknown option")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5569
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5570 let expected = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5571 \ .. "T1M1T2M2T3M3T4M4T5M5T6M6T7M7T8M8T9M9T10M10T11M11T12M12T13M13T14M14"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5572 \ .. "T15M15T16M16T17M17T18M18T19M19T20M20T21M21T22M22T23M23T24M24T25M25"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5573 \ .. "T26M26T27M27"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5574
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5575 call assert_equal(expected, taken)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5576 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5577 let verify =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5578 let expected = "a1b1a2b2a3b3a4b4a5b5a6b6a7b7a8b8a9b9a10b10a11b11a12b12"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5579 \ .. "a13b13a14b14c15d15c16d16c17d17c18d18c19d19c20d20"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5580 \ .. "c21d21c22d22c23d23c24d24c25d25c26d26c27d27"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5581 call assert_equal(expected, g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5582 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5583 call RunInNewVim(test, verify)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5584 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5585
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5586 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5587 " Test 79: Throwing one of several errors for the same command {{{1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5588 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5589 " When several errors appear in a row (for instance during expression
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5590 " evaluation), the first as the most specific one is used when
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5591 " throwing an error exception. If, however, a syntax error is
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5592 " detected afterwards, this one is used for the error exception.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5593 " On a syntax error, the next command is not executed, on a normal
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5594 " error, however, it is (relevant only in a function without the
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5595 " "abort" flag). v:errmsg is not set.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5596 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5597 " If throwing error exceptions is configured off, v:errmsg is always
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5598 " set to the latest error message, that is, to the more general
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5599 " message or the syntax error, respectively.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5600 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5601 func Test_throw_multi_error()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5602 CheckEnglish
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5603
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5604 let test =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5605 func NEXT(cmd)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5606 exec a:cmd . " | Xloop 'a'"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5607 endfun
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5608
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5609 call NEXT('echo novar') " (checks nextcmd)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5610 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5611 call NEXT('let novar #') " (skips nextcmd)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5612 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5613 call NEXT('unlet novar #') " (skips nextcmd)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5614 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5615 call NEXT('let {novar}') " (skips nextcmd)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5616 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5617 call NEXT('unlet{ novar}') " (skips nextcmd)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5618
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5619 call assert_equal('a1', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5620 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5621 XloopINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5622
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5623 func EXEC(cmd)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5624 exec a:cmd
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5625 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5626
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5627 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5628 while 1 " dummy loop
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5629 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5630 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5631 call EXEC('echo novar') " normal error
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5632 catch /^Vim\((\a\+)\)\=:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5633 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5634 call assert_match('E121: Undefined variable: novar', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5635 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5636 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5637 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5638 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5639 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5640 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5641
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5642 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5643 let cmd = "let"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5644 while cmd != ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5645 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5646 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5647 call EXEC(cmd . ' novar #') " normal plus syntax error
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5648 catch /^Vim\((\a\+)\)\=:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5649 Xloop 'e'
25615
b0f82974ddf4 patch 8.2.3344: vimscript test fails
Bram Moolenaar <Bram@vim.org>
parents: 24958
diff changeset
5650 if cmd =~ 'unlet'
b0f82974ddf4 patch 8.2.3344: vimscript test fails
Bram Moolenaar <Bram@vim.org>
parents: 24958
diff changeset
5651 " TODO: should get error for 'novar'
b0f82974ddf4 patch 8.2.3344: vimscript test fails
Bram Moolenaar <Bram@vim.org>
parents: 24958
diff changeset
5652 call assert_match('E488: Trailing characters', v:exception)
b0f82974ddf4 patch 8.2.3344: vimscript test fails
Bram Moolenaar <Bram@vim.org>
parents: 24958
diff changeset
5653 else
b0f82974ddf4 patch 8.2.3344: vimscript test fails
Bram Moolenaar <Bram@vim.org>
parents: 24958
diff changeset
5654 call assert_match('E121: Undefined variable: novar', v:exception)
b0f82974ddf4 patch 8.2.3344: vimscript test fails
Bram Moolenaar <Bram@vim.org>
parents: 24958
diff changeset
5655 endif
21735
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5656 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5657 Xloop 'f'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5658 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5659 if cmd == "let"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5660 let cmd = "unlet"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5661 else
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5662 let cmd = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5663 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5664 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5665 continue
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5666 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5667 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5668
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5669 Xpath 'g'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5670 let cmd = "let"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5671 while cmd != ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5672 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5673 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5674 call EXEC(cmd . ' {novar}') " normal plus syntax error
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5675 catch /^Vim\((\a\+)\)\=:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5676 Xloop 'h'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5677 call assert_match('E475: Invalid argument: {novar}', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5678 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5679 Xloop 'i'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5680 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5681 if cmd == "let"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5682 let cmd = "unlet"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5683 else
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5684 let cmd = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5685 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5686 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5687 continue
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5688 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5689 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5690 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5691 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5692 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5693 Xpath 'j'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5694 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5695 let verify =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5696 call assert_equal('bcde1f1e2f2gh3i3h4i4j', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5697 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5698 call RunInNewVim(test, verify)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5699 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5700
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5701 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5702 " Test 80: Syntax error in expression for illegal :elseif {{{1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5703 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5704 " If there is a syntax error in the expression after an illegal
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5705 " :elseif, an error message is given (or an error exception thrown)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5706 " for the illegal :elseif rather than the expression error.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5707 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5708 func Test_if_syntax_error()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5709 CheckEnglish
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5710
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5711 let test =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5712 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5713 if 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5714 else
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5715 elseif 1 ||| 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5716 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5717 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5718 call assert_match('E584: :elseif after :else', v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5719
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5720 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5721 if 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5722 else
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5723 elseif 1 ||| 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5724 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5725 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5726 call assert_match('E584: :elseif after :else', v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5727
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5728 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5729 elseif 1 ||| 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5730 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5731 call assert_match('E582: :elseif without :if', v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5732
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5733 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5734 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5735 elseif 1 ||| 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5736 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5737 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5738 call assert_match('E582: :elseif without :if', v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5739
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5740 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5741 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5742 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5743 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5744 if 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5745 else
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5746 elseif 1 ||| 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5747 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5748 catch /^Vim\((\a\+)\)\=:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5749 Xpath 'e'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5750 call assert_match('E584: :elseif after :else', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5751 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5752 Xpath 'f'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5753 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5754 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5755 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5756 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5757 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5758 Xpath 'g'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5759 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5760 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5761 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5762
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5763 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5764 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5765 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5766 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5767 if 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5768 else
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5769 elseif 1 ||| 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5770 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5771 catch /^Vim\((\a\+)\)\=:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5772 Xpath 'h'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5773 call assert_match('E584: :elseif after :else', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5774 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5775 Xpath 'i'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5776 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5777 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5778 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5779 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5780 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5781 Xpath 'j'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5782 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5783 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5784 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5785
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5786 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5787 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5788 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5789 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5790 elseif 1 ||| 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5791 catch /^Vim\((\a\+)\)\=:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5792 Xpath 'k'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5793 call assert_match('E582: :elseif without :if', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5794 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5795 Xpath 'l'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5796 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5797 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5798 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5799 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5800 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5801 Xpath 'm'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5802 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5803 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5804 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5805
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5806 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5807 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5808 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5809 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5810 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5811 elseif 1 ||| 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5812 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5813 catch /^Vim\((\a\+)\)\=:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5814 Xpath 'n'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5815 call assert_match('E582: :elseif without :if', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5816 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5817 Xpath 'o'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5818 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5819 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5820 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5821 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5822 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5823 Xpath 'p'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5824 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5825 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5826 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5827 Xpath 'q'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5828 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5829 let verify =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5830 call assert_equal('abcdefghijklmnopq', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5831 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5832 call RunInNewVim(test, verify)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5833 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5834
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5835 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5836 " Test 81: Discarding exceptions after an error or interrupt {{{1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5837 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5838 " When an exception is thrown from inside a :try conditional without
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5839 " :catch and :finally clauses and an error or interrupt occurs before
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5840 " the :endtry is reached, the exception is discarded.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5841 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5842
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5843 func Test_discard_exception_after_error_1()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5844 let test =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5845 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5846 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5847 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5848 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5849 throw "arrgh"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5850 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5851 if 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5852 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5853 " error after :throw: missing :endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5854 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5855 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5856 catch /arrgh/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5857 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5858 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5859 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5860 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5861 let verify =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5862 call assert_equal('ab', g:Xpath)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5863 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5864 call RunInNewVim(test, verify)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5865 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5866
21781
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5867 " interrupt the code before the endtry is invoked
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5868 func Test_discard_exception_after_error_2()
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5869 XpathINIT
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5870 let lines =<< trim [CODE]
21735
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5871 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5872 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5873 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5874 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5875 throw "arrgh"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5876 call assert_report('should not get here')
21781
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5877 endtry " interrupt here
21735
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5878 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5879 catch /arrgh/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5880 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5881 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5882 call assert_report('should not get here')
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5883 [CODE]
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
5884 call writefile(lines, 'Xscript', 'D')
21781
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5885
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5886 breakadd file 7 Xscript
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5887 try
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5888 let caught_intr = 0
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5889 debuggreedy
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5890 call feedkeys(":source Xscript\<CR>quit\<CR>", "xt")
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5891 catch /^Vim:Interrupt$/
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5892 call assert_match('Xscript, line 7', v:throwpoint)
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5893 let caught_intr = 1
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5894 endtry
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5895 0debuggreedy
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5896 call assert_equal(1, caught_intr)
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5897 call assert_equal('ab', g:Xpath)
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5898 breakdel *
21735
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5899 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5900
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5901 "-------------------------------------------------------------------------------
21741
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5902 " Test 82: Ignoring :catch clauses after an error or interrupt {{{1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5903 "
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5904 " When an exception is thrown and an error or interrupt occurs before
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5905 " the matching :catch clause is reached, the exception is discarded
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5906 " and the :catch clause is ignored (also for the error or interrupt
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5907 " exception being thrown then).
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5908 "-------------------------------------------------------------------------------
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5909
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5910 func Test_ignore_catch_after_error_1()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5911 let test =<< trim [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5912 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5913 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5914 Xpath 'a'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5915 throw "arrgh"
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5916 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5917 if 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5918 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5919 " error after :throw: missing :endif
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5920 catch /.*/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5921 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5922 catch /.*/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5923 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5924 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5925 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5926 catch /arrgh/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5927 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5928 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5929 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5930 [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5931 let verify =<< trim [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5932 call assert_equal('a', g:Xpath)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5933 [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5934 call RunInNewVim(test, verify)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5935 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5936
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5937 func Test_ignore_catch_after_error_2()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5938 let test =<< trim [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5939 func E()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5940 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5941 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5942 Xpath 'a'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5943 throw "arrgh"
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5944 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5945 if 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5946 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5947 " error after :throw: missing :endif
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5948 catch /.*/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5949 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5950 catch /.*/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5951 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5952 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5953 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5954 catch /arrgh/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5955 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5956 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5957 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5958
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5959 call E()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5960 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5961 [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5962 let verify =<< trim [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5963 call assert_equal('a', g:Xpath)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5964 [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5965 call RunInNewVim(test, verify)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5966 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5967
21781
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5968 " interrupt right before a catch is invoked in a script
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5969 func Test_ignore_catch_after_intr_1()
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5970 XpathINIT
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5971 let lines =<< trim [CODE]
21741
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5972 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5973 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5974 Xpath 'a'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5975 throw "arrgh"
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5976 call assert_report('should not get here')
21781
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5977 catch /.*/ " interrupt here
21741
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5978 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5979 catch /.*/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5980 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5981 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5982 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5983 catch /arrgh/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5984 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5985 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5986 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5987 [CODE]
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
5988 call writefile(lines, 'Xscript', 'D')
21781
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5989
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5990 breakadd file 6 Xscript
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5991 try
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5992 let caught_intr = 0
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5993 debuggreedy
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5994 call feedkeys(":source Xscript\<CR>quit\<CR>", "xt")
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5995 catch /^Vim:Interrupt$/
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5996 call assert_match('Xscript, line 6', v:throwpoint)
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5997 let caught_intr = 1
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5998 endtry
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5999 0debuggreedy
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6000 call assert_equal(1, caught_intr)
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6001 call assert_equal('a', g:Xpath)
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6002 breakdel *
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6003 endfunc
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6004
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6005 " interrupt right before a catch is invoked inside a function.
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6006 func Test_ignore_catch_after_intr_2()
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6007 XpathINIT
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6008 func F()
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6009 try
21741
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6010 try
21781
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6011 Xpath 'a'
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6012 throw "arrgh"
21741
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6013 call assert_report('should not get here')
21781
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6014 catch /.*/ " interrupt here
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6015 call assert_report('should not get here')
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6016 catch /.*/
21741
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6017 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6018 endtry
21781
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6019 call assert_report('should not get here')
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6020 catch /arrgh/
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6021 call assert_report('should not get here')
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6022 endtry
21741
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6023 call assert_report('should not get here')
21781
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6024 endfunc
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6025
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6026 breakadd func 6 F
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6027 try
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6028 let caught_intr = 0
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6029 debuggreedy
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6030 call feedkeys(":call F()\<CR>quit\<CR>", "xt")
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6031 catch /^Vim:Interrupt$/
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6032 call assert_match('\.F, line 6', v:throwpoint)
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6033 let caught_intr = 1
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6034 endtry
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6035 0debuggreedy
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6036 call assert_equal(1, caught_intr)
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6037 call assert_equal('a', g:Xpath)
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6038 breakdel *
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6039 delfunc F
21741
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6040 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6041
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6042 "-------------------------------------------------------------------------------
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6043 " Test 83: Executing :finally clauses after an error or interrupt {{{1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6044 "
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6045 " When an exception is thrown and an error or interrupt occurs before
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6046 " the :finally of the innermost :try is reached, the exception is
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6047 " discarded and the :finally clause is executed.
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6048 "-------------------------------------------------------------------------------
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6049
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6050 func Test_finally_after_error()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6051 let test =<< trim [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6052 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6053 Xpath 'a'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6054 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6055 Xpath 'b'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6056 throw "arrgh"
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6057 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6058 if 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6059 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6060 " error after :throw: missing :endif
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6061 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6062 Xpath 'c'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6063 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6064 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6065 catch /arrgh/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6066 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6067 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6068 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6069 [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6070 let verify =<< trim [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6071 call assert_equal('abc', g:Xpath)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6072 [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6073 call RunInNewVim(test, verify)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6074 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6075
21781
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6076 " interrupt the code right before the finally is invoked
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6077 func Test_finally_after_intr()
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6078 XpathINIT
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6079 let lines =<< trim [CODE]
21741
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6080 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6081 Xpath 'a'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6082 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6083 Xpath 'b'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6084 throw "arrgh"
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6085 call assert_report('should not get here')
21781
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6086 finally " interrupt here
21741
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6087 Xpath 'c'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6088 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6089 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6090 catch /arrgh/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6091 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6092 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6093 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6094 [CODE]
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
6095 call writefile(lines, 'Xscript', 'D')
21781
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6096
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6097 breakadd file 7 Xscript
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6098 try
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6099 let caught_intr = 0
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6100 debuggreedy
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6101 call feedkeys(":source Xscript\<CR>quit\<CR>", "xt")
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6102 catch /^Vim:Interrupt$/
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6103 call assert_match('Xscript, line 7', v:throwpoint)
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6104 let caught_intr = 1
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6105 endtry
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6106 0debuggreedy
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6107 call assert_equal(1, caught_intr)
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6108 call assert_equal('abc', g:Xpath)
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6109 breakdel *
21741
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6110 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6111
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6112 "-------------------------------------------------------------------------------
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6113 " Test 84: Exceptions in autocommand sequences. {{{1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6114 "
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6115 " When an exception occurs in a sequence of autocommands for
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6116 " a specific event, the rest of the sequence is not executed. The
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6117 " command that triggered the autocommand execution aborts, and the
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6118 " exception is propagated to the caller.
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6119 "
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6120 " For the FuncUndefined event under a function call expression or
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6121 " :call command, the function is not executed, even when it has
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6122 " been defined by the autocommands before the exception occurred.
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6123 "-------------------------------------------------------------------------------
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6124
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6125 func Test_autocmd_exception()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6126 let test =<< trim [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6127 func INT()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6128 call interrupt()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6129 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6130
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6131 aug TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6132 autocmd!
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6133
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6134 autocmd User x1 Xpath 'a'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6135 autocmd User x1 throw "x1"
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6136 autocmd User x1 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6137
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6138 autocmd User x2 Xpath 'b'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6139 autocmd User x2 asdf
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6140 autocmd User x2 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6141
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6142 autocmd User x3 Xpath 'c'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6143 autocmd User x3 call INT()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6144 autocmd User x3 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6145
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6146 autocmd FuncUndefined U1 func U1()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6147 autocmd FuncUndefined U1 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6148 autocmd FuncUndefined U1 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6149 autocmd FuncUndefined U1 Xpath 'd'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6150 autocmd FuncUndefined U1 throw "U1"
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6151 autocmd FuncUndefined U1 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6152
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6153 autocmd FuncUndefined U2 func U2()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6154 autocmd FuncUndefined U2 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6155 autocmd FuncUndefined U2 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6156 autocmd FuncUndefined U2 Xpath 'e'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6157 autocmd FuncUndefined U2 ASDF
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6158 autocmd FuncUndefined U2 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6159
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6160 autocmd FuncUndefined U3 func U3()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6161 autocmd FuncUndefined U3 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6162 autocmd FuncUndefined U3 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6163 autocmd FuncUndefined U3 Xpath 'f'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6164 autocmd FuncUndefined U3 call INT()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6165 autocmd FuncUndefined U3 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6166 aug END
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6167
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6168 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6169 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6170 Xpath 'g'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6171 doautocmd User x1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6172 catch /x1/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6173 Xpath 'h'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6174 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6175
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6176 while 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6177 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6178 Xpath 'i'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6179 doautocmd User x2
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6180 catch /asdf/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6181 Xpath 'j'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6182 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6183 Xpath 'k'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6184 break
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6185 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6186 endwhile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6187
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6188 while 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6189 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6190 Xpath 'l'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6191 doautocmd User x3
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6192 catch /Vim:Interrupt/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6193 Xpath 'm'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6194 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6195 Xpath 'n'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6196 " ... but break loop for caught interrupt exception,
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6197 " or discard interrupt and break loop if $VIMNOINTTHROW
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6198 break
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6199 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6200 endwhile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6201
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6202 if exists("*U1") | delfunction U1 | endif
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6203 if exists("*U2") | delfunction U2 | endif
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6204 if exists("*U3") | delfunction U3 | endif
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6205
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6206 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6207 Xpath 'o'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6208 call U1()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6209 catch /U1/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6210 Xpath 'p'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6211 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6212
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6213 while 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6214 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6215 Xpath 'q'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6216 call U2()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6217 catch /ASDF/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6218 Xpath 'r'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6219 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6220 Xpath 's'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6221 " ... but break loop for caught error exception,
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6222 " or discard error and break loop if $VIMNOERRTHROW
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6223 break
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6224 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6225 endwhile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6226
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6227 while 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6228 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6229 Xpath 't'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6230 call U3()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6231 catch /Vim:Interrupt/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6232 Xpath 'u'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6233 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6234 Xpath 'v'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6235 " ... but break loop for caught interrupt exception,
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6236 " or discard interrupt and break loop if $VIMNOINTTHROW
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6237 break
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6238 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6239 endwhile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6240 catch /.*/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6241 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6242 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6243 Xpath 'w'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6244 [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6245 let verify =<< trim [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6246 call assert_equal('gahibjklcmnodpqerstfuvw', g:Xpath)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6247 [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6248 call RunInNewVim(test, verify)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6249 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6250
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6251 "-------------------------------------------------------------------------------
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6252 " Test 85: Error exceptions in autocommands for I/O command events {{{1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6253 "
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6254 " When an I/O command is inside :try/:endtry, autocommands to be
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6255 " executed after it should be skipped on an error (exception) in the
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6256 " command itself or in autocommands to be executed before the command.
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6257 " In the latter case, the I/O command should not be executed either.
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6258 " Example 1: BufWritePre, :write, BufWritePost
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6259 " Example 2: FileReadPre, :read, FileReadPost.
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6260 "-------------------------------------------------------------------------------
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6261
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6262 func Test_autocmd_error_io_exception()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6263 let test =<< trim [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6264 " Remove the autocommands for the events specified as arguments in all used
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6265 " autogroups.
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6266 func Delete_autocommands(...)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6267 let augfile = tempname()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6268 while 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6269 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6270 exec "redir >" . augfile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6271 aug
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6272 redir END
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6273 exec "edit" augfile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6274 g/^$/d
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6275 norm G$
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6276 let wrap = "w"
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6277 while search('\%( \|^\)\@<=.\{-}\%( \)\@=', wrap) > 0
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6278 let wrap = "W"
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6279 exec "norm y/ \n"
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6280 let argno = 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6281 while argno <= a:0
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6282 exec "au!" escape(@", " ") a:{argno}
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6283 let argno = argno + 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6284 endwhile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6285 endwhile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6286 catch /.*/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6287 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6288 bwipeout!
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6289 call delete(augfile)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6290 break
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6291 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6292 endwhile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6293 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6294
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6295 call Delete_autocommands("BufWritePre", "BufWritePost")
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6296
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6297 while 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6298 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6299 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6300 let post = 0
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6301 aug TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6302 au! BufWritePost * let post = 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6303 aug END
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6304 write /n/o/n/e/x/i/s/t/e/n/t
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6305 catch /^Vim(write):/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6306 Xpath 'a'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6307 call assert_match("E212: Can't open file for writing", v:exception)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6308 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6309 Xpath 'b'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6310 call assert_equal(0, post)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6311 au! TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6312 aug! TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6313 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6314 catch /.*/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6315 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6316 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6317 Xpath 'c'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6318 break
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6319 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6320 endwhile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6321
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6322 while 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6323 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6324 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6325 let post = 0
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6326 aug TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6327 au! BufWritePre * asdf
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6328 au! BufWritePost * let post = 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6329 aug END
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6330 let tmpfile = tempname()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6331 exec "write" tmpfile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6332 catch /^Vim\((write)\)\=:/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6333 Xpath 'd'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6334 call assert_match('E492: Not an editor command', v:exception)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6335 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6336 Xpath 'e'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6337 if filereadable(tmpfile)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6338 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6339 endif
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6340 call assert_equal(0, post)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6341 au! TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6342 aug! TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6343 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6344 catch /.*/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6345 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6346 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6347 Xpath 'f'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6348 break
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6349 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6350 endwhile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6351
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6352 call delete(tmpfile)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6353
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6354 call Delete_autocommands("BufWritePre", "BufWritePost",
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6355 \ "BufReadPre", "BufReadPost", "FileReadPre", "FileReadPost")
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6356
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6357 while 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6358 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6359 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6360 let post = 0
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6361 aug TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6362 au! FileReadPost * let post = 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6363 aug END
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6364 let caught = 0
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6365 read /n/o/n/e/x/i/s/t/e/n/t
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6366 catch /^Vim(read):/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6367 Xpath 'g'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6368 call assert_match("E484: Can't open file", v:exception)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6369 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6370 Xpath 'h'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6371 call assert_equal(0, post)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6372 au! TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6373 aug! TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6374 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6375 catch /.*/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6376 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6377 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6378 Xpath 'i'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6379 break
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6380 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6381 endwhile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6382
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6383 while 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6384 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6385 let infile = tempname()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6386 let tmpfile = tempname()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6387 call writefile(["XYZ"], infile)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6388 exec "edit" tmpfile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6389 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6390 Xpath 'j'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6391 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6392 let post = 0
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6393 aug TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6394 au! FileReadPre * asdf
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6395 au! FileReadPost * let post = 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6396 aug END
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6397 exec "0read" infile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6398 catch /^Vim\((read)\)\=:/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6399 Xpath 'k'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6400 call assert_match('E492: Not an editor command', v:exception)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6401 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6402 Xpath 'l'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6403 if getline("1") == "XYZ"
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6404 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6405 endif
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6406 call assert_equal(0, post)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6407 au! TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6408 aug! TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6409 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6410 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6411 Xpath 'm'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6412 bwipeout!
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6413 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6414 catch /.*/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6415 call assert_report('should not get here')
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6416 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6417 Xpath 'n'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6418 break
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6419 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6420 endwhile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6421
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6422 call delete(infile)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6423 call delete(tmpfile)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6424 [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6425 let verify =<< trim [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6426 call assert_equal('abcdefghijklmn', g:Xpath)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6427 [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6428 call RunInNewVim(test, verify)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6429 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6430
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6431 "-------------------------------------------------------------------------------
18504
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6432 " Test 87 using (expr) ? funcref : funcref {{{1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6433 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6434 " Vim needs to correctly parse the funcref and even when it does
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6435 " not execute the funcref, it needs to consume the trailing ()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6436 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6437
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6438 func Add2(x1, x2)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6439 return a:x1 + a:x2
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6440 endfu
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6441
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6442 func GetStr()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6443 return "abcdefghijklmnopqrstuvwxyp"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6444 endfu
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6445
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6446 func Test_funcref_with_condexpr()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6447 call assert_equal(5, function('Add2')(2,3))
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6448
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6449 call assert_equal(3, 1 ? function('Add2')(1,2) : function('Add2')(2,3))
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6450 call assert_equal(5, 0 ? function('Add2')(1,2) : function('Add2')(2,3))
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6451 " Make sure, GetStr() still works.
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6452 call assert_equal('abcdefghijk', GetStr()[0:10])
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6453 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6454
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6455 " Test 90: Recognizing {} in variable name. {{{1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6456 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6457
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6458 func Test_curlies()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6459 let s:var = 66
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6460 let ns = 's'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6461 call assert_equal(66, {ns}:var)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6462
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6463 let g:a = {}
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6464 let g:b = 't'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6465 let g:a[g:b] = 77
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6466 call assert_equal(77, g:a['t'])
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6467 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6468
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6469 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6470 " Test 91: using type(). {{{1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6471 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6472
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6473 func Test_type()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6474 call assert_equal(0, type(0))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6475 call assert_equal(1, type(""))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6476 call assert_equal(2, type(function("tr")))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6477 call assert_equal(2, type(function("tr", [8])))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6478 call assert_equal(3, type([]))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6479 call assert_equal(4, type({}))
30310
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
6480 call assert_equal(5, type(0.0))
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6481 call assert_equal(6, type(v:false))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6482 call assert_equal(6, type(v:true))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6483 call assert_equal(7, type(v:none))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6484 call assert_equal(7, type(v:null))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6485 call assert_equal(8, v:t_job)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6486 call assert_equal(9, v:t_channel)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6487 call assert_equal(v:t_number, type(0))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6488 call assert_equal(v:t_string, type(""))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6489 call assert_equal(v:t_func, type(function("tr")))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6490 call assert_equal(v:t_func, type(function("tr", [8])))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6491 call assert_equal(v:t_list, type([]))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6492 call assert_equal(v:t_dict, type({}))
30310
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
6493 call assert_equal(v:t_float, type(0.0))
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6494 call assert_equal(v:t_bool, type(v:false))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6495 call assert_equal(v:t_bool, type(v:true))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6496 call assert_equal(v:t_none, type(v:none))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6497 call assert_equal(v:t_none, type(v:null))
20158
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
6498 call assert_equal(v:t_string, type(test_null_string()))
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
6499 call assert_equal(v:t_func, type(test_null_function()))
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
6500 call assert_equal(v:t_func, type(test_null_partial()))
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
6501 call assert_equal(v:t_list, type(test_null_list()))
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
6502 call assert_equal(v:t_dict, type(test_null_dict()))
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
6503 if has('job')
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
6504 call assert_equal(v:t_job, type(test_null_job()))
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
6505 endif
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
6506 if has('channel')
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
6507 call assert_equal(v:t_channel, type(test_null_channel()))
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
6508 endif
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
6509 call assert_equal(v:t_blob, type(test_null_blob()))
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6510
19548
9a9ca0e622c8 patch 8.2.0331: internal error when using test_void() and test_unknown()
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
6511 call assert_fails("call type(test_void())", 'E685:')
9a9ca0e622c8 patch 8.2.0331: internal error when using test_void() and test_unknown()
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
6512 call assert_fails("call type(test_unknown())", 'E685:')
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6513
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6514 call assert_equal(0, 0 + v:false)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6515 call assert_equal(1, 0 + v:true)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6516 call assert_equal(0, 0 + v:none)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6517 call assert_equal(0, 0 + v:null)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6518
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6519 call assert_equal('v:false', '' . v:false)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6520 call assert_equal('v:true', '' . v:true)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6521 call assert_equal('v:none', '' . v:none)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6522 call assert_equal('v:null', '' . v:null)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6523
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6524 call assert_true(v:false == 0)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6525 call assert_false(v:false != 0)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6526 call assert_true(v:true == 1)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6527 call assert_false(v:true != 1)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6528 call assert_false(v:true == v:false)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6529 call assert_true(v:true != v:false)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6530
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6531 call assert_true(v:null == 0)
27928
ca7a207d83cd patch 8.2.4489: failing test for comparing v:null with number
Bram Moolenaar <Bram@vim.org>
parents: 27901
diff changeset
6532 call assert_false(v:null == 1)
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6533 call assert_false(v:null != 0)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6534 call assert_true(v:none == 0)
27928
ca7a207d83cd patch 8.2.4489: failing test for comparing v:null with number
Bram Moolenaar <Bram@vim.org>
parents: 27901
diff changeset
6535 call assert_false(v:none == 1)
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6536 call assert_false(v:none != 0)
30310
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
6537 call assert_true(v:null == 0.0)
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
6538 call assert_false(v:null == 0.1)
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
6539 call assert_false(v:null != 0.0)
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6540
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6541 call assert_true(v:false is v:false)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6542 call assert_true(v:true is v:true)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6543 call assert_true(v:none is v:none)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6544 call assert_true(v:null is v:null)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6545
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6546 call assert_false(v:false isnot v:false)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6547 call assert_false(v:true isnot v:true)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6548 call assert_false(v:none isnot v:none)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6549 call assert_false(v:null isnot v:null)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6550
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6551 call assert_false(v:false is 0)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6552 call assert_false(v:true is 1)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6553 call assert_false(v:true is v:false)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6554 call assert_false(v:none is 0)
28008
cc7d54a134e4 patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents: 27928
diff changeset
6555 call assert_false(v:none is [])
cc7d54a134e4 patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents: 27928
diff changeset
6556 call assert_false(v:none is {})
cc7d54a134e4 patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents: 27928
diff changeset
6557 call assert_false(v:none is 'text')
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6558 call assert_false(v:null is 0)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6559 call assert_false(v:null is v:none)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6560
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6561 call assert_true(v:false isnot 0)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6562 call assert_true(v:true isnot 1)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6563 call assert_true(v:true isnot v:false)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6564 call assert_true(v:none isnot 0)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6565 call assert_true(v:null isnot 0)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6566 call assert_true(v:null isnot v:none)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6567
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6568 call assert_equal(v:false, eval(string(v:false)))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6569 call assert_equal(v:true, eval(string(v:true)))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6570 call assert_equal(v:none, eval(string(v:none)))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6571 call assert_equal(v:null, eval(string(v:null)))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6572
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6573 call assert_equal(v:false, copy(v:false))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6574 call assert_equal(v:true, copy(v:true))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6575 call assert_equal(v:none, copy(v:none))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6576 call assert_equal(v:null, copy(v:null))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6577
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6578 call assert_equal([v:false], deepcopy([v:false]))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6579 call assert_equal([v:true], deepcopy([v:true]))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6580 call assert_equal([v:none], deepcopy([v:none]))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6581 call assert_equal([v:null], deepcopy([v:null]))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6582
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6583 call assert_true(empty(v:false))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6584 call assert_false(empty(v:true))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6585 call assert_true(empty(v:null))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6586 call assert_true(empty(v:none))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6587
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6588 func ChangeYourMind()
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6589 try
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6590 return v:true
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6591 finally
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6592 return 'something else'
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6593 endtry
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6594 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6595
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6596 call ChangeYourMind()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6597 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6598
23594
d3e064f54890 patch 8.2.2339: cannot get the type of a value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23229
diff changeset
6599 func Test_typename()
d3e064f54890 patch 8.2.2339: cannot get the type of a value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23229
diff changeset
6600 call assert_equal('number', typename(123))
d3e064f54890 patch 8.2.2339: cannot get the type of a value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23229
diff changeset
6601 call assert_equal('string', typename('x'))
d3e064f54890 patch 8.2.2339: cannot get the type of a value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23229
diff changeset
6602 call assert_equal('list<number>', typename([123]))
d3e064f54890 patch 8.2.2339: cannot get the type of a value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23229
diff changeset
6603 call assert_equal('dict<number>', typename(#{key: 123}))
d3e064f54890 patch 8.2.2339: cannot get the type of a value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23229
diff changeset
6604 call assert_equal('list<dict<number>>', typename([#{key: 123}]))
24160
e695db9a5465 patch 8.2.2621: typval2type() cannot handle recursive structures
Bram Moolenaar <Bram@vim.org>
parents: 23594
diff changeset
6605
e695db9a5465 patch 8.2.2621: typval2type() cannot handle recursive structures
Bram Moolenaar <Bram@vim.org>
parents: 23594
diff changeset
6606 let l = []
e695db9a5465 patch 8.2.2621: typval2type() cannot handle recursive structures
Bram Moolenaar <Bram@vim.org>
parents: 23594
diff changeset
6607 let d = #{a: 0}
e695db9a5465 patch 8.2.2621: typval2type() cannot handle recursive structures
Bram Moolenaar <Bram@vim.org>
parents: 23594
diff changeset
6608 let l = [d]
e695db9a5465 patch 8.2.2621: typval2type() cannot handle recursive structures
Bram Moolenaar <Bram@vim.org>
parents: 23594
diff changeset
6609 let l[0].e = #{b: l}
e695db9a5465 patch 8.2.2621: typval2type() cannot handle recursive structures
Bram Moolenaar <Bram@vim.org>
parents: 23594
diff changeset
6610 call assert_equal('list<dict<any>>', typename(l))
e695db9a5465 patch 8.2.2621: typval2type() cannot handle recursive structures
Bram Moolenaar <Bram@vim.org>
parents: 23594
diff changeset
6611 call assert_equal('dict<any>', typename(d))
23594
d3e064f54890 patch 8.2.2339: cannot get the type of a value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23229
diff changeset
6612 endfunc
d3e064f54890 patch 8.2.2339: cannot get the type of a value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23229
diff changeset
6613
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6614 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6615 " Test 92: skipping code {{{1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6616 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6617
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6618 func Test_skip()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6619 let Fn = function('Test_type')
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6620 call assert_false(0 && Fn[1])
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6621 call assert_false(0 && string(Fn))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6622 call assert_false(0 && len(Fn))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6623 let l = []
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6624 call assert_false(0 && l[1])
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6625 call assert_false(0 && string(l))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6626 call assert_false(0 && len(l))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6627 let f = 1.0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6628 call assert_false(0 && f[1])
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6629 call assert_false(0 && string(f))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6630 call assert_false(0 && len(f))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6631 let sp = v:null
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6632 call assert_false(0 && sp[1])
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6633 call assert_false(0 && string(sp))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6634 call assert_false(0 && len(sp))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6635
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6636 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6637
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6638 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6639 " Test 93: :echo and string() {{{1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6640 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6641
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6642 func Test_echo_and_string()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6643 " String
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6644 let a = 'foo bar'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6645 redir => result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6646 echo a
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6647 echo string(a)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6648 redir END
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6649 let l = split(result, "\n")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6650 call assert_equal(["foo bar",
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6651 \ "'foo bar'"], l)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6652
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6653 " Float
30310
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
6654 let a = -1.2e0
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
6655 redir => result
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
6656 echo a
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
6657 echo string(a)
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
6658 redir END
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
6659 let l = split(result, "\n")
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
6660 call assert_equal(["-1.2",
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
6661 \ "-1.2"], l)
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6662
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6663 " Funcref
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6664 redir => result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6665 echo function('string')
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6666 echo string(function('string'))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6667 redir END
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6668 let l = split(result, "\n")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6669 call assert_equal(["string",
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6670 \ "function('string')"], l)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6671
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6672 " Recursive dictionary
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6673 let a = {}
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6674 let a["a"] = a
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6675 redir => result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6676 echo a
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6677 echo string(a)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6678 redir END
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6679 let l = split(result, "\n")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6680 call assert_equal(["{'a': {...}}",
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6681 \ "{'a': {...}}"], l)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6682
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6683 " Recursive list
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6684 let a = [0]
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6685 let a[0] = a
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6686 redir => result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6687 echo a
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6688 echo string(a)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6689 redir END
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6690 let l = split(result, "\n")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6691 call assert_equal(["[[...]]",
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6692 \ "[[...]]"], l)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6693
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6694 " Empty dictionaries in a list
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6695 let a = {}
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6696 redir => result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6697 echo [a, a, a]
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6698 echo string([a, a, a])
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6699 redir END
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6700 let l = split(result, "\n")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6701 call assert_equal(["[{}, {}, {}]",
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6702 \ "[{}, {}, {}]"], l)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6703
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6704 " Empty dictionaries in a dictionary
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6705 let a = {}
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6706 let b = {"a": a, "b": a}
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6707 redir => result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6708 echo b
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6709 echo string(b)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6710 redir END
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6711 let l = split(result, "\n")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6712 call assert_equal(["{'a': {}, 'b': {}}",
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6713 \ "{'a': {}, 'b': {}}"], l)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6714
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6715 " Empty lists in a list
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6716 let a = []
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6717 redir => result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6718 echo [a, a, a]
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6719 echo string([a, a, a])
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6720 redir END
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6721 let l = split(result, "\n")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6722 call assert_equal(["[[], [], []]",
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6723 \ "[[], [], []]"], l)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6724
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6725 " Empty lists in a dictionary
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6726 let a = []
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6727 let b = {"a": a, "b": a}
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6728 redir => result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6729 echo b
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6730 echo string(b)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6731 redir END
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6732 let l = split(result, "\n")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6733 call assert_equal(["{'a': [], 'b': []}",
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6734 \ "{'a': [], 'b': []}"], l)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6735
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6736 " Dictionaries in a list
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6737 let a = {"one": "yes", "two": "yes", "three": "yes"}
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6738 redir => result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6739 echo [a, a, a]
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6740 echo string([a, a, a])
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6741 redir END
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6742 let l = split(result, "\n")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6743 call assert_equal(["[{'one': 'yes', 'two': 'yes', 'three': 'yes'}, {...}, {...}]",
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6744 \ "[{'one': 'yes', 'two': 'yes', 'three': 'yes'}, {'one': 'yes', 'two': 'yes', 'three': 'yes'}, {'one': 'yes', 'two': 'yes', 'three': 'yes'}]"], l)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6745
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6746 " Dictionaries in a dictionary
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6747 let a = {"one": "yes", "two": "yes", "three": "yes"}
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6748 let b = {"a": a, "b": a}
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6749 redir => result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6750 echo b
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6751 echo string(b)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6752 redir END
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6753 let l = split(result, "\n")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6754 call assert_equal(["{'a': {'one': 'yes', 'two': 'yes', 'three': 'yes'}, 'b': {...}}",
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6755 \ "{'a': {'one': 'yes', 'two': 'yes', 'three': 'yes'}, 'b': {'one': 'yes', 'two': 'yes', 'three': 'yes'}}"], l)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6756
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6757 " Lists in a list
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6758 let a = [1, 2, 3]
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6759 redir => result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6760 echo [a, a, a]
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6761 echo string([a, a, a])
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6762 redir END
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6763 let l = split(result, "\n")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6764 call assert_equal(["[[1, 2, 3], [...], [...]]",
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6765 \ "[[1, 2, 3], [1, 2, 3], [1, 2, 3]]"], l)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6766
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6767 " Lists in a dictionary
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6768 let a = [1, 2, 3]
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6769 let b = {"a": a, "b": a}
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6770 redir => result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6771 echo b
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6772 echo string(b)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6773 redir END
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6774 let l = split(result, "\n")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6775 call assert_equal(["{'a': [1, 2, 3], 'b': [...]}",
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6776 \ "{'a': [1, 2, 3], 'b': [1, 2, 3]}"], l)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6777
19991
f27473034f26 patch 8.2.0551: not all code for options is tested
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
6778 call assert_fails('echo &:', 'E112:')
f27473034f26 patch 8.2.0551: not all code for options is tested
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
6779 call assert_fails('echo &g:', 'E112:')
f27473034f26 patch 8.2.0551: not all code for options is tested
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
6780 call assert_fails('echo &l:', 'E112:')
f27473034f26 patch 8.2.0551: not all code for options is tested
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
6781
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6782 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6783
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6784 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6785 " Test 94: 64-bit Numbers {{{1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6786 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6787
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6788 func Test_num64()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6789 call assert_notequal( 4294967296, 0)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6790 call assert_notequal(-4294967296, 0)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6791 call assert_equal( 4294967296, 0xFFFFffff + 1)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6792 call assert_equal(-4294967296, -0xFFFFffff - 1)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6793
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6794 call assert_equal( 9223372036854775807, 1 / 0)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6795 call assert_equal(-9223372036854775807, -1 / 0)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6796 call assert_equal(-9223372036854775807 - 1, 0 / 0)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6797
30310
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
6798 call assert_equal( 0x7FFFffffFFFFffff, float2nr( 1.0e150))
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
6799 call assert_equal(-0x7FFFffffFFFFffff, float2nr(-1.0e150))
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6800
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6801 let rng = range(0xFFFFffff, 0x100000001)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6802 call assert_equal([0xFFFFffff, 0x100000000, 0x100000001], rng)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6803 call assert_equal(0x100000001, max(rng))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6804 call assert_equal(0xFFFFffff, min(rng))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6805 call assert_equal(rng, sort(range(0x100000001, 0xFFFFffff, -1), 'N'))
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6806 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6807
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6808 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6809 " Test 95: lines of :append, :change, :insert {{{1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6810 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6811
30687
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
6812 func DefineFunction(name, body)
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6813 let func = join(['function! ' . a:name . '()'] + a:body + ['endfunction'], "\n")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6814 exec func
30687
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
6815 endfunc
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6816
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6817 func Test_script_lines()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6818 " :append
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6819 try
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6820 call DefineFunction('T_Append', [
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6821 \ 'append',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6822 \ 'py <<EOS',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6823 \ '.',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6824 \ ])
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6825 catch
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6826 call assert_report("Can't define function")
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6827 endtry
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6828 try
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6829 call DefineFunction('T_Append', [
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6830 \ 'append',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6831 \ 'abc',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6832 \ ])
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6833 call assert_report("Shouldn't be able to define function")
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6834 catch
23191
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
6835 call assert_exception('Vim(function):E1145: Missing heredoc end marker: .')
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6836 endtry
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6837
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6838 " :change
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6839 try
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6840 call DefineFunction('T_Change', [
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6841 \ 'change',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6842 \ 'py <<EOS',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6843 \ '.',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6844 \ ])
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6845 catch
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6846 call assert_report("Can't define function")
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6847 endtry
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6848 try
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6849 call DefineFunction('T_Change', [
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6850 \ 'change',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6851 \ 'abc',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6852 \ ])
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6853 call assert_report("Shouldn't be able to define function")
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6854 catch
23191
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
6855 call assert_exception('Vim(function):E1145: Missing heredoc end marker: .')
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6856 endtry
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6857
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6858 " :insert
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6859 try
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6860 call DefineFunction('T_Insert', [
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6861 \ 'insert',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6862 \ 'py <<EOS',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6863 \ '.',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6864 \ ])
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6865 catch
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6866 call assert_report("Can't define function")
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6867 endtry
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6868 try
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6869 call DefineFunction('T_Insert', [
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6870 \ 'insert',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6871 \ 'abc',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6872 \ ])
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6873 call assert_report("Shouldn't be able to define function")
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6874 catch
23191
3e7723bab4e5 patch 8.2.2141: a user command with try/catch may not catch an expression error
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
6875 call assert_exception('Vim(function):E1145: Missing heredoc end marker: .')
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6876 endtry
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6877 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6878
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6879 "-------------------------------------------------------------------------------
11352
251f1833db7d patch 8.0.0561: undefined behavior when using backslash after empty line
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
6880 " Test 96: line continuation {{{1
251f1833db7d patch 8.0.0561: undefined behavior when using backslash after empty line
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
6881 "
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6882 " Undefined behavior was detected by ubsan with line continuation
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6883 " after an empty line.
11352
251f1833db7d patch 8.0.0561: undefined behavior when using backslash after empty line
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
6884 "-------------------------------------------------------------------------------
251f1833db7d patch 8.0.0561: undefined behavior when using backslash after empty line
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
6885 func Test_script_emty_line_continuation()
251f1833db7d patch 8.0.0561: undefined behavior when using backslash after empty line
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
6886
251f1833db7d patch 8.0.0561: undefined behavior when using backslash after empty line
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
6887 \
251f1833db7d patch 8.0.0561: undefined behavior when using backslash after empty line
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
6888 endfunc
251f1833db7d patch 8.0.0561: undefined behavior when using backslash after empty line
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
6889
251f1833db7d patch 8.0.0561: undefined behavior when using backslash after empty line
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
6890 "-------------------------------------------------------------------------------
11461
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6891 " Test 97: bitwise functions {{{1
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6892 "-------------------------------------------------------------------------------
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6893 func Test_bitwise_functions()
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6894 " and
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6895 call assert_equal(127, and(127, 127))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6896 call assert_equal(16, and(127, 16))
17783
45eca7143d7c patch 8.1.1888: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
6897 eval 127->and(16)->assert_equal(16)
11461
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6898 call assert_equal(0, and(127, 128))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6899 call assert_fails("call and([], 1)", 'E745:')
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6900 call assert_fails("call and({}, 1)", 'E728:')
30310
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
6901 call assert_fails("call and(1.0, 1)", 'E805:')
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
6902 call assert_fails("call and(1, 1.0)", 'E805:')
11461
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6903 call assert_fails("call and(1, [])", 'E745:')
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6904 call assert_fails("call and(1, {})", 'E728:')
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6905 " or
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6906 call assert_equal(23, or(16, 7))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6907 call assert_equal(15, or(8, 7))
17783
45eca7143d7c patch 8.1.1888: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
6908 eval 8->or(7)->assert_equal(15)
11461
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6909 call assert_equal(123, or(0, 123))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6910 call assert_fails("call or([], 1)", 'E745:')
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6911 call assert_fails("call or({}, 1)", 'E728:')
30310
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
6912 call assert_fails("call or(1.0, 1)", 'E805:')
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
6913 call assert_fails("call or(1, 1.0)", 'E805:')
11461
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6914 call assert_fails("call or(1, [])", 'E745:')
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6915 call assert_fails("call or(1, {})", 'E728:')
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6916 " xor
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6917 call assert_equal(0, xor(127, 127))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6918 call assert_equal(111, xor(127, 16))
17783
45eca7143d7c patch 8.1.1888: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
6919 eval 127->xor(16)->assert_equal(111)
11461
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6920 call assert_equal(255, xor(127, 128))
30310
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
6921 call assert_fails("call xor(1.0, 1)", 'E805:')
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
6922 call assert_fails("call xor(1, 1.0)", 'E805:')
11461
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6923 call assert_fails("call xor([], 1)", 'E745:')
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6924 call assert_fails("call xor({}, 1)", 'E728:')
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6925 call assert_fails("call xor(1, [])", 'E745:')
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6926 call assert_fails("call xor(1, {})", 'E728:')
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6927 " invert
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6928 call assert_equal(65408, and(invert(127), 65535))
17783
45eca7143d7c patch 8.1.1888: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17698
diff changeset
6929 eval 127->invert()->and(65535)->assert_equal(65408)
11461
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6930 call assert_equal(65519, and(invert(16), 65535))
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6931 call assert_equal(65407, and(invert(128), 65535))
30310
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
6932 call assert_fails("call invert(1.0)", 'E805:')
11461
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6933 call assert_fails("call invert([])", 'E745:')
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6934 call assert_fails("call invert({})", 'E728:')
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6935 endfunc
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6936
11547
3d03ed329a54 patch 8.0.0656: cannot use ! after some user commands
Christian Brabandt <cb@256bit.org>
parents: 11545
diff changeset
6937 " Test using bang after user command {{{1
3d03ed329a54 patch 8.0.0656: cannot use ! after some user commands
Christian Brabandt <cb@256bit.org>
parents: 11545
diff changeset
6938 func Test_user_command_with_bang()
3d03ed329a54 patch 8.0.0656: cannot use ! after some user commands
Christian Brabandt <cb@256bit.org>
parents: 11545
diff changeset
6939 command -bang Nieuw let nieuw = 1
3d03ed329a54 patch 8.0.0656: cannot use ! after some user commands
Christian Brabandt <cb@256bit.org>
parents: 11545
diff changeset
6940 Ni!
3d03ed329a54 patch 8.0.0656: cannot use ! after some user commands
Christian Brabandt <cb@256bit.org>
parents: 11545
diff changeset
6941 call assert_equal(1, nieuw)
3d03ed329a54 patch 8.0.0656: cannot use ! after some user commands
Christian Brabandt <cb@256bit.org>
parents: 11545
diff changeset
6942 unlet nieuw
3d03ed329a54 patch 8.0.0656: cannot use ! after some user commands
Christian Brabandt <cb@256bit.org>
parents: 11545
diff changeset
6943 delcommand Nieuw
3d03ed329a54 patch 8.0.0656: cannot use ! after some user commands
Christian Brabandt <cb@256bit.org>
parents: 11545
diff changeset
6944 endfunc
3d03ed329a54 patch 8.0.0656: cannot use ! after some user commands
Christian Brabandt <cb@256bit.org>
parents: 11545
diff changeset
6945
19035
b920ae62c7b1 patch 8.2.0078: expanding <sfile> works differently the second time
Bram Moolenaar <Bram@vim.org>
parents: 18556
diff changeset
6946 func Test_script_expand_sfile()
b920ae62c7b1 patch 8.2.0078: expanding <sfile> works differently the second time
Bram Moolenaar <Bram@vim.org>
parents: 18556
diff changeset
6947 let lines =<< trim END
b920ae62c7b1 patch 8.2.0078: expanding <sfile> works differently the second time
Bram Moolenaar <Bram@vim.org>
parents: 18556
diff changeset
6948 func s:snr()
b920ae62c7b1 patch 8.2.0078: expanding <sfile> works differently the second time
Bram Moolenaar <Bram@vim.org>
parents: 18556
diff changeset
6949 return expand('<sfile>')
b920ae62c7b1 patch 8.2.0078: expanding <sfile> works differently the second time
Bram Moolenaar <Bram@vim.org>
parents: 18556
diff changeset
6950 endfunc
b920ae62c7b1 patch 8.2.0078: expanding <sfile> works differently the second time
Bram Moolenaar <Bram@vim.org>
parents: 18556
diff changeset
6951 let g:result = s:snr()
b920ae62c7b1 patch 8.2.0078: expanding <sfile> works differently the second time
Bram Moolenaar <Bram@vim.org>
parents: 18556
diff changeset
6952 END
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
6953 call writefile(lines, 'Xexpand', 'D')
19035
b920ae62c7b1 patch 8.2.0078: expanding <sfile> works differently the second time
Bram Moolenaar <Bram@vim.org>
parents: 18556
diff changeset
6954 source Xexpand
b920ae62c7b1 patch 8.2.0078: expanding <sfile> works differently the second time
Bram Moolenaar <Bram@vim.org>
parents: 18556
diff changeset
6955 call assert_match('<SNR>\d\+_snr', g:result)
b920ae62c7b1 patch 8.2.0078: expanding <sfile> works differently the second time
Bram Moolenaar <Bram@vim.org>
parents: 18556
diff changeset
6956 source Xexpand
b920ae62c7b1 patch 8.2.0078: expanding <sfile> works differently the second time
Bram Moolenaar <Bram@vim.org>
parents: 18556
diff changeset
6957 call assert_match('<SNR>\d\+_snr', g:result)
b920ae62c7b1 patch 8.2.0078: expanding <sfile> works differently the second time
Bram Moolenaar <Bram@vim.org>
parents: 18556
diff changeset
6958
b920ae62c7b1 patch 8.2.0078: expanding <sfile> works differently the second time
Bram Moolenaar <Bram@vim.org>
parents: 18556
diff changeset
6959 unlet g:result
b920ae62c7b1 patch 8.2.0078: expanding <sfile> works differently the second time
Bram Moolenaar <Bram@vim.org>
parents: 18556
diff changeset
6960 endfunc
b920ae62c7b1 patch 8.2.0078: expanding <sfile> works differently the second time
Bram Moolenaar <Bram@vim.org>
parents: 18556
diff changeset
6961
15790
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6962 func Test_compound_assignment_operators()
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6963 " Test for number
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6964 let x = 1
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6965 let x += 10
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6966 call assert_equal(11, x)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6967 let x -= 5
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6968 call assert_equal(6, x)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6969 let x *= 4
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6970 call assert_equal(24, x)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6971 let x /= 3
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6972 call assert_equal(8, x)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6973 let x %= 3
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6974 call assert_equal(2, x)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6975 let x .= 'n'
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6976 call assert_equal('2n', x)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6977
15969
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
6978 " Test special cases: division or modulus with 0.
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
6979 let x = 1
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
6980 let x /= 0
19427
fdfe44ac6a1a patch 8.2.0271: the "num64" feature is available everywhere
Bram Moolenaar <Bram@vim.org>
parents: 19425
diff changeset
6981 call assert_equal(0x7FFFFFFFFFFFFFFF, x)
15969
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
6982
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
6983 let x = -1
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
6984 let x /= 0
19427
fdfe44ac6a1a patch 8.2.0271: the "num64" feature is available everywhere
Bram Moolenaar <Bram@vim.org>
parents: 19425
diff changeset
6985 call assert_equal(-0x7FFFFFFFFFFFFFFF, x)
15969
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
6986
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
6987 let x = 0
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
6988 let x /= 0
19427
fdfe44ac6a1a patch 8.2.0271: the "num64" feature is available everywhere
Bram Moolenaar <Bram@vim.org>
parents: 19425
diff changeset
6989 call assert_equal(-0x7FFFFFFFFFFFFFFF - 1, x)
15969
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
6990
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
6991 let x = 1
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
6992 let x %= 0
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
6993 call assert_equal(0, x)
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
6994
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
6995 let x = -1
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
6996 let x %= 0
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
6997 call assert_equal(0, x)
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
6998
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
6999 let x = 0
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
7000 let x %= 0
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
7001 call assert_equal(0, x)
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
7002
15790
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7003 " Test for string
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7004 let x = 'str'
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7005 let x .= 'ing'
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7006 call assert_equal('string', x)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7007 let x += 1
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7008 call assert_equal(1, x)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7009
30310
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7010 " Test for float
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7011 let x -= 1.5
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7012 call assert_equal(-0.5, x)
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7013 let x = 0.5
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7014 let x += 4.5
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7015 call assert_equal(5.0, x)
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7016 let x -= 1.5
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7017 call assert_equal(3.5, x)
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7018 let x *= 3.0
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7019 call assert_equal(10.5, x)
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7020 let x /= 2.5
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7021 call assert_equal(4.2, x)
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7022 call assert_fails('let x %= 0.5', 'E734:')
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7023 call assert_fails('let x .= "f"', 'E734:')
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7024 let x = !3.14
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7025 call assert_equal(0.0, x)
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7026
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7027 " integer and float operations
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7028 let x = 1
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7029 let x *= 2.1
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7030 call assert_equal(2.1, x)
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7031 let x = 1
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7032 let x /= 0.25
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7033 call assert_equal(4.0, x)
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7034 let x = 1
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7035 call assert_fails('let x %= 0.25', 'E734:')
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7036 let x = 1
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7037 call assert_fails('let x .= 0.25', 'E734:')
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7038 let x = 1.0
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7039 call assert_fails('let x += [1.1]', 'E734:')
15790
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7040
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7041 " Test for environment variable
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7042 let $FOO = 1
22087
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21925
diff changeset
7043 call assert_fails('let $FOO += 1', 'E734:')
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21925
diff changeset
7044 call assert_fails('let $FOO -= 1', 'E734:')
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21925
diff changeset
7045 call assert_fails('let $FOO *= 1', 'E734:')
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21925
diff changeset
7046 call assert_fails('let $FOO /= 1', 'E734:')
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21925
diff changeset
7047 call assert_fails('let $FOO %= 1', 'E734:')
15790
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7048 let $FOO .= 's'
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7049 call assert_equal('1s', $FOO)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7050 unlet $FOO
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7051
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7052 " Test for option variable (type: number)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7053 let &scrolljump = 1
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7054 let &scrolljump += 5
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7055 call assert_equal(6, &scrolljump)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7056 let &scrolljump -= 2
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7057 call assert_equal(4, &scrolljump)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7058 let &scrolljump *= 3
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7059 call assert_equal(12, &scrolljump)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7060 let &scrolljump /= 2
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7061 call assert_equal(6, &scrolljump)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7062 let &scrolljump %= 5
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7063 call assert_equal(1, &scrolljump)
22087
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21925
diff changeset
7064 call assert_fails('let &scrolljump .= "j"', 'E734:')
15790
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7065 set scrolljump&vim
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7066
24862
f1a390885192 patch 8.2.2969: subtracting from number option fails when result is zero
Bram Moolenaar <Bram@vim.org>
parents: 24234
diff changeset
7067 let &foldlevelstart = 2
f1a390885192 patch 8.2.2969: subtracting from number option fails when result is zero
Bram Moolenaar <Bram@vim.org>
parents: 24234
diff changeset
7068 let &foldlevelstart -= 1
f1a390885192 patch 8.2.2969: subtracting from number option fails when result is zero
Bram Moolenaar <Bram@vim.org>
parents: 24234
diff changeset
7069 call assert_equal(1, &foldlevelstart)
f1a390885192 patch 8.2.2969: subtracting from number option fails when result is zero
Bram Moolenaar <Bram@vim.org>
parents: 24234
diff changeset
7070 let &foldlevelstart -= 1
f1a390885192 patch 8.2.2969: subtracting from number option fails when result is zero
Bram Moolenaar <Bram@vim.org>
parents: 24234
diff changeset
7071 call assert_equal(0, &foldlevelstart)
f1a390885192 patch 8.2.2969: subtracting from number option fails when result is zero
Bram Moolenaar <Bram@vim.org>
parents: 24234
diff changeset
7072 let &foldlevelstart = 2
f1a390885192 patch 8.2.2969: subtracting from number option fails when result is zero
Bram Moolenaar <Bram@vim.org>
parents: 24234
diff changeset
7073 let &foldlevelstart -= 2
f1a390885192 patch 8.2.2969: subtracting from number option fails when result is zero
Bram Moolenaar <Bram@vim.org>
parents: 24234
diff changeset
7074 call assert_equal(0, &foldlevelstart)
f1a390885192 patch 8.2.2969: subtracting from number option fails when result is zero
Bram Moolenaar <Bram@vim.org>
parents: 24234
diff changeset
7075
15790
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7076 " Test for register
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7077 let @/ = 1
22087
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21925
diff changeset
7078 call assert_fails('let @/ += 1', 'E734:')
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21925
diff changeset
7079 call assert_fails('let @/ -= 1', 'E734:')
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21925
diff changeset
7080 call assert_fails('let @/ *= 1', 'E734:')
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21925
diff changeset
7081 call assert_fails('let @/ /= 1', 'E734:')
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21925
diff changeset
7082 call assert_fails('let @/ %= 1', 'E734:')
15790
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7083 let @/ .= 's'
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7084 call assert_equal('1s', @/)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7085 let @/ = ''
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7086 endfunc
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7087
20093
646c53fa5781 patch 8.2.0602: :unlet $VAR does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
7088 func Test_unlet_env()
646c53fa5781 patch 8.2.0602: :unlet $VAR does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
7089 let $TESTVAR = 'yes'
646c53fa5781 patch 8.2.0602: :unlet $VAR does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
7090 call assert_equal('yes', $TESTVAR)
22087
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21925
diff changeset
7091 call assert_fails('lockvar $TESTVAR', 'E940:')
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21925
diff changeset
7092 call assert_fails('unlockvar $TESTVAR', 'E940:')
20093
646c53fa5781 patch 8.2.0602: :unlet $VAR does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
7093 call assert_equal('yes', $TESTVAR)
646c53fa5781 patch 8.2.0602: :unlet $VAR does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
7094 if 0
646c53fa5781 patch 8.2.0602: :unlet $VAR does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
7095 unlet $TESTVAR
646c53fa5781 patch 8.2.0602: :unlet $VAR does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
7096 endif
646c53fa5781 patch 8.2.0602: :unlet $VAR does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
7097 call assert_equal('yes', $TESTVAR)
646c53fa5781 patch 8.2.0602: :unlet $VAR does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
7098 unlet $TESTVAR
646c53fa5781 patch 8.2.0602: :unlet $VAR does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
7099 call assert_equal('', $TESTVAR)
646c53fa5781 patch 8.2.0602: :unlet $VAR does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
7100 endfunc
646c53fa5781 patch 8.2.0602: :unlet $VAR does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
7101
16078
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7102 func Test_refcount()
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7103 " Immediate values
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7104 call assert_equal(-1, test_refcount(1))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7105 call assert_equal(-1, test_refcount('s'))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7106 call assert_equal(-1, test_refcount(v:true))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7107 call assert_equal(0, test_refcount([]))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7108 call assert_equal(0, test_refcount({}))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7109 call assert_equal(0, test_refcount(0zff))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7110 call assert_equal(0, test_refcount({-> line('.')}))
30310
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7111 call assert_equal(-1, test_refcount(0.1))
16078
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7112 if has('job')
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7113 call assert_equal(0, test_refcount(job_start([&shell, &shellcmdflag, 'echo .'])))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7114 endif
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7115
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7116 " No refcount types
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7117 let x = 1
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7118 call assert_equal(-1, test_refcount(x))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7119 let x = 's'
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7120 call assert_equal(-1, test_refcount(x))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7121 let x = v:true
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7122 call assert_equal(-1, test_refcount(x))
30310
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7123 let x = 0.1
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7124 call assert_equal(-1, test_refcount(x))
16078
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7125
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7126 " Check refcount
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7127 let x = []
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7128 call assert_equal(1, test_refcount(x))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7129
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7130 let x = {}
18031
8a2fb21c23c0 patch 8.1.2011: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
7131 call assert_equal(1, x->test_refcount())
16078
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7132
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7133 let x = 0zff
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7134 call assert_equal(1, test_refcount(x))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7135
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7136 let X = {-> line('.')}
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7137 call assert_equal(1, test_refcount(X))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7138 let Y = X
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7139 call assert_equal(2, test_refcount(X))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7140
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7141 if has('job')
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7142 let job = job_start([&shell, &shellcmdflag, 'echo .'])
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7143 call assert_equal(1, test_refcount(job))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7144 call assert_equal(1, test_refcount(job_getchannel(job)))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7145 call assert_equal(1, test_refcount(job))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7146 endif
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7147
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7148 " Function arguments, copying and unassigning
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7149 func ExprCheck(x, i)
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7150 let i = a:i + 1
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7151 call assert_equal(i, test_refcount(a:x))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7152 let Y = a:x
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7153 call assert_equal(i + 1, test_refcount(a:x))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7154 call assert_equal(test_refcount(a:x), test_refcount(Y))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7155 let Y = 0
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7156 call assert_equal(i, test_refcount(a:x))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7157 endfunc
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7158 call ExprCheck([], 0)
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7159 call ExprCheck({}, 0)
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7160 call ExprCheck(0zff, 0)
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7161 call ExprCheck({-> line('.')}, 0)
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7162 if has('job')
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7163 call ExprCheck(job, 1)
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7164 call ExprCheck(job_getchannel(job), 1)
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7165 call job_stop(job)
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7166 endif
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7167 delfunc ExprCheck
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7168
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7169 " Regarding function
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7170 func Func(x) abort
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7171 call assert_equal(2, test_refcount(function('Func')))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7172 call assert_equal(0, test_refcount(funcref('Func')))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7173 endfunc
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7174 call assert_equal(1, test_refcount(function('Func')))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7175 call assert_equal(0, test_refcount(function('Func', [1])))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7176 call assert_equal(0, test_refcount(funcref('Func')))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7177 call assert_equal(0, test_refcount(funcref('Func', [1])))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7178 let X = function('Func')
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7179 let Y = X
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7180 call assert_equal(1, test_refcount(X))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7181 let X = function('Func', [1])
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7182 let Y = X
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7183 call assert_equal(2, test_refcount(X))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7184 let X = funcref('Func')
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7185 let Y = X
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7186 call assert_equal(2, test_refcount(X))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7187 let X = funcref('Func', [1])
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7188 let Y = X
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7189 call assert_equal(2, test_refcount(X))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7190 unlet X
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7191 unlet Y
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7192 call Func(1)
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7193 delfunc Func
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7194
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7195 " Function with dict
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7196 func DictFunc() dict
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7197 call assert_equal(3, test_refcount(self))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7198 endfunc
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7199 let d = {'Func': function('DictFunc')}
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7200 call assert_equal(1, test_refcount(d))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7201 call assert_equal(0, test_refcount(d.Func))
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7202 call d.Func()
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7203 unlet d
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7204 delfunc DictFunc
30415
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
7205
30455
b4c9540577cf patch 9.0.0563: timer_info() test fails
Bram Moolenaar <Bram@vim.org>
parents: 30415
diff changeset
7206 if has('channel')
b4c9540577cf patch 9.0.0563: timer_info() test fails
Bram Moolenaar <Bram@vim.org>
parents: 30415
diff changeset
7207 call assert_equal(-1, test_refcount(test_null_job()))
b4c9540577cf patch 9.0.0563: timer_info() test fails
Bram Moolenaar <Bram@vim.org>
parents: 30415
diff changeset
7208 call assert_equal(-1, test_refcount(test_null_channel()))
b4c9540577cf patch 9.0.0563: timer_info() test fails
Bram Moolenaar <Bram@vim.org>
parents: 30415
diff changeset
7209 endif
30415
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
7210 call assert_equal(-1, test_refcount(test_null_function()))
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
7211 call assert_equal(-1, test_refcount(test_null_partial()))
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
7212 call assert_equal(-1, test_refcount(test_null_blob()))
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
7213 call assert_equal(-1, test_refcount(test_null_list()))
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
7214 call assert_equal(-1, test_refcount(test_null_dict()))
16078
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7215 endfunc
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7216
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7217 " Test for missing :endif, :endfor, :endwhile and :endtry {{{1
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7218 func Test_missing_end()
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
7219 call writefile(['if 2 > 1', 'echo ">"'], 'Xscript', 'D')
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7220 call assert_fails('source Xscript', 'E171:')
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7221 call writefile(['for i in range(5)', 'echo i'], 'Xscript')
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7222 call assert_fails('source Xscript', 'E170:')
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7223 call writefile(['while v:true', 'echo "."'], 'Xscript')
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7224 call assert_fails('source Xscript', 'E170:')
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7225 call writefile(['try', 'echo "."'], 'Xscript')
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7226 call assert_fails('source Xscript', 'E600:')
19471
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7227
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7228 " Using endfor with :while
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7229 let caught_e732 = 0
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7230 try
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7231 while v:true
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7232 endfor
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7233 catch /E732:/
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7234 let caught_e732 = 1
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7235 endtry
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7236 call assert_equal(1, caught_e732)
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7237
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7238 " Using endwhile with :for
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7239 let caught_e733 = 0
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7240 try
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7241 for i in range(1)
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7242 endwhile
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7243 catch /E733:/
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7244 let caught_e733 = 1
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7245 endtry
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7246 call assert_equal(1, caught_e733)
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7247
19932
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7248 " Using endfunc with :if
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7249 call assert_fails('exe "if 1 | endfunc | endif"', 'E193:')
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7250
19471
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7251 " Missing 'in' in a :for statement
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7252 call assert_fails('for i range(1) | endfor', 'E690:')
20128
0b35a7ffceb2 patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
7253
0b35a7ffceb2 patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
7254 " Incorrect number of variables in for
0b35a7ffceb2 patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
7255 call assert_fails('for [i,] in range(3) | endfor', 'E475:')
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7256 endfunc
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7257
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7258 " Test for deep nesting of if/for/while/try statements {{{1
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7259 func Test_deep_nest()
20625
116c7bd5e980 patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 20158
diff changeset
7260 CheckRunVimInTerminal
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7261
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7262 let lines =<< trim [SCRIPT]
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7263 " Deep nesting of if ... endif
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7264 func Test1()
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7265 let @a = join(repeat(['if v:true'], 51), "\n")
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7266 let @a ..= "\n"
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7267 let @a ..= join(repeat(['endif'], 51), "\n")
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7268 @a
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7269 let @a = ''
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7270 endfunc
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7271
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7272 " Deep nesting of for ... endfor
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7273 func Test2()
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7274 let @a = join(repeat(['for i in [1]'], 51), "\n")
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7275 let @a ..= "\n"
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7276 let @a ..= join(repeat(['endfor'], 51), "\n")
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7277 @a
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7278 let @a = ''
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7279 endfunc
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7280
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7281 " Deep nesting of while ... endwhile
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7282 func Test3()
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7283 let @a = join(repeat(['while v:true'], 51), "\n")
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7284 let @a ..= "\n"
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7285 let @a ..= join(repeat(['endwhile'], 51), "\n")
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7286 @a
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7287 let @a = ''
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7288 endfunc
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7289
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7290 " Deep nesting of try ... endtry
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7291 func Test4()
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7292 let @a = join(repeat(['try'], 51), "\n")
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7293 let @a ..= "\necho v:true\n"
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7294 let @a ..= join(repeat(['endtry'], 51), "\n")
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7295 @a
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7296 let @a = ''
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7297 endfunc
19932
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7298
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7299 " Deep nesting of function ... endfunction
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7300 func Test5()
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7301 let @a = join(repeat(['function X()'], 51), "\n")
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7302 let @a ..= "\necho v:true\n"
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7303 let @a ..= join(repeat(['endfunction'], 51), "\n")
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7304 @a
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7305 let @a = ''
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7306 endfunc
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7307 [SCRIPT]
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
7308 call writefile(lines, 'Xscript', 'D')
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7309
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7310 let buf = RunVimInTerminal('-S Xscript', {'rows': 6})
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7311
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7312 " Deep nesting of if ... endif
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7313 call term_sendkeys(buf, ":call Test1()\n")
19954
c087099e9163 patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents: 19950
diff changeset
7314 call TermWait(buf)
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7315 call WaitForAssert({-> assert_match('^E579:', term_getline(buf, 5))})
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7316
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7317 " Deep nesting of for ... endfor
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7318 call term_sendkeys(buf, ":call Test2()\n")
19954
c087099e9163 patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents: 19950
diff changeset
7319 call TermWait(buf)
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7320 call WaitForAssert({-> assert_match('^E585:', term_getline(buf, 5))})
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7321
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7322 " Deep nesting of while ... endwhile
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7323 call term_sendkeys(buf, ":call Test3()\n")
19954
c087099e9163 patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents: 19950
diff changeset
7324 call TermWait(buf)
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7325 call WaitForAssert({-> assert_match('^E585:', term_getline(buf, 5))})
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7326
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7327 " Deep nesting of try ... endtry
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7328 call term_sendkeys(buf, ":call Test4()\n")
19954
c087099e9163 patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents: 19950
diff changeset
7329 call TermWait(buf)
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7330 call WaitForAssert({-> assert_match('^E601:', term_getline(buf, 5))})
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7331
19932
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7332 " Deep nesting of function ... endfunction
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7333 call term_sendkeys(buf, ":call Test5()\n")
19954
c087099e9163 patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents: 19950
diff changeset
7334 call TermWait(buf)
19932
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7335 call WaitForAssert({-> assert_match('^E1058:', term_getline(buf, 4))})
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7336 call term_sendkeys(buf, "\<C-C>\n")
19954
c087099e9163 patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents: 19950
diff changeset
7337 call TermWait(buf)
19932
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7338
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7339 "let l = ''
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7340 "for i in range(1, 6)
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7341 " let l ..= term_getline(buf, i) . "\n"
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7342 "endfor
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7343 "call assert_report(l)
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7344
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7345 call StopVimInTerminal(buf)
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7346 endfunc
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7347
19724
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
7348 " Test for errors in converting to float from various types {{{1
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
7349 func Test_float_conversion_errors()
30310
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7350 call assert_fails('let x = 4.0 % 2.0', 'E804:')
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7351 call assert_fails('echo 1.1[0]', 'E806:')
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7352 call assert_fails('echo sort([function("min"), 1], "f")', 'E891:')
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7353 call assert_fails('echo 3.2 == "vim"', 'E892:')
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7354 call assert_fails('echo sort([[], 1], "f")', 'E893:')
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7355 call assert_fails('echo sort([{}, 1], "f")', 'E894:')
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7356 call assert_fails('echo 3.2 == v:true', 'E362:')
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7357 call assert_fails('echo 3.2 == v:none', 'E907:')
19724
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
7358 endfunc
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
7359
21110
8fb0e507491d patch 8.2.1106: crash when trying to use s: variable in typed command
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
7360 " invalid function names {{{1
20109
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7361 func Test_invalid_function_names()
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7362 " function name not starting with capital
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7363 let caught_e128 = 0
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7364 try
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7365 func! g:test()
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7366 echo "test"
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7367 endfunc
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7368 catch /E128:/
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7369 let caught_e128 = 1
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7370 endtry
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7371 call assert_equal(1, caught_e128)
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7372
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7373 " function name includes a colon
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7374 let caught_e884 = 0
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7375 try
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7376 func! b:test()
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7377 echo "test"
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7378 endfunc
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7379 catch /E884:/
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7380 let caught_e884 = 1
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7381 endtry
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7382 call assert_equal(1, caught_e884)
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7383
23229
b545334ae654 patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
7384 " function name followed by #
20109
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7385 let caught_e128 = 0
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7386 try
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7387 func! test2() "#
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7388 echo "test2"
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7389 endfunc
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7390 catch /E128:/
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7391 let caught_e128 = 1
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7392 endtry
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7393 call assert_equal(1, caught_e128)
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7394
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7395 " function name starting with/without "g:", buffer-local funcref.
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7396 function! g:Foo(n)
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7397 return 'called Foo(' . a:n . ')'
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7398 endfunction
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7399 let b:my_func = function('Foo')
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7400 call assert_equal('called Foo(1)', b:my_func(1))
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7401 call assert_equal('called Foo(2)', g:Foo(2))
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7402 call assert_equal('called Foo(3)', Foo(3))
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7403 delfunc g:Foo
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7404
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7405 " script-local function used in Funcref must exist.
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7406 let lines =<< trim END
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7407 func s:Testje()
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7408 return "foo"
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7409 endfunc
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7410 let Bar = function('s:Testje')
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7411 call assert_equal(0, exists('s:Testje'))
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7412 call assert_equal(1, exists('*s:Testje'))
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7413 call assert_equal(1, exists('Bar'))
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7414 call assert_equal(1, exists('*Bar'))
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7415 END
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
7416 call writefile(lines, 'Xscript', 'D')
20109
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7417 source Xscript
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7418 endfunc
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7419
21110
8fb0e507491d patch 8.2.1106: crash when trying to use s: variable in typed command
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
7420 " substring and variable name {{{1
20109
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7421 func Test_substring_var()
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7422 let str = 'abcdef'
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7423 let n = 3
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7424 call assert_equal('def', str[n:])
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7425 call assert_equal('abcd', str[:n])
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7426 call assert_equal('d', str[n:n])
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7427 unlet n
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7428 let nn = 3
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7429 call assert_equal('def', str[nn:])
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7430 call assert_equal('abcd', str[:nn])
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7431 call assert_equal('d', str[nn:nn])
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7432 unlet nn
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7433 let b:nn = 4
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7434 call assert_equal('ef', str[b:nn:])
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7435 call assert_equal('abcde', str[:b:nn])
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7436 call assert_equal('e', str[b:nn:b:nn])
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7437 unlet b:nn
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7438 endfunc
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7439
21110
8fb0e507491d patch 8.2.1106: crash when trying to use s: variable in typed command
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
7440 " Test using s: with a typed command {{{1
8fb0e507491d patch 8.2.1106: crash when trying to use s: variable in typed command
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
7441 func Test_typed_script_var()
8fb0e507491d patch 8.2.1106: crash when trying to use s: variable in typed command
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
7442 CheckRunVimInTerminal
8fb0e507491d patch 8.2.1106: crash when trying to use s: variable in typed command
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
7443
8fb0e507491d patch 8.2.1106: crash when trying to use s: variable in typed command
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
7444 let buf = RunVimInTerminal('', {'rows': 6})
8fb0e507491d patch 8.2.1106: crash when trying to use s: variable in typed command
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
7445
8fb0e507491d patch 8.2.1106: crash when trying to use s: variable in typed command
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
7446 " Deep nesting of if ... endif
8fb0e507491d patch 8.2.1106: crash when trying to use s: variable in typed command
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
7447 call term_sendkeys(buf, ":echo get(s:, 'foo', 'x')\n")
8fb0e507491d patch 8.2.1106: crash when trying to use s: variable in typed command
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
7448 call TermWait(buf)
8fb0e507491d patch 8.2.1106: crash when trying to use s: variable in typed command
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
7449 call WaitForAssert({-> assert_match('^E116:', term_getline(buf, 5))})
8fb0e507491d patch 8.2.1106: crash when trying to use s: variable in typed command
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
7450
8fb0e507491d patch 8.2.1106: crash when trying to use s: variable in typed command
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
7451 call StopVimInTerminal(buf)
8fb0e507491d patch 8.2.1106: crash when trying to use s: variable in typed command
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
7452 endfunc
8fb0e507491d patch 8.2.1106: crash when trying to use s: variable in typed command
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
7453
21925
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7454 " Test for issue6776 {{{1
27901
dd7d94b911fa patch 8.2.4476: operator name spelled wrong
Bram Moolenaar <Bram@vim.org>
parents: 26606
diff changeset
7455 func Test_ternary_expression()
21925
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7456 try
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7457 call eval('0 ? 0')
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7458 catch
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7459 endtry
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7460 " previous failure should not cause next expression to fail
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7461 call assert_equal(v:false, eval(string(v:false)))
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7462
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7463 try
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7464 call eval('0 ? "burp')
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7465 catch
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7466 endtry
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7467 " previous failure should not cause next expression to fail
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7468 call assert_equal(v:false, eval(string(v:false)))
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7469
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7470 try
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7471 call eval('1 ? 0 : "burp')
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7472 catch
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7473 endtry
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7474 " previous failure should not cause next expression to fail
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7475 call assert_equal(v:false, eval(string(v:false)))
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7476 endfunction
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7477
24234
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7478 func Test_for_over_string()
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7479 let res = ''
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7480 for c in 'aéc̀d'
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7481 let res ..= c .. '-'
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7482 endfor
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7483 call assert_equal('a-é-c̀-d-', res)
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7484
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7485 let res = ''
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7486 for c in ''
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7487 let res ..= c .. '-'
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7488 endfor
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7489 call assert_equal('', res)
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7490
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7491 let res = ''
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7492 for c in test_null_string()
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7493 let res ..= c .. '-'
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7494 endfor
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7495 call assert_equal('', res)
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7496 endfunc
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7497
29305
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7498 " Test for deeply nested :source command {{{1
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7499 func Test_deeply_nested_source()
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7500 let lines =<< trim END
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7501
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7502 so
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7503 sil 0scr
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7504 delete
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7505 so
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7506 0
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7507 END
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
7508 call writefile(["vim9 silent! @0 \n/"] + lines, 'Xnested.vim', 'D')
29305
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7509
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7510 " this must not crash
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7511 let cmd = GetVimCommand() .. " -e -s -S Xnested.vim -c qa!"
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7512 call system(cmd)
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7513 endfunc
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7514
11461
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
7515 "-------------------------------------------------------------------------------
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7516 " Modelines {{{1
18504
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
7517 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7518 "-------------------------------------------------------------------------------