annotate src/testdir/test_vimscript.vim @ 31349:22d11340ee68 v9.0.1008

patch 9.0.1008: test for swapfilelist() fails on MS-Windows Commit: https://github.com/vim/vim/commit/6cf3151f0e3839332c89367b7384c395a1185927 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Dec 5 15:01:05 2022 +0000 patch 9.0.1008: test for swapfilelist() fails on MS-Windows Problem: Test for swapfilelist() fails on MS-Windows. Solution: Only check the tail of the path. Mark a test as flaky.
author Bram Moolenaar <Bram@vim.org>
date Mon, 05 Dec 2022 16:15:04 +0100
parents 39698292a849
children a207f55deb62
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
31069
39698292a849 patch 9.0.0869: bogus error when string used after :elseif
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
195 " Check double quote after skipped "elseif" does not give error E15
39698292a849 patch 9.0.0869: bogus error when string used after :elseif
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
196 func Test_skipped_elseif()
39698292a849 patch 9.0.0869: bogus error when string used after :elseif
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
197 if "foo" ==? "foo"
39698292a849 patch 9.0.0869: bogus error when string used after :elseif
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
198 let result = "first"
39698292a849 patch 9.0.0869: bogus error when string used after :elseif
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
199 elseif "foo" ==? "foo"
39698292a849 patch 9.0.0869: bogus error when string used after :elseif
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
200 let result = "second"
39698292a849 patch 9.0.0869: bogus error when string used after :elseif
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
201 endif
39698292a849 patch 9.0.0869: bogus error when string used after :elseif
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
202 call assert_equal('first', result)
39698292a849 patch 9.0.0869: bogus error when string used after :elseif
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
203 endfunc
39698292a849 patch 9.0.0869: bogus error when string used after :elseif
Bram Moolenaar <Bram@vim.org>
parents: 30986
diff changeset
204
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
205 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
206 " 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
207 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
208
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
209 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
210 if 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
211 Xpath 'a'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
212 let loops = 3
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
213 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
214 Xpath 'b' . loops
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
215 if (loops == 2)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
216 Xpath 'c' . loops
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
217 return
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
218 Xpath 'd' . loops
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
219 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
220 Xpath 'e' . loops
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
221 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
222 endwhile
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
223 Xpath 'f'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
224 else
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
225 Xpath 'g'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
226 endif
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
227 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
228
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
229 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
230 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
231 call T4_F()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
232 Xpath '4'
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 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
235 endfunc
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
236
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
237
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
238 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
239 " 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
240 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
241 " 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
242 " 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
243 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
244
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
245 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
246 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
247 ExecAsScript T4_F
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
248 Xpath '5'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
249 call DeleteTheScript()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
250
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
251 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
252 endfunc
10942
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
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
255
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 " 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
258 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
259 " 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
260 " 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
261 " 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
262 " 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
263 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
264 " 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
265 " 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
266 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
267
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
268 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
269
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
270 " 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
271 " 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
272 " 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
273 " 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
274 " 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
275 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
276 let calls = ""
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
277 com! -nargs=1 CALL
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
278 \ if !exists("calls") && !exists("outer") |
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
279 \ 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
280 \ endif
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
281
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
282 let i = 0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
283 while i < 3
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
284 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
285 if i == 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
286 Xpath 'a'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
287 function! F1(arg)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
288 CALL a:arg
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
289 let outer = 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
290
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
291 let j = 0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
292 while j < 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
293 Xpath 'b'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
294 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
295 function! G1(arg)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
296 CALL a:arg
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
297 endfunction
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
298 Xpath 'c'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
299 endwhile
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
300 endfunction
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
301 Xpath 'd'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
302
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
303 continue
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
304 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
305
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
306 Xpath 'e' . i
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
307 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
308 CALL a:arg
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
309 let outer = 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
310
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
311 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
312 Xpath 'f'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
313 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
314 let k = 0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
315 while k < 3
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
316 Xpath 'g' . k
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
317 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
318 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
319 CALL a:arg
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
320 endfunction
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
321 Xpath 'h' . k
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
322 endwhile
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
323 endfunction
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
324 Xpath 'i'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
325
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
326 endwhile
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("*G1")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
329 Xpath 'j'
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("*F1")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
332 call F1("F1")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
333 if exists("*G1")
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
334 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
335 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
336 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
337
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
338 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
339 Xpath 'k'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
340 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
341 if exists("*F2")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
342 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
343 if exists("*G21")
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
344 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
345 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
346 if exists("*G22")
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
347 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
348 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
349 if exists("*G23")
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
350 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
351 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
352 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
353
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
354 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
355 Xpath 'l'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
356 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
357 if exists("*F3")
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
358 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
359 if exists("*G31")
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
360 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
361 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
362 if exists("*G32")
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
363 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
364 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
365 if exists("*G33")
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
366 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
367 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
368 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
369
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
370 Xpath 'm'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
371
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
372 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
373 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
374
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
375 unlet calls
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
376 delfunction F1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
377 delfunction G1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
378 delfunction F2
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
379 delfunction G21
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
380 delfunction G22
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
381 delfunction G23
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
382 delfunction G31
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
383 delfunction G32
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
384 delfunction G33
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
385
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
386 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
387 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
388 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
389 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
390
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 " 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
393 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
394 " 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
395 " 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
396 " 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
397 " line.
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
398 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
399
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
400 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
401
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
402 if 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
403 Xpath 'a'
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 'b'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
406 asdf
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
407 Xpath 'c'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
408 break
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
409 endwhile | Xpath 'd'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
410 Xpath 'e'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
411 endif | Xpath 'f'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
412 Xpath 'g'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
413
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
414 while 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
415 Xpath 'h'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
416 if 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
417 Xpath 'i'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
418 asdf
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
419 Xpath 'j'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
420 endif | Xpath 'k'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
421 Xpath 'l'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
422 break
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
423 endwhile | Xpath 'm'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
424 Xpath 'n'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
425
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
426 asdf
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
427 Xpath 'o'
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 asdf | Xpath 'p'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
430 Xpath 'q'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
431
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
432 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
433
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
434 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
435 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
436 endfunc
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 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
439 " 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
440 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
441 " 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
442 " 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
443 " 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
444 " "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
445 " 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
446 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
447
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
448 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
449
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
450 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
451 if 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
452 Xpath 'a'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
453 while 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
454 Xpath 'b'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
455 asdf
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
456 Xpath 'c'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
457 asdf | Xpath 'd'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
458 Xpath 'e'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
459 break
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
460 endwhile
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
461 Xpath 'f'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
462 endif | Xpath 'g'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
463 Xpath 'h'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
464
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
465 while 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
466 Xpath 'i'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
467 if 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
468 Xpath 'j'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
469 asdf
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
470 Xpath 'k'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
471 asdf | Xpath 'l'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
472 Xpath 'm'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
473 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
474 Xpath 'n'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
475 break
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
476 endwhile | Xpath 'o'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
477 Xpath 'p'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
478
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
479 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
480 Xpath 'q'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
481 return 1 " not reached
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
482 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
483
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
484 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
485 if 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
486 Xpath 'r'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
487 while 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
488 Xpath 's'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
489 asdf " returns -1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
490 Xpath 't'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
491 break
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
492 endwhile
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
493 Xpath 'v'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
494 endif | Xpath 'w'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
495 Xpath 'x'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
496
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
497 return -4 " not reached
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
498 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
499
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
500 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
501 while 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
502 Xpath 'A'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
503 if 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
504 Xpath 'B'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
505 asdf " returns -1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
506 Xpath 'C'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
507 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
508 Xpath 'D'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
509 break
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
510 endwhile | Xpath 'E'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
511 Xpath 'F'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
512
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
513 return -4 " not reached
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
514 endfunc
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
515
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
516 " 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
517 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
518 Xpath 'X'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
519 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
520
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
521 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
522 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
523 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
524
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
525 delfunction T8_F
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
526 delfunction T8_G
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
527 delfunction T8_H
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
528 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
529
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
530
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
531 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
532 " 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
533 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
534 " 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
535 " 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
536 " "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
537 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
538
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
539 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
540
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
541 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
542 Xpath 'a'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
543 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
544 Xpath 'b'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
545 if result != 2
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
546 Xpath 'c'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
547 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
548 return 1
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
549 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
550
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
551 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
552 Xpath 'd'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
553 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
554 Xpath 'e'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
555 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
556 Xpath 'f'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
557 return 2
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
558 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
559
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
560 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
561 Xpath 'g'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
562 call I() " aborted
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
563 Xpath 'h'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
564 return 4
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
565 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
566
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
567 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
568 Xpath 'i'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
569 asdf " error
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
570 Xpath 'j'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
571 return 8
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
572 endfunc
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
573
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
574 if F() != 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
575 Xpath 'k'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
576 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
577
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
578 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
579
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
580 delfunction F
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
581 delfunction G
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
582 delfunction H
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
583 delfunction I
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
584
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
585 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
586 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
587 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
588
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
589
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
590 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
591 " 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
592 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
593 " 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
594 " 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
595 " be recognized.
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
596 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
597
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
598 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
599
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
600 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
601 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
602 if a:enr == ""
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
603 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
604 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
605 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
606 let match = 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
607 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
608 let match = 0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
609 if v:errmsg == ""
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
610 Xout "Message missing."
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
611 else
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17783
diff changeset
612 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
613 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
614 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
615 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
616 return match
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
617 endfunc
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
618
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
619 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
620 Xpath 'b'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
621 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
622 Xpath 'c'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
623
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
624 if 0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
625 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
626 Xpath 'e'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
627 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
628 Xpath 'f'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
629
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
630 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
631 Xpath 'h'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
632 break
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
633 endwhile
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
634 Xpath 'i'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
635
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
636 let v:errmsg = ""
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
637 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
638 Xpath 'k'
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 'l'
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 'm'
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 if 0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
647 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
648 Xpath 'o'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
649 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
650 Xpath 'p'
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 'q'
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 v:errmsg = ""
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
656 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
657 Xpath 's'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
658 break
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
659 endwhile
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
660 Xpath 't'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
661 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
662 Xpath 'u'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
663 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
664
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
665 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
666 delfunction MSG
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
667
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
668 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
669 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
670 endfunc
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
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
673 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
674 " 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
675 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
676 " 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
677 " 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
678 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
679
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
680 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
681
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
682 let calls = 0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
683
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
684 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
685 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
686 return 0
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
687 endfunc
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
688
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
689 if 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
690 Xpath 'a'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
691 asdf " error
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
692 Xpath 'b'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
693 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
694 Xpath 'c'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
695 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
696 Xpath 'd'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
697 else
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
698 Xpath 'e'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
699 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
700 Xpath 'f'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
701 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
702 Xpath 'g'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
703 endwhile
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
704 Xpath 'h'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
705 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
706 Xpath 'x'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
707
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
708 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
709 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
710
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
711 unlet calls
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
712 delfunction P
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
713
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
714 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
715 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
716 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
717 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
718
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
719
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
720 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
721 " 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
722 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
723 " 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
724 " 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
725 " 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
726 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
727
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
728 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
729
30687
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
730 func NULL()
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
731 Xpath 'a'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
732 return 0
30687
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
733 endfunc
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
734
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
735 func ZERO()
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
736 Xpath 'b'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
737 return 0
30687
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
738 endfunc
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
739
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
740 func! F0()
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
741 Xpath 'c'
30687
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
742 endfunc
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
743
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
744 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
745 Xpath 'e'
30687
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
746 endfunc
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
747
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
748 let V0 = 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
749
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
750 Xpath 'f'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
751 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
752
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
753 Xpath 'g'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
754 if 0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
755 Xpath 'h'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
756 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
757 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
758
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
759 Xpath 'i'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
760 if 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
761 asdf " error
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
762 Xpath 'j'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
763 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
764 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
765
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
766 Xpath 'k'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
767 if 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
768 asdf " error
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
769 Xpath 'l'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
770 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
771 endif
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 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
774
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
775 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
776 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
777 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
778
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 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
781 " 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
782 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
783 " 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
784 " 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
785 " 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
786 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
787
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
788 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
789
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
790 Xpath 'a'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
791 while asdf
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
792 Xpath 'b'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
793 while 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
794 Xpath 'c'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
795 break
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
796 endwhile
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
797 Xpath 'd'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
798 break
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
799 endwhile
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
800 Xpath 'e'
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 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
803 Xpath 'h'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
804 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
805
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
806 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
807 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
808 endfunc
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
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 " 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
813 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
814 " 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
815 " 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
816 " 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
817 " are executed.
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
818 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
819
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
820 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
821
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
822 function! F()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
823 Xpath 'a'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
824 let x = 0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
825 if x " false
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
826 Xpath 'b'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
827 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
828 Xpath 'c'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
829 let x = 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
830 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
831 Xpath 'd'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
832 else
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
833 Xpath 'e'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
834 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
835 Xpath 'f'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
836 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
837 Xpath 'g'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
838 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
839 Xpath 'h'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
840 endfunction
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 let boolvar = 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
843 call F()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
844 Xpath '-'
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 unlet boolvar
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
847 call F()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
848 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
849
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
850 delfunction F
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
851
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
852 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
853 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
854 endfunc
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
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
857 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
858 " 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
859 "
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
860 " 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
861 " 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
862 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
863
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
864 XpathINIT
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
865
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
866 function! F()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
867 Xpath 'a'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
868 let x = 0
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
869 if x " false
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
870 Xpath 'b'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
871 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
872 Xpath 'c'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
873 let x = 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
874 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
875 Xpath 'f'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
876 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
877 Xpath 'g'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
878 endif
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
879 Xpath 'h'
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
880 endfunction
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 let boolvar = 1
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
883 call F()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
884 Xpath '-'
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 unlet boolvar
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
887 call F()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
888 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
889
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
890 delfunction F
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
891
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
892 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
893 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
894 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
895
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
896 "-------------------------------------------------------------------------------
18504
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
897 " 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
898 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
899 " 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
900 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
901
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
902 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
903 if 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
904 Xpath 'a'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
905 else
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
906 Xpath 'b'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
907 else " aborts function
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
908 Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
909 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
910 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
911 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
912
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
913 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
914 if 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
915 Xpath 'a'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
916 else
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
917 Xpath 'b'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
918 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
919 Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
920 else
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
921 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
922 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
923 Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
924 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
925
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
926 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
927 if 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
928 Xpath 'a'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
929 elseif 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
930 Xpath 'b'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
931 else
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
932 Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
933 else " aborts function
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
934 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
935 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
936 Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
937 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
938
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
939 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
940 if 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
941 Xpath 'a'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
942 elseif 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
943 Xpath 'b'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
944 else
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
945 Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
946 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
947 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
948 else
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 endif
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
951 Xpath 'f'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
952 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
953
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
954 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
955 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
956 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
957 call T16_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
958 catch /E583:/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
959 Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
960 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
961 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
962
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
963 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
964 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
965 call T16_G()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
966 catch /E584:/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
967 Xpath 'f'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
968 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
969 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
970
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
971 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
972 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
973 call T16_H()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
974 catch /E583:/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
975 Xpath 'f'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
976 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
977 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
978
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
979 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
980 try
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
981 call T16_I()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
982 catch /E584:/
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
983 Xpath 'g'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
984 endtry
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
985 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
986 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
987
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
988 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
989 " 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
990 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
991 " 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
992 " :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
993 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
994
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
995 " 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
996 func T17_F()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
997 let loops = 3
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
998 while loops > 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
999 let loops -= 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1000 Xpath 'a' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1001 if (loops == 1)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1002 Xpath 'b' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1003 continue
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1004 elseif (loops == 0)
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1005 Xpath 'c' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1006 break
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1007 elseif 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1008 Xpath 'd' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1009 " endif missing!
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1010 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
1011 Xpath 'e'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1012 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1013
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1014 func T17_G()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1015 let loops = 2
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1016 while loops > 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1017 let loops -= 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1018 Xpath 'a' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1019 if 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1020 Xpath 'b' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1021 " endif missing
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1022 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
1023 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1024
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1025 func T17_H()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1026 let loops = 2
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1027 while loops > 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1028 let loops -= 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1029 Xpath 'a' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1030 " if missing!
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1031 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
1032 Xpath 'b' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1033 endwhile
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1034 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1035
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1036 " 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
1037 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1038 let v:errmsg = ''
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1039 let loops = 2
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1040 while loops > 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1041 let loops -= 1
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1042 Xpath 'a' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1043 if 0
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1044 Xpath 'b' . loops
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1045 " 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
1046 endwhile | Xpath 'c'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1047 Xpath 'd'
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1048 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
1049 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
1050
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1051 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
1052 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1053 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
1054 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
1055
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1056 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1057 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
1058 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
1059
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1060 XpathINIT
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1061 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
1062 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
1063 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1064
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
1065 "-------------------------------------------------------------------------------
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1066 " 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
1067 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1068 " 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
1069 "-------------------------------------------------------------------------------
21632
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1070
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1071 func Test_interrupt_while_if()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1072 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1073 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1074 if 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1075 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1076 while 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1077 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1078 if 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1079 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1080 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1081 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
1082 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1083 finish
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1084 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
1085 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
1086 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
1087 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
1088 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
1089 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
1090 catch /^Vim:Interrupt$/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1091 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1092 endtry | Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1093 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1094 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1095 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1096 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
1097 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1098 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1099 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1100
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1101 func Test_interrupt_try()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1102 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1103 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1104 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1105 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1106 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1107 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
1108 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
1109 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
1110 catch /^Vim:Interrupt$/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1111 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1112 endtry | Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1113 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1114 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1115 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1116 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
1117 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1118 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1119 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1120
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1121 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
1122 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1123 func F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1124 if 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1125 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1126 while 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1127 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1128 if 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1129 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1130 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1131 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
1132 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1133 return
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1134 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
1135 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
1136 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
1137 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
1138 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
1139 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
1140 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1141
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1142 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1143 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1144 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
1145 catch /^Vim:Interrupt$/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1146 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1147 endtry | Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1148 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1149 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1150 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1151 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
1152 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1153 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1154 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1155
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1156 func Test_interrupt_func_try()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1157 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1158 func G()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1159 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1160 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1161 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1162 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
1163 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
1164 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
1165 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1166
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1167 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1168 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1169 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
1170 catch /^Vim:Interrupt$/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1171 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1172 endtry | Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1173 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1174 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1175 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1176 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
1177 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1178 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1179 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1180
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1181 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1182 " 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
1183 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1184 " 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
1185 " 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
1186 " 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
1187 " function has an "abort" attribute.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1188 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1189
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1190 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
1191 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1192 func F() abort
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1193 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1194 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1195 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
1196 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1197
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1198 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1199 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1200 call F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1201 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
1202 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
1203 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
1204 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1205 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1206 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
1207 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1208 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1209 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1210
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1211 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
1212 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1213 func G()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1214 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1215 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1216 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
1217 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1218
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1219 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1220 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1221 call G()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1222 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
1223 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
1224 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
1225 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1226 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1227 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
1228 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1229 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1230 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1231
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1232 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
1233 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1234 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1235 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1236 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1237 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
1238 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
1239 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
1240 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1241 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1242 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
1243 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1244 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1245 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1246
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1247 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
1248 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1249 if 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1250 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1251 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1252 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1253 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
1254 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
1255 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
1256 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
1257 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1258 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1259 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
1260 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1261 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1262 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1263
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1264 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
1265 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1266 let p = 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1267 while p
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1268 let p = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1269 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1270 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1271 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1272 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
1273 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
1274 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
1275 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
1276 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1277 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1278 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
1279 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1280 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1281 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1282
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1283 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
1284 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1285 let p = 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1286 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1287 while p
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1288 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1289 let p = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1290 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1291 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1292 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
1293 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
1294 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1295 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1296 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
1297 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1298 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1299 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1300
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1301 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1302 " 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
1303 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1304 " 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
1305 " 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
1306 " seen.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1307 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1308
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1309 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
1310 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1311 let p = 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1312 while p
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1313 let p = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1314 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1315 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1316 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1317 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1318 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1319 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
1320 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
1321 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1322 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1323 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1324 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
1325 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1326 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1327 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1328
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1329 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
1330 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1331 while 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1332 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1333 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1334 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1335 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
1336 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1337 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1338 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1339 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1340 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1341 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1342 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1343 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
1344 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1345 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1346 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1347
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1348 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
1349 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1350 while 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1351 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1352 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1353 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1354 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
1355 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1356 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1357 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1358 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1359 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1360 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1361 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1362 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1363 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1364 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
1365 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1366 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1367 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1368
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1369 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
1370 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1371 while 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1372 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1373 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1374 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1375 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1376 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1377 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
1378 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1379 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1380 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1381 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1382 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1383 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1384 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1385 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
1386 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1387 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1388 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1389
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1390 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
1391 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1392 let p = 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1393 while p
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1394 let p = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1395 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1396 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1397 continue
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1398 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
1399 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1400 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1401 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1402 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1403 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1404 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1405 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1406 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
1407 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1408 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1409 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1410
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1411 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
1412 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1413 let p = 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1414 while p
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1415 let p = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1416 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1417 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1418 continue
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1419 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
1420 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1421 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1422 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1423 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1424 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1425 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1426 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1427 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1428 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1429 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
1430 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1431 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1432 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1433
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1434 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
1435 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1436 let p = 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1437 while p
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1438 let p = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1439 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1440 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1441 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1442 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1443 continue
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1444 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
1445 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1446 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1447 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1448 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1449 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1450 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1451 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1452 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
1453 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1454 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1455 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1456
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1457 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1458 " 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
1459 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1460 " 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
1461 " :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
1462 " executed.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1463 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1464
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1465 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
1466 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1467 func F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1468 let loops = 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1469 while loops > 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1470 XloopNEXT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1471 let loops = loops - 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1472 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1473 if loops == 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1474 Xloop 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1475 continue
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 elseif loops == 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1478 Xloop 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1479 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1480 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
1481 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1482
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1483 try " inactive
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1484 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
1485 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1486 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
1487 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1488 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1489 Xloop 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1490 endtry
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 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1493
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1494 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1495 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1496 return
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1497 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
1498 try " inactive
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1499 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
1500 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1501 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
1502 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1503 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1504 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1505 endtry
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 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1508
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1509 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1510 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1511 call F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1512 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1513 finish
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1514 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
1515 try " inactive
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1516 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
1517 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1518 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
1519 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1520 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1521 Xpath 'h'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1522 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1523 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
1524 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1525 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1526 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
1527 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1528 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1529 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1530
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1531 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1532 " 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
1533 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1534 " 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
1535 " 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
1536 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1537
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1538 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
1539 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1540 func Error()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1541 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1542 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1543 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
1544 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
1545 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1546 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
1547 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1548
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1549 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1550 call Error()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1551 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
1552
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1553 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
1554 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
1555 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
1556 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1557 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
1558 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1559 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1560
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1561 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
1562 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
1563 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1564 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
1565 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1566 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1567 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1568 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
1569 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1570 call RunInNewVim(test, verify)
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 func Test_finally_after_interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1574 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1575 func Interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1576 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1577 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1578 call interrupt() " triggering interrupt exception
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1579 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
1580 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1581 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1582
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1583 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1584 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1585 call Interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1586 catch /^Vim:Interrupt$/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1587 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1588 finish
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1589 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1590 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
1591
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1592 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
1593 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
1594 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
1595 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1596 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
1597 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1598 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1599
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1600 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
1601 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
1602 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1603 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
1604 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1605 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1606 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1607 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
1608 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1609 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1610 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1611
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1612 func Test_finally_after_throw()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1613 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1614 func Throw()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1615 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1616 throw 'xyz'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1617 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1618
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1619 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1620 call Throw()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1621 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
1622
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1623 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
1624 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
1625 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
1626 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1627 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
1628 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1629 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1630
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1631 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
1632 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
1633 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1634 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
1635 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1636 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1637 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1638 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
1639 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1640 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1641 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1642
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1643 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1644 " 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
1645 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1646 " 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
1647 " 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
1648 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1649
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1650 func Test_catch_after_throw()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1651 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1652 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1653 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1654 throw "xyz"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1655 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
1656
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1657 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
1658 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
1659 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
1660 catch /xyz/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1661 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
1662 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1663 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1664 catch /xyz/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1665 Xpath 'b'
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
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1668 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1669 throw "abc"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1670 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
1671
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1672 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
1673 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
1674 catch /abc/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1675 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
1676 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1677 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1678 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1679 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
1680 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1681 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1682 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1683
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1684 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1685 " 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
1686 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1687 " 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
1688 " 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
1689 " active :try conditional.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1690 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1691
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1692 func Test_endtry_after_throw()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1693 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1694 try " try 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1695 try " try 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1696 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1697 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
1698 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
1699
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1700 try " try 3
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1701 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
1702 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
1703 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
1704 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1705 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1706 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
1707 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
1708 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1709 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1710 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1711 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1712 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
1713 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1714 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1715 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1716
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1717 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1718 " 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
1719 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1720 " 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
1721 " :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
1722 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1723
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1724 func T27_F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1725 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1726 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1727 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1728 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1729 return
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1730 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
1731 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1732 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1733 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1734 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1735 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1736 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1737 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1738 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
1739 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1740
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1741 func T27_G()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1742 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1743 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1744 return
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1745 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
1746 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1747 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1748 call T27_F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1749 Xpath 'h'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1750 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1751 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
1752 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1753
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1754 func T27_H()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1755 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1756 Xpath 'i'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1757 call T27_G()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1758 Xpath 'j'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1759 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1760 Xpath 'k'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1761 return
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1762 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
1763 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1764 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
1765 endfunction
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1766
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1767 func Test_finally_after_return()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1768 XpathINIT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1769 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1770 Xpath 'l'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1771 call T27_H()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1772 Xpath 'm'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1773 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1774 Xpath 'n'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1775 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1776 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
1777 endfunc
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 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1780 " 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
1781 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1782 " 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
1783 " :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
1784 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1785 " 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
1786 " 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
1787 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1788
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1789 func Test_finally_after_finish()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1790 XpathINIT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1791
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1792 let scriptF = MakeScript("T27_F")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1793 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
1794 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
1795
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1796 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1797 Xpath 'A'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1798 exec "source" scriptH
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1799 Xpath 'B'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1800 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1801 Xpath 'C'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1802 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1803 Xpath 'D'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1804 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
1805 call delete(scriptF)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1806 call delete(scriptG)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1807 call delete(scriptH)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1808 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1809
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1810 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1811 " 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
1812 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1813 " 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
1814 " 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
1815 " terminated.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1816 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1817
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1818 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
1819 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1820 func F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1821 while 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1822 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1823 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1824 while 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1825 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1826 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1827 asdf " error
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1828 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 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1830 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1831 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
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 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1834 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1835 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
1836 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1837 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1838 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
1839 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
1840 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1841 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1842 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 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1844
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1845 while 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1846 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1847 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1848 while 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1849 call F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1850 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
1851 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1852 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
1853 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
1854 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1855 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1856 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
1857 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
1858 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
1859 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1860 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1861 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
1862 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1863 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1864 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1865
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1866 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
1867 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1868 func G() abort
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1869 if 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1870 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1871 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1872 asdf " error
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1873 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
1874 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1875 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1876 endtry | Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1877 endif | Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1878 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 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1880
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1881 if 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1882 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1883 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1884 call G()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1885 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
1886 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1887 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1888 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
1889 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
1890 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
1891 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1892 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1893 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
1894 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1895 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1896 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1897
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1898 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1899 " 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
1900 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1901 " 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
1902 " 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
1903 " script processing is terminated.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1904 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1905
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1906 func Test_finally_on_interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1907 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1908 func F()
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 Xloop 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1911 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1912 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
1913 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1914 Xloop 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1915 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1916 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
1917 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1918
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1919 try
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 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1922 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1923 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1924 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1925 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
1926 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1927 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1928 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1929 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1930 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1931 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1932 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1933 Xpath 'h'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1934 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1935 Xpath 'i'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1936 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1937 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
1938 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1939 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
1940 endtry
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 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1943 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
1944 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1945 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
1946 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1947 Xpath 'j'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1948 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1949 Xpath 'k'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1950 call F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1951 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
1952 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1953 Xpath 'l'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1954 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1955 Xpath 'm'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1956 XloopNEXT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1957 ExecAsScript F
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1958 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
1959 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1960 Xpath 'n'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1961 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1962 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
1963 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1964 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
1965 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1966 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
1967 catch /^Vim:Interrupt$/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1968 Xpath 'o'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1969 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1970 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1971 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1972 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
1973 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1974 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1975 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1976
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1977 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1978 " 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
1979 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1980 " 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
1981 " :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
1982 " terminated.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1983 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1984
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1985 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
1986 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1987 func F()
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 Xloop 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1990 throw "exception"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1991 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
1992 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1993 Xloop 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1994 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1995 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
1996 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
1997
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 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2000 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2001 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2002 throw "exception"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2003 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
2004 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2005 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2006 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2007 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2008 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2009 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2010 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2011 Xpath 'h'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2012 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2013 Xpath 'i'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2014 throw "exception"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2015 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
2016 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2017 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
2018 endtry
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 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2021 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
2022 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2023 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
2024 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2025 Xpath 'j'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2026 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2027 Xpath 'k'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2028 call F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2029 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
2030 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2031 Xpath 'l'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2032 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2033 Xpath 'm'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2034 XloopNEXT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2035 ExecAsScript F
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2036 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
2037 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2038 Xpath 'n'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2039 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2040 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
2041 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2042 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
2043 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2044 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
2045 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2046 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2047 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
2048 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2049 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2050 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2051
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2052 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2053 " 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
2054 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2055 " 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
2056 " :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
2057 " 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
2058 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2059
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2060 func Test_finally_after_continue()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2061 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2062 func C(jump)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2063 XloopNEXT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2064 let loop = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2065 while loop < 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2066 let loop = loop + 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2067 if loop == 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2068 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2069 if a:jump == "continue"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2070 continue
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2071 elseif a:jump == "break"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2072 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2073 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
2074 return
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2075 elseif a:jump == "error"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2076 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2077 elseif a:jump == "interrupt"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2078 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2079 let dummy = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2080 elseif a:jump == "throw"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2081 throw "abc"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2082 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2083 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2084 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
2085 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
2086 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2087 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
2088 elseif loop == 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2089 Xloop 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2090 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2091 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2092 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2093
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2094 call C("continue")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2095 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2096 call C("break")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2097 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2098 call C("return")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2099 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2100 let g:jump = "finish"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2101 ExecAsScript C
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2102 unlet g:jump
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2103 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2104 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2105 call C("error")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2106 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2107 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2108 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2109 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2110 call C("interrupt")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2111 Xpath 'h'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2112 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2113 Xpath 'i'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2114 call C("throw")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2115 Xpath 'j'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2116 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2117 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2118 Xpath 'k'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2119 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2120 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2121 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
2122 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2123 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2124 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2125
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2126 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2127 " 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
2128 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2129 " 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
2130 " :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
2131 " 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
2132 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2133
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2134 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
2135 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2136 func B(jump)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2137 XloopNEXT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2138 let loop = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2139 while loop < 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2140 let loop = loop + 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2141 if loop == 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2142 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2143 if a:jump == "continue"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2144 continue
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2145 elseif a:jump == "break"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2146 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2147 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
2148 return
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2149 elseif a:jump == "error"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2150 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2151 elseif a:jump == "interrupt"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2152 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2153 let dummy = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2154 elseif a:jump == "throw"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2155 throw "abc"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2156 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2157 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2158 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
2159 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
2160 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2161 elseif loop == 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2162 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
2163 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2164 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2165 Xloop 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2166 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2167
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2168 call B("continue")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2169 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2170 call B("break")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2171 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2172 call B("return")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2173 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2174 let g:jump = "finish"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2175 ExecAsScript B
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2176 unlet g:jump
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2177 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2178 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2179 call B("error")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2180 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2181 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2182 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2183 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2184 call B("interrupt")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2185 Xpath 'h'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2186 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2187 Xpath 'i'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2188 call B("throw")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2189 Xpath 'j'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2190 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2191 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2192 Xpath 'k'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2193 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2194 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2195 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
2196 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2197 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2198 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2199
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2200 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2201 " 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
2202 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2203 " 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
2204 " :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
2205 " 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
2206 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2207
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2208 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
2209 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2210 func R(jump, retval) abort
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2211 let loop = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2212 while loop < 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2213 let loop = loop + 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2214 if loop == 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2215 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2216 if a:jump == "continue"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2217 continue
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2218 elseif a:jump == "break"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2219 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2220 elseif a:jump == "return"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2221 return
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2222 elseif a:jump == "error"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2223 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2224 elseif a:jump == "interrupt"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2225 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2226 let dummy = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2227 elseif a:jump == "throw"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2228 throw "abc"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2229 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2230 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2231 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
2232 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
2233 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2234 elseif loop == 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2235 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
2236 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2237 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2238 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
2239 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2240
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2241 let sum = -R("continue", -8)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2242 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2243 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
2244 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2245 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
2246 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2247 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2248 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
2249 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2250 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2251 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2252 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2253 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
2254 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2255 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2256 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2257 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
2258 Xpath 'h'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2259 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2260 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2261 Xpath 'i'
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 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
2264 call assert_equal(sum, expected)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2265 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2266 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2267 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
2268 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2269 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2270 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2271
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2272 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2273 " 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
2274 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2275 " 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
2276 " :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
2277 " 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
2278 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2279
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2280 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
2281 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2282 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
2283 let loop = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2284 while loop < 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2285 let loop = loop + 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2286 if loop == 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2287 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2288 if a:jump == "continue"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2289 continue
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2290 elseif a:jump == "break"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2291 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2292 elseif a:jump == "finish"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2293 finish
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2294 elseif a:jump == "error"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2295 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2296 elseif a:jump == "interrupt"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2297 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2298 let dummy = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2299 elseif a:jump == "throw"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2300 throw "abc"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2301 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2302 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2303 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
2304 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
2305 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2306 elseif loop == 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2307 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
2308 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2309 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2310 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
2311 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2312
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2313 let scriptF = MakeScript("F")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2314 delfunction F
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2315
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2316 let g:jump = "continue"
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 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2319 let g:jump = "break"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2320 exec "source" scriptF
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2321 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2322 let g:jump = "finish"
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 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2325 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2326 let g:jump = "error"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2327 exec "source" scriptF
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2328 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2329 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2330 Xpath 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2331 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2332 let g:jump = "interrupt"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2333 exec "source" scriptF
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2334 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2335 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2336 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2337 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2338 let g:jump = "throw"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2339 exec "source" scriptF
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2340 Xpath 'h'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2341 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2342 Xpath 'i'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2343 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2344 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2345 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2346 unlet g:jump
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2347 call delete(scriptF)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2348 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2349 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2350 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
2351 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2352 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2353 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2354
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2355 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2356 " 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
2357 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2358 " 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
2359 " :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
2360 " 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
2361 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2362
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2363 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
2364 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2365 func E(jump)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2366 let loop = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2367 while loop < 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2368 let loop = loop + 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2369 if loop == 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2370 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2371 if a:jump == "continue"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2372 continue
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2373 elseif a:jump == "break"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2374 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2375 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
2376 return
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2377 elseif a:jump == "error"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2378 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2379 elseif a:jump == "interrupt"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2380 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2381 let dummy = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2382 elseif a:jump == "throw"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2383 throw "abc"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2384 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2385 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2386 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
2387 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2388 elseif loop == 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2389 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
2390 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2391 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2392 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
2393 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2394
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 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2397 call E("continue")
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 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2402 call E("break")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2403 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
2404 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2405 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2406 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2407 call E("return")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2408 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
2409 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2410 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2411 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2412 let g:jump = "finish"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2413 ExecAsScript E
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2414 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
2415 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2416 unlet g:jump
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 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2419 call E("error")
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 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2423 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2424 call E("interrupt")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2425 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
2426 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2427 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2428 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2429 call E("throw")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2430 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
2431 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2432 Xpath 'h'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2433 delfunction E
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2434 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2435 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2436 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2437 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2438 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2439 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2440 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2441 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
2442 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2443 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2444 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
2445 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2446 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2447 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2448
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2449 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2450 " 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
2451 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2452 " 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
2453 " :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
2454 " 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
2455 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2456
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2457 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
2458 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2459 func I(jump)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2460 let loop = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2461 while loop < 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2462 let loop = loop + 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2463 if loop == 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2464 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2465 if a:jump == "continue"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2466 continue
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2467 elseif a:jump == "break"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2468 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2469 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
2470 return
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2471 elseif a:jump == "error"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2472 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2473 elseif a:jump == "interrupt"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2474 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2475 let dummy = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2476 elseif a:jump == "throw"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2477 throw "abc"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2478 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2479 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2480 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2481 let dummy = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2482 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2483 elseif loop == 2
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 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2486 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2487 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
2488 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2489
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2490 try
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 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2493 call I("continue")
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 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2498 call I("break")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2499 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
2500 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2501 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2502 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2503 call I("return")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2504 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
2505 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2506 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2507 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2508 let g:jump = "finish"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2509 ExecAsScript I
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2510 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
2511 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2512 unlet g:jump
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 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2515 call I("error")
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 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2519 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2520 call I("interrupt")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2521 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
2522 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2523 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2524 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2525 call I("throw")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2526 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
2527 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2528 Xpath 'h'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2529 delfunction I
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 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2532 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2533 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2534 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2535 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2536 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2537 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
2538 catch /^Vim:Interrupt$/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2539 Xpath 'A'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2540 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2541 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2542 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2543 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
2544 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2545 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2546 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2547
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2548 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2549 " 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
2550 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2551 " 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
2552 " :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
2553 " 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
2554 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2555
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2556 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
2557 let test =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2558 func T(jump)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2559 let loop = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2560 while loop < 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2561 let loop = loop + 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2562 if loop == 1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2563 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2564 if a:jump == "continue"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2565 continue
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2566 elseif a:jump == "break"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2567 break
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2568 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
2569 return
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2570 elseif a:jump == "error"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2571 asdf
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2572 elseif a:jump == "interrupt"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2573 call interrupt()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2574 let dummy = 0
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2575 elseif a:jump == "throw"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2576 throw "abc"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2577 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2578 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2579 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
2580 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2581 elseif loop == 2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2582 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
2583 endif
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2584 endwhile
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2585 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
2586 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2587
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 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2590 call T("continue")
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 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2595 call T("break")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2596 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
2597 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2598 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2599 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2600 call T("return")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2601 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
2602 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2603 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2604 Xpath 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2605 let g:jump = "finish"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2606 ExecAsScript T
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2607 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
2608 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2609 unlet g:jump
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 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2612 call T("error")
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 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2616 Xpath 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2617 call T("interrupt")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2618 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
2619 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2620 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2621 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2622 call T("throw")
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2623 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
2624 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2625 Xpath 'h'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2626 delfunction T
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2627 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2628 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2629 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2630 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2631 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2632 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2633 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2634 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
2635 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2636 let verify =<< trim [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2637 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
2638 [CODE]
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2639 call RunInNewVim(test, verify)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2640 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2641
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2642 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2643 " 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
2644 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2645 " 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
2646 " 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
2647 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2648
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2649 func T49_C()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2650 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2651 Xpath 'a'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2652 throw "arrgh"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2653 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
2654 catch /arrgh/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2655 Xpath 'b'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2656 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2657 Xpath 'c'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2658 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2659
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2660 func T49_T1()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2661 XloopNEXT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2662 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2663 Xloop 'd'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2664 throw "arrgh"
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2665 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
2666 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2667 Xloop 'e'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2668 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2669 Xloop 'f'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2670 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2671
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2672 func T49_T2()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2673 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2674 Xpath 'g'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2675 call T49_T1()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2676 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
2677 finally
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2678 Xpath 'h'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2679 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2680 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
2681 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2682
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2683 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
2684 XpathINIT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2685 XloopINIT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2686 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2687 Xpath 'i'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2688 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
2689 Xpath 'j'
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 'k'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2696 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
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 'l'
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
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2704 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2705 Xpath 'm'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2706 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
2707 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
2708 catch /arrgh/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2709 Xpath 'n'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2710 catch /.*/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2711 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
2712 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2713 Xpath 'o'
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 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
2716 endfunc
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 " 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
2720 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2721 " 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
2722 " 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
2723 " clause.
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2724 "
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2725 " 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
2726 " 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
2727 "-------------------------------------------------------------------------------
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2728
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2729 func T50_F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2730 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2731 Xpath 'A'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2732 exec "source" g:scriptC
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2733 Xpath 'B'
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
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2738 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2739 Xpath 'C'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2740 exec "source" g:scriptT1
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2741 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
2742 catch /arrgh/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2743 Xpath 'D'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2744 catch /.*/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2745 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
2746 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2747 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2748
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2749 func Test_throw_across_script()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2750 XpathINIT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2751 XloopINIT
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2752 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
2753 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
2754 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
2755
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2756 try
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2757 Xpath 'E'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2758 call T50_F()
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2759 Xpath 'F'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2760 exec "source" scriptT2
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2761 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
2762 catch /arrgh/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2763 Xpath 'G'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2764 catch /.*/
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2765 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
2766 endtry
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2767 Xpath 'H'
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2768 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
2769
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2770 call delete(g:scriptC)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2771 call delete(g:scriptT1)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2772 call delete(scriptT2)
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2773 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
2774 endfunc
792398a9fe39 patch 8.2.1366: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21110
diff changeset
2775
18504
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
2776 "-------------------------------------------------------------------------------
21666
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2777 " Test 52: Uncaught exceptions {{{1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2778 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2779 " 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
2780 " 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
2781 " 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
2782 " displayed.
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2783 "-------------------------------------------------------------------------------
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2784
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2785 func Test_uncaught_exception_1()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2786 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2787
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2788 let test =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2789 Xpath 'a'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2790 throw "arrgh"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2791 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
2792 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2793 let verify =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2794 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
2795 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
2796 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2797 call RunInNewVim(test, verify)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2798 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2799
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2800 func Test_uncaught_exception_2()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2801 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2802
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2803 let test =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2804 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2805 Xpath 'a'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2806 throw "oops"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2807 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
2808 catch /arrgh/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2809 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
2810 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2811 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
2812 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2813 let verify =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2814 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
2815 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
2816 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2817 call RunInNewVim(test, verify)
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 func Test_uncaught_exception_3()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2821 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2822
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2823 let test =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2824 func T()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2825 Xpath 'c'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2826 throw "brrr"
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 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2829
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2830 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2831 Xpath 'a'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2832 throw "arrgh"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2833 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
2834 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2835 Xpath 'b'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2836 call T()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2837 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
2838 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2839 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
2840 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2841 let verify =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2842 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
2843 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
2844 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2845 call RunInNewVim(test, verify)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2846 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2847
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2848 func Test_uncaught_exception_4()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2849 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2850
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2851 let test =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2852 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2853 Xpath 'a'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2854 throw "arrgh"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2855 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
2856 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2857 Xpath 'b'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2858 throw "brrr"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2859 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
2860 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2861 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
2862 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2863 let verify =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2864 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
2865 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
2866 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2867 call RunInNewVim(test, verify)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2868 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2869
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2870 func Test_uncaught_exception_5()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2871 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2872
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2873 " 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
2874 " 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
2875 let test =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2876 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2877 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2878 Xpath 'a'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2879 call interrupt()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2880 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
2881 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2882 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
2883 catch /^Vim:Interrupt$/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2884 Xpath 'b'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2885 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2886 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2887 let verify =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2888 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
2889 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2890 call RunInNewVim(test, verify)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2891 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2892
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2893 func Test_uncaught_exception_6()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2894 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2895
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2896 let test =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2897 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2898 Xpath 'a'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2899 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
2900 catch /E15:/ " should not catch
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2901 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
2902 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2903 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
2904 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2905 let verify =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2906 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
2907 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
2908 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2909 call RunInNewVim(test, verify)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2910 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2911
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2912 func Test_uncaught_exception_7()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2913 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2914
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2915 let test =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2916 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2917 Xpath 'a'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2918 " error E108/E488; exception: E488
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2919 unlet novar #
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2920 catch /E108:/ " should not catch
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2921 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
2922 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2923 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
2924 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2925 let verify =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2926 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
2927 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
2928 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2929 call RunInNewVim(test, verify)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2930 endfunc
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 "-------------------------------------------------------------------------------
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2933 " 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
2934 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2935 " 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
2936 " should be given.
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2937 "-------------------------------------------------------------------------------
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 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
2940 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2941
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2942 " :endif without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2943 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2944 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2945 END
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
2946 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
2947 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
2948
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2949 " :endif without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2950 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2951 while 1
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 endwhile
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 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2962 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2963 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2964 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2965 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2966 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
2967
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2968 " :endif without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2969 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2970 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2971 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2972 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2973 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2974 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2975 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
2976
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2977 " :endif without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2978 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2979 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2980 throw "a"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2981 catch /a/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2982 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2983 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2984 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2985 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2986 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
2987
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2988 " :else without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2989 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2990 else
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2991 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2992 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2993 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
2994
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2995 " :else without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2996 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
2997 while 1
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 endwhile
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 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3008 else
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3009 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3010 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3011 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3012 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
3013
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3014 " :else without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3015 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3016 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3017 else
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3018 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3019 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3020 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3021 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
3022
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3023 " :else without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3024 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3025 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3026 throw "a"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3027 catch /a/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3028 else
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3029 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3030 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3031 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3032 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
3033
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3034 " :elseif without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3035 let code =<< trim END
28301
ebe0eeea501a patch 8.2.4676: test fails with different error
Bram Moolenaar <Bram@vim.org>
parents: 28171
diff changeset
3036 elseif 1
21666
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3037 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3038 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3039 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
3040
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3041 " :elseif without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3042 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3043 while 1
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 endwhile
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
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3053 finally
28301
ebe0eeea501a patch 8.2.4676: test fails with different error
Bram Moolenaar <Bram@vim.org>
parents: 28171
diff changeset
3054 elseif 1
21666
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3055 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3056 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3057 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3058 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
3059
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3060 " :elseif without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3061 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3062 try
28301
ebe0eeea501a patch 8.2.4676: test fails with different error
Bram Moolenaar <Bram@vim.org>
parents: 28171
diff changeset
3063 elseif 1
21666
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3064 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3065 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3066 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3067 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
3068
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3069 " :elseif without :if
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3070 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3071 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3072 throw "a"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3073 catch /a/
28301
ebe0eeea501a patch 8.2.4676: test fails with different error
Bram Moolenaar <Bram@vim.org>
parents: 28171
diff changeset
3074 elseif 1
21666
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3075 endtry
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')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3078 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
3079
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3080 " multiple :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 else
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')
28735
c428a4e53b9c patch 8.2.4892: test failures because of changed error messages
Bram Moolenaar <Bram@vim.org>
parents: 28301
diff changeset
3088 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
3089
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3090 " :elseif after :else
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3091 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3092 if 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3093 else
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3094 elseif 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3095 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3096 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3097 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3098 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
3099 endfunc
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 "-------------------------------------------------------------------------------
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3102 " 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
3103 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3104 " 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
3105 " should be given.
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3106 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3107 " 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
3108 " 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
3109 "-------------------------------------------------------------------------------
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 func Test_nested_while_error()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3112 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3113
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3114 " :endwhile without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3115 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3116 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3117 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3118 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3119 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
3120
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3121 " :endwhile without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3122 let code =<< trim END
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 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3126 END
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
3127 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
3128 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
3129
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3130 " Missing :endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3131 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3132 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3133 if 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3134 endwhile
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):E171: Missing :endif')
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 " :endwhile without :while
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 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3142 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3143 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3144 endtry
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):E588: :endwhile without :while')
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 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3153 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3154 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3155 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3156 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3157 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
3158
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3159 " Missing :endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3160 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3161 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3162 if 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 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3166 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3167 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3168 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
3169
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3170 " Missing :endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3171 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3172 while 1
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 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3175 if 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3176 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3177 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3178 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3179 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
3180
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3181 " :endwhile without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3182 let code =<< trim END
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 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3187 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3188 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
3189
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3190 " :endwhile without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3191 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3192 while 1
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 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3195 endtry
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 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3198 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3199 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
3200
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3201 " :endwhile without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3202 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3203 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3204 throw "a"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3205 catch /a/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3206 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3207 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3208 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3209 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3210 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
3211
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3212 " :endwhile without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3213 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3214 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3215 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3216 throw "a"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3217 catch /a/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3218 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3219 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3220 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3221 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3222 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3223 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
3224 endfunc
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 "-------------------------------------------------------------------------------
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3227 " 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
3228 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3229 " 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
3230 " error messages should be given.
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3231 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3232 " 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
3233 " 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
3234 "-------------------------------------------------------------------------------
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 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
3237 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3238
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3239 " :continue without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3240 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3241 continue
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3242 END
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
3243 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
3244 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
3245
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3246 " :continue without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3247 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3248 if 1
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 endif
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 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3259 continue
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3260 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3261 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3262 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3263 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
3264
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3265 " :continue without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3266 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3267 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3268 continue
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3269 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3270 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3271 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3272 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
3273
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3274 " :continue without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3275 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3276 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3277 throw "a"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3278 catch /a/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3279 continue
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3280 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3281 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3282 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3283 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
3284
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3285 " :break without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3286 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3287 break
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3288 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3289 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3290 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
3291
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3292 " :break without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3293 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3294 if 1
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 endif
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 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3305 break
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3306 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3307 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3308 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3309 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
3310
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3311 " :break without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3312 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3313 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3314 break
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3315 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3316 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3317 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3318 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
3319
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3320 " :break without :while
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3321 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3322 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3323 throw "a"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3324 catch /a/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3325 break
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3326 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3327 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3328 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3329 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
3330 endfunc
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 "-------------------------------------------------------------------------------
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3333 " 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
3334 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3335 " 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
3336 " should be given.
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3337 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3338 " 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
3339 " 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
3340 "-------------------------------------------------------------------------------
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 func Test_nested_endtry_error()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3343 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3344
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3345 " :endtry without :try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3346 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3347 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3348 END
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
3349 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
3350 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
3351
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3352 " :endtry without :try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3353 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3354 if 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3355 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3356 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3357 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3358 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3359 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
3360
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3361 " :endtry without :try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3362 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3363 while 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 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3366 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3367 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3368 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
3369
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3370 " Missing :endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3371 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3372 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3373 if 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3374 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3375 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3376 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3377 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
3378
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3379 " Missing :endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3380 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3381 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3382 while 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):E170: Missing :endwhile')
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 :endif
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 if 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):E171: Missing :endif')
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 :endwhile
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 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3402 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3403 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3404 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3405 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3406 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
3407
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3408 " Missing :endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3409 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3410 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3411 throw "a"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3412 catch /a/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3413 if 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3414 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3415 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3416 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3417 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
3418
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3419 " Missing :endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3420 let code =<< trim END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3421 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3422 throw "a"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3423 catch /a/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3424 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3425 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3426 END
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3427 call writefile(code, 'Xtest')
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3428 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
3429 endfunc
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 "-------------------------------------------------------------------------------
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3432 " 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
3433 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3434 " 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
3435 " 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
3436 " 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
3437 " 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
3438 " 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
3439 "-------------------------------------------------------------------------------
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 Test_user_exception_info()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3442 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3443
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3444 XpathINIT
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3445 XloopINIT
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3446
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3447 func FuncException()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3448 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 endfunc
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 FuncThrowpoint()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3452 let g:throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3453 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3454
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3455 let scriptException = MakeScript("FuncException")
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3456 let scriptThrowPoint = MakeScript("FuncThrowpoint")
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3457
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3458 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
3459 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
3460
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3461 func T(arg, line)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3462 if a:line == 2
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3463 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
3464 elseif a:line == 4
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3465 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
3466 elseif a:line == 6
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3467 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
3468 elseif a:line == 8
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3469 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
3470 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3471 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3472
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3473 func G(arg, line)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3474 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
3475 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3476
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3477 func F(arg, line)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3478 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
3479 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3480
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3481 let scriptT = MakeScript("T")
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3482 let scriptG = MakeScript("G", scriptT)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3483 let scriptF = MakeScript("F", scriptG)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3484
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3485 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3486 Xpath 'a'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3487 call F("oops", 2)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3488 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3489 Xpath 'b'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3490 let exception = v:exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3491 let throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3492 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
3493 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
3494 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
3495
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3496 exec "let exception = v:exception"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3497 exec "let throwpoint = v:throwpoint"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3498 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
3499 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
3500 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
3501
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3502 CmdException
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3503 CmdThrowpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3504 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
3505 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
3506 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
3507
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3508 call FuncException()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3509 call FuncThrowpoint()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3510 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
3511 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
3512 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
3513
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3514 exec "source" scriptException
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3515 exec "source" scriptThrowPoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3516 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
3517 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
3518 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
3519
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3520 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3521 Xpath 'c'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3522 call G("arrgh", 4)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3523 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3524 Xpath 'd'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3525 let exception = v:exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3526 let throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3527 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
3528 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
3529 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
3530
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3531 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3532 Xpath 'e'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3533 let g:arg = "autsch"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3534 let g:line = 6
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3535 exec "source" scriptF
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3536 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3537 Xpath 'f'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3538 let exception = v:exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3539 let throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3540 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
3541 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
3542 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
3543 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3544 Xpath 'g'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3545 let exception = v:exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3546 let throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3547 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
3548 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
3549 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
3550 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3551 Xpath 'h'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3552 let g:arg = "brrrr"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3553 let g:line = 8
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3554 exec "source" scriptG
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3555 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3556 Xpath 'i'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3557 let exception = v:exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3558 let throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3559 " 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
3560 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
3561 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
3562 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
3563 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3564 Xpath 'j'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3565 let exception = v:exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3566 let throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3567 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
3568 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
3569 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
3570 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3571 Xpath 'k'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3572 let exception = v:exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3573 let throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3574 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
3575 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
3576 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
3577 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3578 Xpath 'l'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3579 let exception = v:exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3580 let throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3581 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
3582 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
3583 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
3584 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3585 Xpath 'm'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3586 let exception = v:exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3587 let throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3588 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
3589 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
3590 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
3591 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3592 Xpath 'n'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3593 let exception = v:exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3594 let throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3595 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
3596 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
3597 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
3598 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3599 Xpath 'o'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3600 let exception = v:exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3601 let throwpoint = v:throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3602 call assert_equal("", v:exception)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3603 call assert_match('^$', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3604 call assert_match('^$', v:throwpoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3605 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3606
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3607 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
3608
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3609 unlet exception throwpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3610 delfunction FuncException
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3611 delfunction FuncThrowpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3612 call delete(scriptException)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3613 call delete(scriptThrowPoint)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3614 unlet scriptException scriptThrowPoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3615 delcommand CmdException
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3616 delcommand CmdThrowpoint
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3617 delfunction T
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3618 delfunction G
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3619 delfunction F
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3620 call delete(scriptT)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3621 call delete(scriptG)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3622 call delete(scriptF)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3623 unlet scriptT scriptG scriptF
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3624 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3625
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 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3628 " 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
3629 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3630 " 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
3631 " exceptions.
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3632 "-------------------------------------------------------------------------------
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3633
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
3634 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
3635 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3636
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3637 let test =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3638 func T(line)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3639 if a:line == 2
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3640 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
3641 elseif a:line == 4
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3642 call interrupt()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3643 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3644 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3645
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3646 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3647 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3648 Xpath 'a'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3649 call T(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 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3652 Xpath 'b'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3653 if v:exception !~ 'Vim(delfunction):'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3654 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
3655 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3656 if v:throwpoint !~ '\<T\>'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3657 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
3658 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3659 if v:throwpoint !~ '\<2\>'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3660 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
3661 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3662 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3663 Xpath 'c'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3664 if v:exception != ""
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3665 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
3666 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3667 if v:throwpoint != ""
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3668 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
3669 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3670 break
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3671 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3672 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3673
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3674 Xpath 'd'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3675 if v:exception != ""
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 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3678 if v:throwpoint != ""
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3679 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
3680 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3681
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3682 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3683 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3684 Xpath 'e'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3685 call T(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 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3688 Xpath 'f'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3689 if v:exception != 'Vim:Interrupt'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3690 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
3691 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3692 if v:throwpoint !~ 'function T'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3693 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
3694 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3695 if v:throwpoint !~ '\<4\>'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3696 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
3697 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3698 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3699 Xpath 'g'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3700 if v:exception != ""
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3701 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
3702 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3703 if v:throwpoint != ""
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3704 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
3705 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3706 break
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3707 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3708 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3709
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3710 Xpath 'h'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3711 if v:exception != ""
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3712 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
3713 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3714 if v:throwpoint != ""
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3715 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
3716 endif
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3717 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3718 let verify =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3719 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
3720 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3721 call RunInNewVim(test, verify)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3722 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3723
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
3724 "-------------------------------------------------------------------------------
21735
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 " 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
3727 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3728 " 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
3729 " 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
3730 " 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
3731 " caught.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3732 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3733 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
3734 CheckEnglish
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3735
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3736 let test =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3737 let sfile = expand("<sfile>")
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 "x1"
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 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3745 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3746 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3747 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3748
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3749 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3750 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3751 throw "x2"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3752 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3753 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3754 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3755 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3756 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3757 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3758 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3759 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3760 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3761 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3762
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3763 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3764 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3765 let errcaught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3766 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3767 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3768 throw "x3"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3769 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3770 let lnum = expand("<sflnum>")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3771 asdf
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3772 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3773 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3774 let errcaught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3775 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
3776 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
3777 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3778 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3779 call assert_equal(1, errcaught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3780 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3781 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3782 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3783 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3784 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3785
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3786 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3787
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3788 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3789 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3790 let intcaught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3791 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3792 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3793 throw "x4"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3794 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3795 let lnum = expand("<sflnum>")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3796 call interrupt()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3797 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3798 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3799 let intcaught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3800 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
3801 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
3802 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3803 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3804 call assert_equal(1, intcaught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3805 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3806 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3807 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3808 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3809 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3810
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3811 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3812
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3813 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3814 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3815 let errcaught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3816 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3817 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3818 if 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3819 let lnum = expand("<sflnum>")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3820 throw "x5"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3821 " missing endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3822 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3823 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
3824 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3825 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3826 let errcaught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3827 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
3828 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
3829 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3830 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3831 call assert_equal(1, errcaught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3832 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3833 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3834 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3835 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3836 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3837
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3838 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3839
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3840 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3841 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3842 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3843 throw "x6"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3844 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3845 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3846 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3847 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3848 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3849 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3850 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
3851 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3852 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3853 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3854
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3855 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3856 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3857 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3858 throw "x7"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3859 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3860 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3861 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3862 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3863 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3864 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3865 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
3866 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3867 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3868 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3869 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3870 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3871 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3872
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3873 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3874 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3875 let errcaught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3876 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3877 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3878 throw "x8"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3879 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3880 let lnum = expand("<sflnum>")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3881 asdf
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3882 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3883 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3884 let errcaught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3885 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
3886 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
3887 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3888 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3889 call assert_equal(1, errcaught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3890 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3891 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3892 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3893 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3894 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3895
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3896 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3897
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3898 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3899 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3900 let intcaught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3901 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3902 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3903 throw "x9"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3904 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3905 let lnum = expand("<sflnum>")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3906 call interrupt()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3907 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3908 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3909 let intcaught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3910 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
3911 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
3912 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3913 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3914 call assert_equal(1, intcaught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3915 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3916 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3917 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3918 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3919 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3920
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3921 Xpath 'e'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3922
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3923 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3924 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3925 let errcaught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3926 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3927 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3928 if 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3929 let lnum = expand("<sflnum>")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3930 throw "x10"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3931 " missing endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3932 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3933 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3934 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3935 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3936 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3937 let errcaught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3938 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
3939 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
3940 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3941 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3942 call assert_equal(1, errcaught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3943 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3944 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3945 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3946 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3947 call assert_equal('', v:throwpoint)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3948
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3949 Xpath 'f'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3950
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3951 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3952 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3953 let errcaught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3954 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3955 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3956 if 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3957 let lnum = expand("<sflnum>")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3958 throw "x11"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3959 " missing endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3960 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3961 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3962 let errcaught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3963 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
3964 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
3965 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3966 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3967 call assert_equal(1, errcaught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3968 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3969 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3970 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3971 call assert_equal('', v:exception)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3972 call assert_equal('', v:throwpoint)
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 Xpath 'g'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3975 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3976 let verify =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3977 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
3978 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3979 call RunInNewVim(test, verify)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3980 endfunc
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 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3984 " 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
3985 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3986 " 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
3987 " 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
3988 " 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
3989 " 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
3990 " command.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3991 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3992
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3993 func Test_rethrow_exception_1()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3994 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3995 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3996 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3997 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3998 throw "oops"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
3999 catch /oops/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4000 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4001 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
4002 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4003 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
4004 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4005 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
4006 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4007 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4008 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
4009 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4010 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
4011 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4012
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4013 func Test_rethrow_exception_2()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4014 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4015 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4016 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4017 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4018 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4019 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
4020 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
4021 catch /^Vim(write):/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4022 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4023 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
4024 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4025 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
4026 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4027 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4028 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4029 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4030 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
4031 let caught = caught + 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4032 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4033 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
4034 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4035 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4036 call assert_equal(2, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4037 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4038 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
4039 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4040
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4041 func Test_rethrow_exception_3()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4042 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4043 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4044 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4045 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4046 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4047 asdf
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4048 catch /^Vim/ " catch error exception
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4049 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4050 " 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
4051 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
4052 echoerr value
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4053 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4054 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
4055 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4056 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4057 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4058 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4059 catch /^Vim(echoerr):/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4060 let caught = caught + 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4061 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
4062 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4063 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
4064 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4065 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4066 call assert_equal(2, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4067 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4068 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
4069 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4070
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4071 func Test_rethrow_exception_3()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4072 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4073 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4074 let errcaught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4075 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4076 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4077 let intcaught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4078 call interrupt()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4079 catch /^Vim:/ " catch interrupt exception
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4080 let intcaught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4081 " 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
4082 echoerr substitute(v:exception, '^Vim\((.*)\)\=:', '', "")
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4083 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4084 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
4085 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4086 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4087 call assert_equal(1, intcaught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4088 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4089 catch /^Vim(echoerr):/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4090 let errcaught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4091 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
4092 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4093 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4094 call assert_equal(1, errcaught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4095 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4096 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
4097 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4098
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4099 "-------------------------------------------------------------------------------
21666
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4100 " 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
4101 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4102 " 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
4103 " 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
4104 " "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
4105 " 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
4106 " 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
4107 " 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
4108 " 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
4109 " 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
4110 "-------------------------------------------------------------------------------
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4111
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4112 func Test_catch_intr_exception()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4113 let test =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4114 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4115 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4116 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4117 Xpath 'a'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4118 call interrupt()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4119 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
4120 catch /^Vim:Interrupt$/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4121 Xpath 'b'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4122 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4123 Xpath 'c'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4124 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4125 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4126 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
4127 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4128 Xpath 'd'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4129 break
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4130 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4131 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4132
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4133 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4134 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4135 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4136 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4137 Xpath 'e'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4138 asdf
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4139 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
4140 catch /do_not_catch/
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 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4143 Xpath 'f'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4144 call interrupt()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4145 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
4146 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4147 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
4148 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4149 Xpath 'g'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4150 call interrupt()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4151 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
4152 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4153 catch /^Vim:Interrupt$/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4154 Xpath 'h'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4155 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4156 Xpath 'i'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4157 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4158 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4159 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
4160 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4161 Xpath 'j'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4162 break
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4163 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4164 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4165
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4166 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4167 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4168 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4169 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4170 Xpath 'k'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4171 throw "x"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4172 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
4173 catch /do_not_catch/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4174 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
4175 catch /x/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4176 Xpath 'l'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4177 call interrupt()
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 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4180 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
4181 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4182 catch /^Vim:Interrupt$/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4183 Xpath 'm'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4184 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4185 Xpath 'n'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4186 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4187 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4188 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
4189 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4190 Xpath 'o'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4191 break
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4192 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4193 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4194
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4195 while 1
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4196 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4197 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4198 Xpath 'p'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4199 call interrupt()
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 catch /do_not_catch/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4202 call interrupt()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4203 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
4204 catch /^Vim:Interrupt$/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4205 Xpath 'q'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4206 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4207 Xpath 'r'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4208 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4209 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4210 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
4211 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4212 Xpath 's'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4213 break
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4214 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4215 endwhile
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4216
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4217 Xpath 't'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4218 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4219 let verify =<< trim [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4220 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
4221 [CODE]
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4222 call RunInNewVim(test, verify)
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4223 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4224
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4225 "-------------------------------------------------------------------------------
21735
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4226 " 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
4227 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4228 " 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
4229 " 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
4230 " 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
4231 " 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
4232 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4233
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4234 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
4235 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4236 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4237 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4238 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4239 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4240 unlet novar
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4241 catch /^Vim(unlet):/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4242 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4243 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4244 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
4245 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4246 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4247 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4248 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
4249 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4250 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4251 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
4252 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4253 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4254 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4255 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4256 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
4257 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4258 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
4259 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4260
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4261 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
4262 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4263 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4264 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4265 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4266 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4267 throw novar " error in :throw
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4268 catch /^Vim(throw):/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4269 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4270 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4271 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
4272 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4273 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4274 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4275 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
4276 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4277 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4278 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
4279 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4280 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4281 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4282 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4283 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
4284 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4285 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
4286 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4287
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4288 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
4289 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4290 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4291 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4292 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4293 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4294 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
4295 catch /^Vim(throw):/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4296 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4297 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4298 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
4299 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4300 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4301 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4302 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
4303 \ v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4304 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4305 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4306 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
4307 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4308 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4309 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4310 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4311 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
4312 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4313 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
4314 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4315
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4316 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
4317 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4318 func F()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4319 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4320 " Missing :endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4321 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4322
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4323 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4324 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4325 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4326 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4327 call F()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4328 catch /^Vim(endfunction):/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4329 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4330 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4331 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
4332 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4333 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4334 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4335 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
4336 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4337 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4338 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
4339 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4340 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4341 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4342 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4343 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
4344 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4345 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
4346 delfunc F
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4347 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4348
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4349 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
4350 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4351 func F()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4352 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4353 " Missing :endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4354 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4355
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4356 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4357 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4358 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4359 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4360 ExecAsScript F
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4361 catch /^Vim:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4362 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4363 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4364 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
4365 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4366 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4367 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4368 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
4369 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4370 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4371 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
4372 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4373 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4374 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4375 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4376 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
4377 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4378 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
4379 delfunc F
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4380 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4381
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4382 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
4383 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4384 func G()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4385 call G()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4386 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4387
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4388 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4389 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4390 let mfd_save = &mfd
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4391 set mfd=3
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4392 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4393 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4394 call G()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4395 catch /^Vim(call):/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4396 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4397 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4398 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
4399 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4400 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4401 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4402 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
4403 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4404 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4405 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
4406 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4407 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4408 let &mfd = mfd_save
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4409 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4410 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4411 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
4412 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4413 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
4414 delfunc G
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4415 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4416
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4417 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
4418 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4419 func H()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4420 return H()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4421 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4422
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4423 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4424 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4425 let mfd_save = &mfd
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4426 set mfd=3
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4427 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4428 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4429 call H()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4430 catch /^Vim(return):/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4431 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4432 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4433 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
4434 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4435 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4436 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4437 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
4438 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4439 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4440 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
4441 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4442 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4443 let &mfd = mfd_save
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4444 break " discard error for $VIMNOERRTHROW
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4445 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4446 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
4447 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4448
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4449 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
4450 delfunc H
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4451 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4452
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4453 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4454 " 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
4455 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4456 " 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
4457 " 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
4458 " 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
4459 " 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
4460 " 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
4461 " 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
4462 " 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
4463 " script line.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4464 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4465 " 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
4466 " 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
4467 " on error.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4468 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4469 " 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
4470 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4471
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4472 func Test_silent_exception()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4473 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4474 XloopINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4475 let g:taken = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4476
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4477 func S(n) abort
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4478 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4479 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
4480 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4481 exec "asdf" . a:n
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4482
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4483 " Check that ":silent!" continues:
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4484 Xloop 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4485
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4486 " 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
4487 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
4488 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4489
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4490 func Foo()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4491 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4492 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4493 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4494 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4495 " This is not silent:
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4496 call S(3)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4497 catch /^Vim:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4498 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4499 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4500 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
4501 silent! call S(4)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4502 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4503 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4504 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4505 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
4506 silent! call S(5)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4507 " 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
4508 " 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
4509 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4510 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4511 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4512 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
4513 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4514 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4515 " 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
4516 silent! call S(6)
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 func Bar()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4520 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4521 silent! call S(2)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4522 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
4523 silent! call S(8)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4524 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
4525 " 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
4526 call S(9)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4527 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4528
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4529 silent! call S(1)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4530 silent! call Bar()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4531 silent! call S(10)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4532
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4533 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
4534
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4535 augroup TMP
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4536 au!
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4537 autocmd BufWritePost * Xpath 'd'
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
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4540 Xpath 'e'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4541 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
4542 Xpath 'f'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4543
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4544 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
4545
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4546 augroup TMP
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4547 au!
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4548 augroup END
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4549 augroup! TMP
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4550 delfunction S
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4551 delfunction Foo
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4552 delfunction Bar
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4553 endfunc
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 " 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
4557 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4558 " 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
4559 " 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
4560 " 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
4561 " 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
4562 " 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
4563 " has not been caught.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4564 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4565
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4566 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
4567 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4568 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4569 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4570 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4571 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4572 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4573 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4574 if 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4575 " Missing :endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4576 endwhile " throw error exception
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4577 catch /^Vim(/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4578 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4579 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4580 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4581 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4582 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4583 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4584 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4585 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
4586 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4587 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4588 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4589 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4590 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
4591 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4592 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
4593 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4594
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4595 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
4596 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4597 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4598 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4599 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4600 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4601 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4602 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4603 if 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4604 " Missing :endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4605 catch /.*/ " throw error exception
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4606 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
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 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4610 catch /^Vim(/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4611 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4612 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4613 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4614 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4615 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4616 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4617 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4618 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
4619 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4620 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4621 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4622 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4623 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
4624 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4625 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
4626 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4627
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4628 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
4629 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4630 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4631 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4632 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4633 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4634 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4635 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4636 call interrupt()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4637 catch /do_not_catch/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4638 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
4639 if 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4640 " Missing :endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4641 catch /.*/ " throw error exception
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4642 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
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 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4646 catch /^Vim(/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4647 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4648 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4649 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4650 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4651 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4652 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4653 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4654 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
4655 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4656 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4657 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4658 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4659 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
4660 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4661 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
4662 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4663
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4664 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
4665 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4666 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4667 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4668 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4669 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4670 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4671 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4672 throw "x"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4673 catch /do_not_catch/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4674 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
4675 if 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4676 " Missing :endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4677 catch /x/ " throw error exception
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4678 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
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 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4682 catch /^Vim(/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4683 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4684 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4685 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4686 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4687 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4688 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4689 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4690 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
4691 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4692 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4693 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4694 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4695 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
4696 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4697 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
4698 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4699
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4700 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
4701 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4702 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4703 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4704 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4705 let caught = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4706 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4707 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
4708 if 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4709 " Missing :endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4710 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
4711 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
4712 catch /^Vim(endif):/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4713 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4714 let caught = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4715 catch /^Vim(/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4716 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
4717 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4718 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4719 call assert_equal(1, caught)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4720 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4721 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4722 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
4723 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4724 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4725 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4726 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4727 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
4728 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4729 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
4730 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4731
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4732 "-------------------------------------------------------------------------------
21666
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4733 " 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
4734 "
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4735 " 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
4736 " 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
4737 " 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
4738 "-------------------------------------------------------------------------------
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4739
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4740 func Test_catch_pattern_error()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4741 CheckEnglish
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4742 XpathINIT
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4743
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4744 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4745 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4746 Xpath 'a'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4747 throw "oops"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4748 catch /^oops$/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4749 Xpath 'b'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4750 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
4751 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
4752 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4753 Xpath 'c'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4754 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4755 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
4756 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4757 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
4758
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4759 XpathINIT
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4760 func F()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4761 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4762 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4763 try
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4764 Xpath 'a'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4765 throw "ab"
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4766 catch /abc/ " does not catch
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 /\)/ " error; discards exception
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4769 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
4770 catch /.*/ " not checked
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4771 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
4772 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4773 Xpath 'b'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4774 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4775 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
4776 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
4777 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
4778 catch /^Vim(catch):/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4779 Xpath 'c'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4780 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
4781 finally
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4782 Xpath 'd'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4783 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4784 Xpath 'e'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4785 catch /.*/
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4786 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
4787 endtry
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4788 Xpath 'f'
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4789 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4790
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4791 call F()
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4792 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
4793
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4794 delfunc F
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4795 endfunc
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4796
97b887aecd4a patch 8.2.1383: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21632
diff changeset
4797 "-------------------------------------------------------------------------------
21735
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4798 " 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
4799 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4800 " 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
4801 " 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
4802 " 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
4803 " 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
4804 " 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
4805 " 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
4806 " lines in the range.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4807 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4808
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4809 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
4810 let test =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4811 let file = tempname()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4812 exec "edit" file
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4813 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
4814 let taken = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4815 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
4816
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4817 func F(reason, n) abort
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4818 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
4819 \ 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
4820 \ "(" .. line(".") .. ")"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4821
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4822 if a:reason == "error"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4823 asdf
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4824 elseif a:reason == "interrupt"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4825 call interrupt()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4826 elseif a:reason == "throw"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4827 throw "xyz"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4828 elseif a:reason == "aborting error"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4829 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4830 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
4831 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4832 bwipeout!
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4833 call delete(g:file)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4834 asdf
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4835 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4836 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4837 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4838
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4839 func G(reason, n)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4840 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
4841 \ 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
4842 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
4843 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4844
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4845 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4846 call G("error", 1)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4847 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4848 Xpath 'b'
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("error", 2)
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 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4853 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4854 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4855 call G("interrupt", 3)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4856 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
4857 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4858 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4859 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4860 call G("throw", 4)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4861 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
4862 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4863 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4864 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4865 catch /xyz/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4866 Xpath 'e'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4867 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4868 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
4869 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4870 Xpath 'f'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4871 call G("aborting error", 5)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4872 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
4873 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4874 let verify =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4875 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
4876 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4877 call RunInNewVim(test, verify)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4878 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4879
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4880 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4881 " 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
4882 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4883 " 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
4884 " 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
4885 " 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
4886 " caller.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4887 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4888
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4889 func THROW(x, n)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4890 if a:n == 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4891 Xpath 'A'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4892 elseif a:n == 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4893 Xpath 'B'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4894 elseif a:n == 3
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4895 Xpath 'C'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4896 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4897 throw a:x
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4898 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4899
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4900 func NAME(x, n)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4901 if a:n == 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4902 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
4903 elseif a:n == 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4904 Xpath 'D'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4905 elseif a:n == 3
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4906 Xpath 'E'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4907 elseif a:n == 4
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4908 Xpath 'F'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4909 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4910 return a:x
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4911 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4912
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4913 func ARG(x, n)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4914 if a:n == 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4915 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
4916 elseif a:n == 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4917 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
4918 elseif a:n == 3
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4919 Xpath 'G'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4920 elseif a:n == 4
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4921 Xpath 'I'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4922 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4923 return a:x
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4924 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4925
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4926 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
4927 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4928
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4929 func F(x, n)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4930 if a:n == 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4931 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
4932 elseif a:n == 4
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4933 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4934 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4935 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4936
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4937 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4938 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4939 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4940
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4941 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4942 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4943 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4944 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
4945 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
4946 catch /^name$/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4947 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4948 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4949 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
4950 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4951 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4952 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4953 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4954 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4955 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4956
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4957 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4958 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4959 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4960 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
4961 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
4962 catch /^arg$/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4963 Xpath 'e'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4964 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4965 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
4966 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4967 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4968 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4969 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4970 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4971 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4972
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4973 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4974 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4975 Xpath 'f'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4976 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
4977 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
4978 catch /^call$/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4979 Xpath 'g'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4980 catch /^0$/ " default return value
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4981 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
4982 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4983 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
4984 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4985 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4986 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4987 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4988 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4989 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4990
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4991 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4992 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4993 Xpath 'h'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4994 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
4995 Xpath 'i'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4996 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4997 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
4998 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
4999 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5000 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5001 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5002 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5003 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5004
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5005 catch /^0$/ " default return value
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5006 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
5007 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5008 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
5009 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5010 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5011 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5012 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5013 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5014 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5015
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5016 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
5017 delfunction F
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5018 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5019
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 " 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
5022 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5023 " 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
5024 " 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
5025 " 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
5026 " 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
5027 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5028 " 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
5029 " previous test.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5030 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5031
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5032 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
5033 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5034
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5035 func F(x, n)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5036 if a:n == 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5037 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
5038 elseif a:n == 4
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5039 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5040 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5041 return a:x
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5042 endfunction
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5043
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5044 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5045 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5046 let error = 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5047 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5048
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5049 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5050 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5051 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5052 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
5053 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
5054 catch /^name$/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5055 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5056 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5057 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
5058 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5059 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5060 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5061 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5062 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5063 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5064 call assert_true(!exists('var1'))
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5065
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5066 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5067 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5068 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5069 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
5070 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
5071 catch /^arg$/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5072 Xpath 'e'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5073 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5074 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
5075 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5076 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5077 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5078 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5079 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5080 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5081 call assert_true(!exists('var2'))
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5082
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5083 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5084 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5085 Xpath 'f'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5086 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
5087 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
5088 catch /^call$/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5089 Xpath 'g'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5090 catch /^0$/ " default return value
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5091 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
5092 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5093 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
5094 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5095 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5096 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5097 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5098 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5099 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5100 call assert_true(!exists('var3'))
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5101
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5102 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5103 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5104 Xpath 'h'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5105 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
5106 Xpath 'i'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5107 catch /.*/
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 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5110 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5111 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5112 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5113 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5114 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5115 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
5116
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5117 catch /^0$/ " default return value
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5118 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
5119 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5120 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
5121 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5122 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5123 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5124 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5125 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5126
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5127 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
5128 delfunc F
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5129 endfunc
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 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5132 " 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
5133 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5134 " 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
5135 " 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
5136 " 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
5137 " 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
5138 " 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
5139 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5140
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5141 func Test_expr_eval_error()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5142 let test =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5143 let taken = ""
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 ERR(n)
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 .. "E" .. a:n
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5147 asdf
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5148 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5149
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5150 func ERRabort(n) abort
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5151 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
5152 asdf
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5153 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
5154
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5155 func WRAP(n, arg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5156 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
5157 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
5158 return arg
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 INT(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 .. "I" .. a:n
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5163 call interrupt()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5164 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5165
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5166 func THR(n)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5167 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
5168 throw "should not be caught"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5169 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5170
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5171 func CONT(n)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5172 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
5173 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5174
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5175 func MSG(n)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5176 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
5177 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
5178 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
5179 call assert_match(msgptn, errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5180 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5181 let g:saved_errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5182 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5183
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5184 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5185
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5186 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5187 let t = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5188 while t <= 9
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5189 Xloop 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5190 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5191 if t == 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5192 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
5193 elseif t == 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5194 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
5195 elseif t == 3
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5196 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
5197 elseif t == 4
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5198 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
5199 elseif t == 5
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5200 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
5201 endfunction
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5202 elseif t == 6
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5203 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
5204 elseif t == 7
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5205 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
5206 elseif t == 8
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5207 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
5208 elseif t == 9
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5209 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
5210 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5211 catch /asdf/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5212 " 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
5213 " 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
5214 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
5215 catch /^Vim\((\a\+)\)\=:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5216 " 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
5217 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5218 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5219 call MSG(t)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5220 let t = t + 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5221 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5222 continue " discard an aborting error
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5223 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5224 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5225 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5226 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
5227 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5228
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5229 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5230 let t = 10
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5231 while t <= 18
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5232 Xloop 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5233 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5234 if t == 10
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5235 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
5236 elseif t == 11
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5237 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
5238 elseif t == 12
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5239 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
5240 elseif t == 13
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5241 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
5242 elseif t == 14
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5243 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
5244 endfunction
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5245 elseif t == 15
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5246 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
5247 elseif t == 16
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5248 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
5249 elseif t == 17
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5250 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
5251 elseif t == 18
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5252 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
5253 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5254 catch /^Vim\((\a\+)\)\=:\(Interrupt\)\@!/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5255 " 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
5256 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
5257 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5258 call MSG(t)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5259 let t = t + 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5260 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5261 continue " discard interrupt
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5262 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5263 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5264 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5265 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
5266 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5267
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5268 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5269 let t = 19
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5270 while t <= 27
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5271 Xloop 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5272 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5273 if t == 19
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5274 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
5275 elseif t == 20
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5276 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
5277 elseif t == 21
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5278 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
5279 elseif t == 22
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5280 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
5281 elseif t == 23
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5282 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
5283 endfunction
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5284 elseif t == 24
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5285 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
5286 elseif t == 25
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5287 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
5288 elseif t == 26
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5289 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
5290 elseif t == 27
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5291 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
5292 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5293 catch /^Vim\((\a\+)\)\=:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5294 " 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
5295 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
5296 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5297 call MSG(t)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5298 let t = t + 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5299 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5300 continue " discard exception
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5301 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5302 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5303 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5304 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
5305 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5306
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5307 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
5308 call MSG(28)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5309 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
5310 call MSG(29)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5311 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
5312 call MSG(30)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5313 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
5314 call MSG(31)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5315 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
5316 endfunction
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5317 call MSG(32)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5318 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
5319 call MSG(33)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5320 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
5321 call MSG(34)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5322 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
5323 call MSG(35)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5324 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
5325 call MSG(36)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5326
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5327 let saved_errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5328
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5329 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
5330 call MSG(37)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5331 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
5332 call MSG(38)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5333 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
5334 call MSG(39)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5335 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
5336 call MSG(40)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5337 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
5338 endfunction
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5339 call MSG(41)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5340 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
5341 call MSG(42)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5342 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
5343 call MSG(43)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5344 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
5345 call MSG(44)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5346 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
5347 call MSG(45)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5348 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5349
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5350 let expected = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5351 \ .. "E1M1E2M2E3M3E4M4E5M5E6M6E7M7E8M8E9M9"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5352 \ .. "I10M10I11M11I12M12I13M13I14M14I15M15I16M16I17M17I18M18"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5353 \ .. "T19M19T20M20T21M21T22M22T23M23T24M24T25M25T26M26T27M27"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5354 \ .. "E28C28M28E29C29M29E30C30M30E31C31M31E32C32M32E33C33M33"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5355 \ .. "E34C34M34E35C35M35E36C36M36"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5356 \ .. "A37W37C37M37A38W38C38M38A39W39C39M39A40W40C40M40A41W41C41M41"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5357 \ .. "A42W42C42M42A43W43C43M43A44W44C44M44A45C45M45"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5358 call assert_equal(expected, taken)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5359 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5360 let verify =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5361 let expected = "a1a2a3a4a5a6a7a8a9"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5362 \ .. "b10b11b12b13b14b15b16b17b18"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5363 \ .. "c19c20c21c22c23c24c25c26c27d"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5364 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
5365 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5366 call RunInNewVim(test, verify)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5367 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5368
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5369 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5370 " 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
5371 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5372 " 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
5373 " 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
5374 " 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
5375 " 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
5376 " 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
5377 " ":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
5378 " 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
5379 " called and deleted.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5380 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5381 func Test_brace_expr_error()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5382 let test =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5383 func ERR() abort
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5384 Xloop 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5385 asdf
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5386 endfunc " returns -1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5387
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5388 func OK()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5389 Xloop 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5390 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5391 return 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5392 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5393
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5394 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5395
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5396 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5397 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
5398 " F0 should be defined.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5399 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
5400 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5401 else
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5402 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
5403 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5404 endfunction
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 Xpath 'e'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5409 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
5410 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5411 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5412
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5413 Xpath 'f'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5414 delfunction F{1 + ERR() + OK()}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5415 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5416 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5417
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5418 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5419 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5420 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5421 Xpath 'g'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5422 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
5423 " 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
5424 " skipped.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5425 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
5426 " 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
5427 " 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
5428 " 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
5429 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5430 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
5431 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5432 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5433 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
5434 endfunction
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5435
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5436 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
5437 catch /asdf/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5438 " 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
5439 " skipped.
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5440 Xpath 'h'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5441 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5442 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
5443 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5444 Xpath 'i'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5445 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5446 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
5447 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5448 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5449 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
5450 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5451 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5452 let verify =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5453 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
5454 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5455 call RunInNewVim(test, verify)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5456 endfunc
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 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5459 " 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
5460 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5461 " 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
5462 " 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
5463 " evaluation is aborted.
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 Test_expr_eval_error_msg()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5466 CheckEnglish
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5467
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5468 let test =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5469 let taken = ""
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 F(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 . "F" . 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 func MSG(n, enr, emsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5476 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
5477 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
5478 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
5479 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5480
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5481 func CONT(n)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5482 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
5483 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5484
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5485 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5486 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5487 let t = 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5488 while t <= 14
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5489 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
5490 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5491 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5492 if t == 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5493 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
5494 elseif t == 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5495 let v{novar + CONT(t)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5496 elseif t == 3
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5497 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
5498 elseif t == 4
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5499 unlet v{novar + CONT(t)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5500 elseif t == 5
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5501 function F{novar + CONT(t)}()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5502 endfunction
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5503 elseif t == 6
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5504 function 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 == 7
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5506 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
5507 elseif t == 8
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5508 delfunction F{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 == 9
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5510 echo novar + CONT(t)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5511 elseif t == 10
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5512 echo v{novar + CONT(t)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5513 elseif t == 11
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5514 echo F{novar + CONT(t)}
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5515 elseif t == 12
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5516 let var = novar + CONT(t)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5517 elseif t == 13
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5518 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
5519 elseif t == 14
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5520 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
5521 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5522 catch /^Vim\((\a\+)\)\=:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5523 Xloop 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5524 " 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
5525 " 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
5526 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
5527 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5528 Xloop 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5529 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
5530 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
5531 else
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5532 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
5533 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5534 let t = t + 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5535 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5536 continue " discard an aborting error
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5537 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5538 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5539 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5540 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
5541 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5542
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5543 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
5544 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5545 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
5546 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5547 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5548 execute "let var = " . a:expr
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5549 catch /^Vim\((\a\+)\)\=:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5550 Xloop 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5551 " 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
5552 " 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
5553 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
5554 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5555 Xloop 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5556 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
5557 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5558 " Discard an aborting error:
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5559 return
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5560 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5561 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5562 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
5563 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5564 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5565
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5566 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
5567 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
5568 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
5569 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
5570 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
5571 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
5572 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
5573 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
5574 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
5575 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
5576 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
5577 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
5578 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
5579
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5580 let expected = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5581 \ .. "T1M1T2M2T3M3T4M4T5M5T6M6T7M7T8M8T9M9T10M10T11M11T12M12T13M13T14M14"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5582 \ .. "T15M15T16M16T17M17T18M18T19M19T20M20T21M21T22M22T23M23T24M24T25M25"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5583 \ .. "T26M26T27M27"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5584
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5585 call assert_equal(expected, taken)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5586 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5587 let verify =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5588 let expected = "a1b1a2b2a3b3a4b4a5b5a6b6a7b7a8b8a9b9a10b10a11b11a12b12"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5589 \ .. "a13b13a14b14c15d15c16d16c17d17c18d18c19d19c20d20"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5590 \ .. "c21d21c22d22c23d23c24d24c25d25c26d26c27d27"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5591 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
5592 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5593 call RunInNewVim(test, verify)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5594 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5595
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 " 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
5598 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5599 " 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
5600 " 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
5601 " 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
5602 " 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
5603 " 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
5604 " 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
5605 " "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
5606 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5607 " 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
5608 " 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
5609 " 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
5610 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5611 func Test_throw_multi_error()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5612 CheckEnglish
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5613
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5614 let test =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5615 func NEXT(cmd)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5616 exec a:cmd . " | Xloop 'a'"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5617 endfun
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 NEXT('echo novar') " (checks nextcmd)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5620 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5621 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
5622 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5623 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
5624 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5625 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
5626 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5627 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
5628
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5629 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
5630 XpathINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5631 XloopINIT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5632
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5633 func EXEC(cmd)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5634 exec a:cmd
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5635 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5636
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5637 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5638 while 1 " dummy loop
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5639 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5640 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5641 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
5642 catch /^Vim\((\a\+)\)\=:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5643 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5644 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
5645 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5646 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5647 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5648 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5649 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5650 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5651
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5652 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5653 let cmd = "let"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5654 while cmd != ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5655 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5656 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5657 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
5658 catch /^Vim\((\a\+)\)\=:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5659 Xloop 'e'
25615
b0f82974ddf4 patch 8.2.3344: vimscript test fails
Bram Moolenaar <Bram@vim.org>
parents: 24958
diff changeset
5660 if cmd =~ 'unlet'
b0f82974ddf4 patch 8.2.3344: vimscript test fails
Bram Moolenaar <Bram@vim.org>
parents: 24958
diff changeset
5661 " TODO: should get error for 'novar'
b0f82974ddf4 patch 8.2.3344: vimscript test fails
Bram Moolenaar <Bram@vim.org>
parents: 24958
diff changeset
5662 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
5663 else
b0f82974ddf4 patch 8.2.3344: vimscript test fails
Bram Moolenaar <Bram@vim.org>
parents: 24958
diff changeset
5664 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
5665 endif
21735
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5666 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5667 Xloop 'f'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5668 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5669 if cmd == "let"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5670 let cmd = "unlet"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5671 else
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5672 let cmd = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5673 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5674 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5675 continue
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5676 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5677 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5678
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5679 Xpath 'g'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5680 let cmd = "let"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5681 while cmd != ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5682 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5683 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5684 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
5685 catch /^Vim\((\a\+)\)\=:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5686 Xloop 'h'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5687 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
5688 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5689 Xloop 'i'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5690 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5691 if cmd == "let"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5692 let cmd = "unlet"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5693 else
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5694 let cmd = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5695 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5696 XloopNEXT
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5697 continue
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5698 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5699 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5700 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5701 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
5702 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5703 Xpath 'j'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5704 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5705 let verify =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5706 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
5707 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5708 call RunInNewVim(test, verify)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5709 endfunc
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 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5712 " 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
5713 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5714 " 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
5715 " :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
5716 " 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
5717 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5718 func Test_if_syntax_error()
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5719 CheckEnglish
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5720
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5721 let test =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5722 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5723 if 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5724 else
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5725 elseif 1 ||| 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5726 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5727 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5728 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
5729
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5730 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5731 if 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5732 else
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5733 elseif 1 ||| 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5734 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5735 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5736 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
5737
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5738 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5739 elseif 1 ||| 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5740 Xpath 'c'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5741 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
5742
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 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5745 elseif 1 ||| 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5746 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5747 Xpath 'd'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5748 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
5749
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5750 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5751 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5752 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5753 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5754 if 0
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5755 else
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5756 elseif 1 ||| 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5757 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5758 catch /^Vim\((\a\+)\)\=:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5759 Xpath 'e'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5760 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
5761 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5762 Xpath 'f'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5763 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5764 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5765 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5766 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
5767 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5768 Xpath 'g'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5769 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5770 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5771 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5772
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5773 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5774 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5775 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5776 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5777 if 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5778 else
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5779 elseif 1 ||| 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5780 endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5781 catch /^Vim\((\a\+)\)\=:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5782 Xpath 'h'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5783 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
5784 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5785 Xpath 'i'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5786 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5787 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5788 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5789 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
5790 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5791 Xpath 'j'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5792 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5793 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5794 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5795
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5796 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5797 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5798 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5799 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5800 elseif 1 ||| 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5801 catch /^Vim\((\a\+)\)\=:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5802 Xpath 'k'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5803 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
5804 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5805 Xpath 'l'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5806 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5807 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5808 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5809 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
5810 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5811 Xpath 'm'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5812 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5813 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5814 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5815
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5816 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5817 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5818 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5819 let v:errmsg = ""
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5820 while 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5821 elseif 1 ||| 2
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5822 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5823 catch /^Vim\((\a\+)\)\=:/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5824 Xpath 'n'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5825 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
5826 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5827 Xpath 'o'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5828 call assert_equal("", v:errmsg)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5829 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5830 catch /.*/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5831 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
5832 finally
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5833 Xpath 'p'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5834 break
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5835 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5836 endwhile
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5837 Xpath 'q'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5838 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5839 let verify =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5840 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
5841 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5842 call RunInNewVim(test, verify)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5843 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5844
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5845 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5846 " 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
5847 "
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5848 " 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
5849 " :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
5850 " 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
5851 "-------------------------------------------------------------------------------
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5852
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5853 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
5854 let test =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5855 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5856 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5857 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5858 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5859 throw "arrgh"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5860 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
5861 if 1
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5862 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
5863 " error after :throw: missing :endif
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5864 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5865 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
5866 catch /arrgh/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5867 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
5868 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5869 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
5870 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5871 let verify =<< trim [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5872 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
5873 [CODE]
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5874 call RunInNewVim(test, verify)
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5875 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5876
21781
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5877 " 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
5878 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
5879 XpathINIT
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5880 let lines =<< trim [CODE]
21735
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5881 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5882 Xpath 'a'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5883 try
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5884 Xpath 'b'
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5885 throw "arrgh"
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5886 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
5887 endtry " interrupt here
21735
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5888 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
5889 catch /arrgh/
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5890 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
5891 endtry
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5892 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
5893 [CODE]
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
5894 call writefile(lines, 'Xscript', 'D')
21781
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5895
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5896 breakadd file 7 Xscript
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5897 try
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5898 let caught_intr = 0
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5899 debuggreedy
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5900 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
5901 catch /^Vim:Interrupt$/
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5902 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
5903 let caught_intr = 1
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5904 endtry
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5905 0debuggreedy
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5906 call assert_equal(1, caught_intr)
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5907 call assert_equal('ab', g:Xpath)
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5908 breakdel *
21735
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5909 endfunc
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5910
078d98fe1c65 patch 8.2.1417: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21666
diff changeset
5911 "-------------------------------------------------------------------------------
21741
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5912 " 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
5913 "
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5914 " 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
5915 " 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
5916 " 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
5917 " exception being thrown then).
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5918 "-------------------------------------------------------------------------------
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5919
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5920 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
5921 let test =<< trim [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5922 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5923 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5924 Xpath 'a'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5925 throw "arrgh"
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5926 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
5927 if 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5928 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
5929 " error after :throw: missing :endif
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5930 catch /.*/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5931 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
5932 catch /.*/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5933 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
5934 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5935 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
5936 catch /arrgh/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5937 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
5938 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5939 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
5940 [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5941 let verify =<< trim [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5942 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
5943 [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5944 call RunInNewVim(test, verify)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5945 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5946
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5947 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
5948 let test =<< trim [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5949 func E()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5950 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5951 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5952 Xpath 'a'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5953 throw "arrgh"
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5954 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
5955 if 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5956 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
5957 " error after :throw: missing :endif
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5958 catch /.*/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5959 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
5960 catch /.*/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5961 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
5962 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5963 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
5964 catch /arrgh/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5965 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
5966 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5967 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5968
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5969 call E()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5970 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
5971 [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5972 let verify =<< trim [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5973 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
5974 [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5975 call RunInNewVim(test, verify)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5976 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5977
21781
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5978 " 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
5979 func Test_ignore_catch_after_intr_1()
31349
22d11340ee68 patch 9.0.1008: test for swapfilelist() fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 31069
diff changeset
5980 " for unknown reasons this test sometimes fails on MS-Windows.
22d11340ee68 patch 9.0.1008: test for swapfilelist() fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 31069
diff changeset
5981 let g:test_is_flaky = 1
22d11340ee68 patch 9.0.1008: test for swapfilelist() fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 31069
diff changeset
5982
21781
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5983 XpathINIT
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
5984 let lines =<< trim [CODE]
21741
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5985 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5986 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5987 Xpath 'a'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5988 throw "arrgh"
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5989 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
5990 catch /.*/ " interrupt here
21741
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5991 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
5992 catch /.*/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5993 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
5994 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5995 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
5996 catch /arrgh/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5997 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
5998 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
5999 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
6000 [CODE]
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
6001 call writefile(lines, 'Xscript', 'D')
21781
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6002
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6003 breakadd file 6 Xscript
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6004 try
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6005 let caught_intr = 0
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6006 debuggreedy
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6007 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
6008 catch /^Vim:Interrupt$/
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6009 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
6010 let caught_intr = 1
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6011 endtry
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6012 0debuggreedy
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6013 call assert_equal(1, caught_intr)
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6014 call assert_equal('a', g:Xpath)
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6015 breakdel *
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6016 endfunc
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6017
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6018 " 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
6019 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
6020 XpathINIT
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6021 func F()
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6022 try
21741
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6023 try
21781
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6024 Xpath 'a'
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6025 throw "arrgh"
21741
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6026 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
6027 catch /.*/ " interrupt here
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6028 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
6029 catch /.*/
21741
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6030 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
6031 endtry
21781
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6032 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
6033 catch /arrgh/
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6034 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
6035 endtry
21741
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6036 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
6037 endfunc
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6038
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6039 breakadd func 6 F
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6040 try
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6041 let caught_intr = 0
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6042 debuggreedy
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6043 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
6044 catch /^Vim:Interrupt$/
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6045 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
6046 let caught_intr = 1
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6047 endtry
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6048 0debuggreedy
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6049 call assert_equal(1, caught_intr)
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6050 call assert_equal('a', g:Xpath)
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6051 breakdel *
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6052 delfunc F
21741
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6053 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6054
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6055 "-------------------------------------------------------------------------------
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6056 " 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
6057 "
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6058 " 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
6059 " 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
6060 " 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
6061 "-------------------------------------------------------------------------------
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6062
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6063 func Test_finally_after_error()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6064 let test =<< trim [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6065 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6066 Xpath 'a'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6067 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6068 Xpath 'b'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6069 throw "arrgh"
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6070 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
6071 if 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6072 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
6073 " error after :throw: missing :endif
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6074 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6075 Xpath 'c'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6076 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6077 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
6078 catch /arrgh/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6079 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
6080 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6081 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
6082 [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6083 let verify =<< trim [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6084 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
6085 [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6086 call RunInNewVim(test, verify)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6087 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6088
21781
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6089 " 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
6090 func Test_finally_after_intr()
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6091 XpathINIT
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6092 let lines =<< trim [CODE]
21741
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6093 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6094 Xpath 'a'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6095 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6096 Xpath 'b'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6097 throw "arrgh"
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6098 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
6099 finally " interrupt here
21741
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6100 Xpath 'c'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6101 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6102 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
6103 catch /arrgh/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6104 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
6105 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6106 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
6107 [CODE]
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
6108 call writefile(lines, 'Xscript', 'D')
21781
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6109
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6110 breakadd file 7 Xscript
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6111 try
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6112 let caught_intr = 0
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6113 debuggreedy
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6114 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
6115 catch /^Vim:Interrupt$/
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6116 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
6117 let caught_intr = 1
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6118 endtry
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6119 0debuggreedy
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6120 call assert_equal(1, caught_intr)
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6121 call assert_equal('abc', g:Xpath)
99fe9e960207 patch 8.2.1440: debugger code insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 21741
diff changeset
6122 breakdel *
21741
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6123 endfunc
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 "-------------------------------------------------------------------------------
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6126 " 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
6127 "
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6128 " 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
6129 " 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
6130 " 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
6131 " 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
6132 "
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6133 " 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
6134 " :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
6135 " 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
6136 "-------------------------------------------------------------------------------
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 func Test_autocmd_exception()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6139 let test =<< trim [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6140 func INT()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6141 call interrupt()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6142 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6143
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6144 aug TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6145 autocmd!
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6146
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6147 autocmd User x1 Xpath 'a'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6148 autocmd User x1 throw "x1"
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6149 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
6150
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6151 autocmd User x2 Xpath 'b'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6152 autocmd User x2 asdf
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6153 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
6154
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6155 autocmd User x3 Xpath 'c'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6156 autocmd User x3 call INT()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6157 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
6158
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6159 autocmd FuncUndefined U1 func U1()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6160 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
6161 autocmd FuncUndefined U1 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6162 autocmd FuncUndefined U1 Xpath 'd'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6163 autocmd FuncUndefined U1 throw "U1"
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6164 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
6165
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6166 autocmd FuncUndefined U2 func U2()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6167 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
6168 autocmd FuncUndefined U2 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6169 autocmd FuncUndefined U2 Xpath 'e'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6170 autocmd FuncUndefined U2 ASDF
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6171 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
6172
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6173 autocmd FuncUndefined U3 func U3()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6174 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
6175 autocmd FuncUndefined U3 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6176 autocmd FuncUndefined U3 Xpath 'f'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6177 autocmd FuncUndefined U3 call INT()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6178 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
6179 aug END
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6180
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6181 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6182 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6183 Xpath 'g'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6184 doautocmd User x1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6185 catch /x1/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6186 Xpath 'h'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6187 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6188
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6189 while 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6190 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6191 Xpath 'i'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6192 doautocmd User x2
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6193 catch /asdf/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6194 Xpath 'j'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6195 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6196 Xpath 'k'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6197 break
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6198 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6199 endwhile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6200
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6201 while 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6202 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6203 Xpath 'l'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6204 doautocmd User x3
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6205 catch /Vim:Interrupt/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6206 Xpath 'm'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6207 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6208 Xpath 'n'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6209 " ... 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
6210 " 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
6211 break
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6212 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6213 endwhile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6214
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6215 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
6216 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
6217 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
6218
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6219 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6220 Xpath 'o'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6221 call U1()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6222 catch /U1/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6223 Xpath 'p'
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
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6226 while 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6227 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6228 Xpath 'q'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6229 call U2()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6230 catch /ASDF/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6231 Xpath 'r'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6232 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6233 Xpath 's'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6234 " ... 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
6235 " 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
6236 break
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6237 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6238 endwhile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6239
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6240 while 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6241 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6242 Xpath 't'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6243 call U3()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6244 catch /Vim:Interrupt/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6245 Xpath 'u'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6246 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6247 Xpath 'v'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6248 " ... 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
6249 " 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
6250 break
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6251 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6252 endwhile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6253 catch /.*/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6254 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
6255 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6256 Xpath 'w'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6257 [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6258 let verify =<< trim [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6259 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
6260 [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6261 call RunInNewVim(test, verify)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6262 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6263
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6264 "-------------------------------------------------------------------------------
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6265 " 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
6266 "
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6267 " 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
6268 " 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
6269 " 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
6270 " 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
6271 " Example 1: BufWritePre, :write, BufWritePost
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6272 " Example 2: FileReadPre, :read, FileReadPost.
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6273 "-------------------------------------------------------------------------------
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6274
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6275 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
6276 let test =<< trim [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6277 " 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
6278 " autogroups.
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6279 func Delete_autocommands(...)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6280 let augfile = tempname()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6281 while 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6282 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6283 exec "redir >" . augfile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6284 aug
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6285 redir END
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6286 exec "edit" augfile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6287 g/^$/d
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6288 norm G$
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6289 let wrap = "w"
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6290 while search('\%( \|^\)\@<=.\{-}\%( \)\@=', wrap) > 0
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6291 let wrap = "W"
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6292 exec "norm y/ \n"
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6293 let argno = 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6294 while argno <= a:0
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6295 exec "au!" escape(@", " ") a:{argno}
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6296 let argno = argno + 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6297 endwhile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6298 endwhile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6299 catch /.*/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6300 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6301 bwipeout!
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6302 call delete(augfile)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6303 break
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6304 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6305 endwhile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6306 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6307
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6308 call Delete_autocommands("BufWritePre", "BufWritePost")
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6309
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6310 while 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6311 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6312 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6313 let post = 0
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6314 aug TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6315 au! BufWritePost * let post = 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6316 aug END
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6317 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
6318 catch /^Vim(write):/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6319 Xpath 'a'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6320 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
6321 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6322 Xpath 'b'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6323 call assert_equal(0, post)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6324 au! TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6325 aug! TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6326 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6327 catch /.*/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6328 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
6329 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6330 Xpath 'c'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6331 break
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6332 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6333 endwhile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6334
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6335 while 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6336 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6337 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6338 let post = 0
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6339 aug TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6340 au! BufWritePre * asdf
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6341 au! BufWritePost * let post = 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6342 aug END
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6343 let tmpfile = tempname()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6344 exec "write" tmpfile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6345 catch /^Vim\((write)\)\=:/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6346 Xpath 'd'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6347 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
6348 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6349 Xpath 'e'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6350 if filereadable(tmpfile)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6351 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
6352 endif
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6353 call assert_equal(0, post)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6354 au! TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6355 aug! TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6356 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6357 catch /.*/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6358 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
6359 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6360 Xpath 'f'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6361 break
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6362 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6363 endwhile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6364
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6365 call delete(tmpfile)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6366
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6367 call Delete_autocommands("BufWritePre", "BufWritePost",
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6368 \ "BufReadPre", "BufReadPost", "FileReadPre", "FileReadPost")
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6369
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6370 while 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6371 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6372 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6373 let post = 0
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6374 aug TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6375 au! FileReadPost * let post = 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6376 aug END
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6377 let caught = 0
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6378 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
6379 catch /^Vim(read):/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6380 Xpath 'g'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6381 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
6382 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6383 Xpath 'h'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6384 call assert_equal(0, post)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6385 au! TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6386 aug! TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6387 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6388 catch /.*/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6389 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
6390 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6391 Xpath 'i'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6392 break
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6393 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6394 endwhile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6395
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6396 while 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6397 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6398 let infile = tempname()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6399 let tmpfile = tempname()
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6400 call writefile(["XYZ"], infile)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6401 exec "edit" tmpfile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6402 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6403 Xpath 'j'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6404 try
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6405 let post = 0
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6406 aug TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6407 au! FileReadPre * asdf
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6408 au! FileReadPost * let post = 1
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6409 aug END
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6410 exec "0read" infile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6411 catch /^Vim\((read)\)\=:/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6412 Xpath 'k'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6413 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
6414 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6415 Xpath 'l'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6416 if getline("1") == "XYZ"
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6417 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
6418 endif
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6419 call assert_equal(0, post)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6420 au! TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6421 aug! TMP
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6422 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6423 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6424 Xpath 'm'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6425 bwipeout!
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6426 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6427 catch /.*/
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6428 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
6429 finally
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6430 Xpath 'n'
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6431 break
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6432 endtry
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6433 endwhile
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6434
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6435 call delete(infile)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6436 call delete(tmpfile)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6437 [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6438 let verify =<< trim [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6439 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
6440 [CODE]
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6441 call RunInNewVim(test, verify)
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6442 endfunc
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6443
baccf9e06efe patch 8.2.1420: test 49 is old style
Bram Moolenaar <Bram@vim.org>
parents: 21735
diff changeset
6444 "-------------------------------------------------------------------------------
18504
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6445 " 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
6446 "
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6447 " 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
6448 " 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
6449 "-------------------------------------------------------------------------------
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6450
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6451 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
6452 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
6453 endfu
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6454
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6455 func GetStr()
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6456 return "abcdefghijklmnopqrstuvwxyp"
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6457 endfu
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6458
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6459 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
6460 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
6461
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6462 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
6463 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
6464 " 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
6465 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
6466 endfunc
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
6467
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6468 " 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
6469 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6470
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6471 func Test_curlies()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6472 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
6473 let ns = 's'
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(66, {ns}:var)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6475
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6476 let g:a = {}
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6477 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
6478 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
6479 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
6480 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6481
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6482 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6483 " 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
6484 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6485
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6486 func Test_type()
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(0, 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(1, 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(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
6490 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
6491 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
6492 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
6493 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
6494 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
6495 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
6496 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
6497 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
6498 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
6499 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
6500 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
6501 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
6502 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
6503 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
6504 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
6505 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
6506 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
6507 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
6508 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
6509 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
6510 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
6511 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
6512 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
6513 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
6514 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
6515 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
6516 if has('job')
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
6517 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
6518 endif
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
6519 if has('channel')
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
6520 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
6521 endif
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 20128
diff changeset
6522 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
6523
19548
9a9ca0e622c8 patch 8.2.0331: internal error when using test_void() and test_unknown()
Bram Moolenaar <Bram@vim.org>
parents: 19471
diff changeset
6524 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
6525 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
6526
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6527 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
6528 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
6529 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
6530 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
6531
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6532 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
6533 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
6534 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
6535 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
6536
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6537 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
6538 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
6539 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
6540 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
6541 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
6542 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
6543
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 == 0)
27928
ca7a207d83cd patch 8.2.4489: failing test for comparing v:null with number
Bram Moolenaar <Bram@vim.org>
parents: 27901
diff changeset
6545 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
6546 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
6547 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
6548 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
6549 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
6550 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
6551 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
6552 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
6553
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6554 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
6555 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
6556 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
6557 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
6558
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: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
6560 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
6561 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
6562 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
6563
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6564 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
6565 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
6566 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
6567 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
6568 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
6569 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
6570 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
6571 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
6572 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
6573
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6574 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
6575 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
6576 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
6577 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
6578 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
6579 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
6580
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: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
6582 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
6583 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
6584 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
6585
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6586 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
6587 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
6588 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
6589 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
6590
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6591 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
6592 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
6593 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
6594 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
6595
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6596 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
6597 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
6598 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
6599 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
6600
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6601 func ChangeYourMind()
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6602 try
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6603 return v:true
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6604 finally
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6605 return 'something else'
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6606 endtry
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6607 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6608
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6609 call ChangeYourMind()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6610 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6611
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 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
6613 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
6614 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
6615 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
6616 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
6617 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
6618
e695db9a5465 patch 8.2.2621: typval2type() cannot handle recursive structures
Bram Moolenaar <Bram@vim.org>
parents: 23594
diff changeset
6619 let l = []
e695db9a5465 patch 8.2.2621: typval2type() cannot handle recursive structures
Bram Moolenaar <Bram@vim.org>
parents: 23594
diff changeset
6620 let d = #{a: 0}
e695db9a5465 patch 8.2.2621: typval2type() cannot handle recursive structures
Bram Moolenaar <Bram@vim.org>
parents: 23594
diff changeset
6621 let l = [d]
e695db9a5465 patch 8.2.2621: typval2type() cannot handle recursive structures
Bram Moolenaar <Bram@vim.org>
parents: 23594
diff changeset
6622 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
6623 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
6624 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
6625 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
6626
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6627 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6628 " 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
6629 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6630
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6631 func Test_skip()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6632 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
6633 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
6634 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
6635 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
6636 let l = []
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6637 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
6638 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
6639 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
6640 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
6641 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
6642 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
6643 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
6644 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
6645 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
6646 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
6647 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
6648
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6649 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6650
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6651 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6652 " 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
6653 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6654
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6655 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
6656 " String
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6657 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
6658 redir => result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6659 echo a
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6660 echo string(a)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6661 redir END
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6662 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
6663 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
6664 \ "'foo bar'"], l)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6665
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6666 " 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
6667 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
6668 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
6669 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
6670 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
6671 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
6672 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
6673 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
6674 \ "-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
6675
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6676 " Funcref
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6677 redir => result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6678 echo function('string')
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6679 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
6680 redir END
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6681 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
6682 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
6683 \ "function('string')"], l)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6684
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6685 " Recursive dictionary
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6686 let a = {}
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6687 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
6688 redir => result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6689 echo a
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6690 echo string(a)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6691 redir END
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6692 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
6693 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
6694 \ "{'a': {...}}"], l)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6695
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6696 " Recursive list
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6697 let a = [0]
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6698 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
6699 redir => result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6700 echo a
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6701 echo string(a)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6702 redir END
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6703 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
6704 call assert_equal(["[[...]]",
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6705 \ "[[...]]"], l)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6706
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6707 " 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
6708 let a = {}
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6709 redir => result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6710 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
6711 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
6712 redir END
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6713 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
6714 call assert_equal(["[{}, {}, {}]",
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6715 \ "[{}, {}, {}]"], l)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6716
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6717 " 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
6718 let a = {}
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6719 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
6720 redir => result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6721 echo b
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6722 echo string(b)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6723 redir END
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6724 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
6725 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
6726 \ "{'a': {}, 'b': {}}"], l)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6727
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6728 " 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
6729 let a = []
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6730 redir => result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6731 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
6732 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
6733 redir END
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6734 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
6735 call assert_equal(["[[], [], []]",
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6736 \ "[[], [], []]"], l)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6737
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6738 " 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
6739 let a = []
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6740 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
6741 redir => result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6742 echo b
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6743 echo string(b)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6744 redir END
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6745 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
6746 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
6747 \ "{'a': [], 'b': []}"], l)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6748
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6749 " 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
6750 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
6751 redir => result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6752 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
6753 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
6754 redir END
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6755 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
6756 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
6757 \ "[{'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
6758
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6759 " 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
6760 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
6761 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
6762 redir => result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6763 echo b
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6764 echo string(b)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6765 redir END
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6766 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
6767 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
6768 \ "{'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
6769
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6770 " 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
6771 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
6772 redir => result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6773 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
6774 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
6775 redir END
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6776 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
6777 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
6778 \ "[[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
6779
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6780 " 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
6781 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
6782 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
6783 redir => result
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6784 echo b
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6785 echo string(b)
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6786 redir END
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6787 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
6788 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
6789 \ "{'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
6790
19991
f27473034f26 patch 8.2.0551: not all code for options is tested
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
6791 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
6792 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
6793 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
6794
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6795 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6796
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6797 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6798 " 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
6799 "-------------------------------------------------------------------------------
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 func Test_num64()
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6802 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
6803 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
6804 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
6805 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
6806
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6807 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
6808 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
6809 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
6810
30310
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
6811 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
6812 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
6813
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6814 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
6815 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
6816 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
6817 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
6818 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
6819 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6820
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6821 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6822 " 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
6823 "-------------------------------------------------------------------------------
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6824
30687
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
6825 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
6826 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
6827 exec func
30687
f936d46cc9c1 patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents: 30455
diff changeset
6828 endfunc
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6829
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6830 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
6831 " :append
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6832 try
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6833 call DefineFunction('T_Append', [
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6834 \ 'append',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6835 \ 'py <<EOS',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6836 \ '.',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6837 \ ])
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6838 catch
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6839 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
6840 endtry
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6841 try
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6842 call DefineFunction('T_Append', [
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6843 \ 'append',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6844 \ 'abc',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6845 \ ])
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6846 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
6847 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
6848 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
6849 endtry
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6850
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6851 " :change
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6852 try
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6853 call DefineFunction('T_Change', [
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6854 \ 'change',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6855 \ 'py <<EOS',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6856 \ '.',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6857 \ ])
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6858 catch
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6859 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
6860 endtry
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6861 try
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6862 call DefineFunction('T_Change', [
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6863 \ 'change',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6864 \ 'abc',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6865 \ ])
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6866 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
6867 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
6868 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
6869 endtry
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6870
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6871 " :insert
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6872 try
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6873 call DefineFunction('T_Insert', [
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6874 \ 'insert',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6875 \ 'py <<EOS',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6876 \ '.',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6877 \ ])
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6878 catch
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6879 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
6880 endtry
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6881 try
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6882 call DefineFunction('T_Insert', [
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6883 \ 'insert',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6884 \ 'abc',
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6885 \ ])
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6886 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
6887 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
6888 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
6889 endtry
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6890 endfunc
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6891
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6892 "-------------------------------------------------------------------------------
11352
251f1833db7d patch 8.0.0561: undefined behavior when using backslash after empty line
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
6893 " 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
6894 "
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 13351
diff changeset
6895 " 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
6896 " 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
6897 "-------------------------------------------------------------------------------
30986
360f286b5869 patch 9.0.0828: various typos
Bram Moolenaar <Bram@vim.org>
parents: 30867
diff changeset
6898 func Test_script_empty_line_continuation()
11352
251f1833db7d patch 8.0.0561: undefined behavior when using backslash after empty line
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
6899
251f1833db7d patch 8.0.0561: undefined behavior when using backslash after empty line
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
6900 \
251f1833db7d patch 8.0.0561: undefined behavior when using backslash after empty line
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
6901 endfunc
251f1833db7d patch 8.0.0561: undefined behavior when using backslash after empty line
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
6902
251f1833db7d patch 8.0.0561: undefined behavior when using backslash after empty line
Christian Brabandt <cb@256bit.org>
parents: 11183
diff changeset
6903 "-------------------------------------------------------------------------------
11461
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6904 " Test 97: bitwise functions {{{1
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6905 "-------------------------------------------------------------------------------
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6906 func Test_bitwise_functions()
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6907 " and
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6908 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
6909 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
6910 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
6911 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
6912 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
6913 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
6914 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
6915 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
6916 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
6917 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
6918 " or
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6919 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
6920 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
6921 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
6922 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
6923 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
6924 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
6925 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
6926 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
6927 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
6928 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
6929 " xor
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6930 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
6931 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
6932 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
6933 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
6934 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
6935 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
6936 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
6937 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
6938 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
6939 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
6940 " invert
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6941 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
6942 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
6943 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
6944 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
6945 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
6946 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
6947 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
6948 endfunc
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
6949
11547
3d03ed329a54 patch 8.0.0656: cannot use ! after some user commands
Christian Brabandt <cb@256bit.org>
parents: 11545
diff changeset
6950 " 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
6951 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
6952 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
6953 Ni!
3d03ed329a54 patch 8.0.0656: cannot use ! after some user commands
Christian Brabandt <cb@256bit.org>
parents: 11545
diff changeset
6954 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
6955 unlet nieuw
3d03ed329a54 patch 8.0.0656: cannot use ! after some user commands
Christian Brabandt <cb@256bit.org>
parents: 11545
diff changeset
6956 delcommand Nieuw
3d03ed329a54 patch 8.0.0656: cannot use ! after some user commands
Christian Brabandt <cb@256bit.org>
parents: 11545
diff changeset
6957 endfunc
3d03ed329a54 patch 8.0.0656: cannot use ! after some user commands
Christian Brabandt <cb@256bit.org>
parents: 11545
diff changeset
6958
19035
b920ae62c7b1 patch 8.2.0078: expanding <sfile> works differently the second time
Bram Moolenaar <Bram@vim.org>
parents: 18556
diff changeset
6959 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
6960 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
6961 func s:snr()
b920ae62c7b1 patch 8.2.0078: expanding <sfile> works differently the second time
Bram Moolenaar <Bram@vim.org>
parents: 18556
diff changeset
6962 return expand('<sfile>')
b920ae62c7b1 patch 8.2.0078: expanding <sfile> works differently the second time
Bram Moolenaar <Bram@vim.org>
parents: 18556
diff changeset
6963 endfunc
b920ae62c7b1 patch 8.2.0078: expanding <sfile> works differently the second time
Bram Moolenaar <Bram@vim.org>
parents: 18556
diff changeset
6964 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
6965 END
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
6966 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
6967 source Xexpand
b920ae62c7b1 patch 8.2.0078: expanding <sfile> works differently the second time
Bram Moolenaar <Bram@vim.org>
parents: 18556
diff changeset
6968 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
6969 source Xexpand
b920ae62c7b1 patch 8.2.0078: expanding <sfile> works differently the second time
Bram Moolenaar <Bram@vim.org>
parents: 18556
diff changeset
6970 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
6971
b920ae62c7b1 patch 8.2.0078: expanding <sfile> works differently the second time
Bram Moolenaar <Bram@vim.org>
parents: 18556
diff changeset
6972 unlet g:result
b920ae62c7b1 patch 8.2.0078: expanding <sfile> works differently the second time
Bram Moolenaar <Bram@vim.org>
parents: 18556
diff changeset
6973 endfunc
b920ae62c7b1 patch 8.2.0078: expanding <sfile> works differently the second time
Bram Moolenaar <Bram@vim.org>
parents: 18556
diff changeset
6974
15790
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6975 func Test_compound_assignment_operators()
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6976 " Test for number
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6977 let x = 1
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6978 let x += 10
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6979 call assert_equal(11, x)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6980 let x -= 5
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6981 call assert_equal(6, x)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6982 let x *= 4
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6983 call assert_equal(24, x)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6984 let x /= 3
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6985 call assert_equal(8, x)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6986 let x %= 3
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6987 call assert_equal(2, x)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6988 let x .= 'n'
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6989 call assert_equal('2n', x)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
6990
15969
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
6991 " 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
6992 let x = 1
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
6993 let x /= 0
19427
fdfe44ac6a1a patch 8.2.0271: the "num64" feature is available everywhere
Bram Moolenaar <Bram@vim.org>
parents: 19425
diff changeset
6994 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
6995
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
6996 let x = -1
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
6997 let x /= 0
19427
fdfe44ac6a1a patch 8.2.0271: the "num64" feature is available everywhere
Bram Moolenaar <Bram@vim.org>
parents: 19425
diff changeset
6998 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
6999
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 let x /= 0
19427
fdfe44ac6a1a patch 8.2.0271: the "num64" feature is available everywhere
Bram Moolenaar <Bram@vim.org>
parents: 19425
diff changeset
7002 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
7003
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
7004 let x = 1
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
7005 let x %= 0
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
7006 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
7007
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
7008 let x = -1
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
7009 let x %= 0
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
7010 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
7011
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
7012 let x = 0
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
7013 let x %= 0
9cc42db77a54 patch 8.1.0990: floating point exception with "%= 0" and "/= 0"
Bram Moolenaar <Bram@vim.org>
parents: 15790
diff changeset
7014 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
7015
15790
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7016 " Test for string
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7017 let x = 'str'
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7018 let x .= 'ing'
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7019 call assert_equal('string', x)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7020 let x += 1
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7021 call assert_equal(1, x)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7022
30310
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7023 " 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
7024 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
7025 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
7026 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
7027 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
7028 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
7029 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
7030 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
7031 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
7032 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
7033 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
7034 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
7035 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
7036 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
7037 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
7038 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
7039
029c59bf78f1 patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents: 29305
diff changeset
7040 " 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
7041 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
7042 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
7043 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
7044 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
7045 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
7046 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
7047 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
7048 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
7049 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
7050 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
7051 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
7052 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
7053
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7054 " Test for environment variable
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7055 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
7056 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
7057 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
7058 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
7059 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
7060 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
7061 let $FOO .= 's'
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7062 call assert_equal('1s', $FOO)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7063 unlet $FOO
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7064
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7065 " 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
7066 let &scrolljump = 1
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7067 let &scrolljump += 5
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7068 call assert_equal(6, &scrolljump)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7069 let &scrolljump -= 2
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7070 call assert_equal(4, &scrolljump)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7071 let &scrolljump *= 3
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7072 call assert_equal(12, &scrolljump)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7073 let &scrolljump /= 2
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7074 call assert_equal(6, &scrolljump)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7075 let &scrolljump %= 5
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7076 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
7077 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
7078 set scrolljump&vim
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7079
24862
f1a390885192 patch 8.2.2969: subtracting from number option fails when result is zero
Bram Moolenaar <Bram@vim.org>
parents: 24234
diff changeset
7080 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
7081 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
7082 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
7083 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
7084 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
7085 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
7086 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
7087 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
7088
15790
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7089 " Test for register
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7090 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
7091 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
7092 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
7093 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
7094 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
7095 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
7096 let @/ .= 's'
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7097 call assert_equal('1s', @/)
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7098 let @/ = ''
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7099 endfunc
05d836c8f1c4 patch 8.1.0902: incomplete set of assignment operators
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
7100
20093
646c53fa5781 patch 8.2.0602: :unlet $VAR does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
7101 func Test_unlet_env()
646c53fa5781 patch 8.2.0602: :unlet $VAR does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
7102 let $TESTVAR = 'yes'
646c53fa5781 patch 8.2.0602: :unlet $VAR does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
7103 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
7104 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
7105 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
7106 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
7107 if 0
646c53fa5781 patch 8.2.0602: :unlet $VAR does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
7108 unlet $TESTVAR
646c53fa5781 patch 8.2.0602: :unlet $VAR does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
7109 endif
646c53fa5781 patch 8.2.0602: :unlet $VAR does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
7110 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
7111 unlet $TESTVAR
646c53fa5781 patch 8.2.0602: :unlet $VAR does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
7112 call assert_equal('', $TESTVAR)
646c53fa5781 patch 8.2.0602: :unlet $VAR does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
7113 endfunc
646c53fa5781 patch 8.2.0602: :unlet $VAR does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 19991
diff changeset
7114
16078
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7115 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
7116 " 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
7117 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
7118 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
7119 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
7120 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
7121 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
7122 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
7123 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
7124 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
7125 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
7126 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
7127 endif
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7128
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7129 " 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
7130 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
7131 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
7132 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
7133 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
7134 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
7135 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
7136 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
7137 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
7138
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7139 " 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
7140 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
7141 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
7142
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7143 let x = {}
18031
8a2fb21c23c0 patch 8.1.2011: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17849
diff changeset
7144 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
7145
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7146 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
7147 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
7148
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7149 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
7150 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
7151 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
7152 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
7153
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7154 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
7155 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
7156 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
7157 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
7158 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
7159 endif
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7160
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7161 " 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
7162 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
7163 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
7164 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
7165 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
7166 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
7167 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
7168 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
7169 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
7170 endfunc
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 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
7172 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
7173 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
7174 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
7175 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
7176 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
7177 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
7178 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
7179 endif
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7180 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
7181
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7182 " 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
7183 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
7184 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
7185 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
7186 endfunc
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7187 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
7188 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
7189 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
7190 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
7191 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
7192 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
7193 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
7194 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
7195 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
7196 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
7197 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
7198 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
7199 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
7200 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
7201 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
7202 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
7203 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
7204 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
7205 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
7206 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
7207
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7208 " 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
7209 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
7210 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
7211 endfunc
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7212 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
7213 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
7214 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
7215 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
7216 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
7217 delfunc DictFunc
30415
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
7218
30455
b4c9540577cf patch 9.0.0563: timer_info() test fails
Bram Moolenaar <Bram@vim.org>
parents: 30415
diff changeset
7219 if has('channel')
b4c9540577cf patch 9.0.0563: timer_info() test fails
Bram Moolenaar <Bram@vim.org>
parents: 30415
diff changeset
7220 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
7221 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
7222 endif
30415
56e38195570b patch 9.0.0543: insufficient testing for assert and test functions
Bram Moolenaar <Bram@vim.org>
parents: 30310
diff changeset
7223 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
7224 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
7225 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
7226 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
7227 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
7228 endfunc
d13aa9c5a1d1 patch 8.1.1044: no way to check the reference count of objects
Bram Moolenaar <Bram@vim.org>
parents: 15969
diff changeset
7229
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7230 " 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
7231 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
7232 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
7233 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
7234 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
7235 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
7236 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
7237 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
7238 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
7239 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
7240
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7241 " Using endfor with :while
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7242 let caught_e732 = 0
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7243 try
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7244 while v:true
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7245 endfor
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7246 catch /E732:/
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7247 let caught_e732 = 1
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7248 endtry
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7249 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
7250
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7251 " Using endwhile with :for
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7252 let caught_e733 = 0
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7253 try
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7254 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
7255 endwhile
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7256 catch /E733:/
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7257 let caught_e733 = 1
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7258 endtry
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7259 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
7260
19932
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7261 " Using endfunc with :if
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7262 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
7263
19471
cb73f4ae6b7c patch 8.2.0293: various Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19427
diff changeset
7264 " 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
7265 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
7266
0b35a7ffceb2 patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents: 20109
diff changeset
7267 " 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
7268 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
7269 endfunc
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7270
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7271 " 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
7272 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
7273 CheckRunVimInTerminal
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7274
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7275 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
7276 " 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
7277 func Test1()
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 = 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
7279 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
7280 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
7281 @a
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7282 let @a = ''
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7283 endfunc
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7284
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7285 " 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
7286 func Test2()
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 = 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
7288 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
7289 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
7290 @a
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7291 let @a = ''
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7292 endfunc
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7293
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7294 " 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
7295 func Test3()
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 = 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
7297 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
7298 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
7299 @a
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7300 let @a = ''
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7301 endfunc
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7302
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7303 " 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
7304 func Test4()
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7305 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
7306 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
7307 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
7308 @a
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7309 let @a = ''
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7310 endfunc
19932
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7311
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7312 " 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
7313 func Test5()
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7314 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
7315 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
7316 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
7317 @a
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7318 let @a = ''
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7319 endfunc
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7320 [SCRIPT]
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
7321 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
7322
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7323 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
7324
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7325 " 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
7326 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
7327 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
7328 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
7329
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7330 " 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
7331 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
7332 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
7333 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
7334
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7335 " 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
7336 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
7337 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
7338 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
7339
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7340 " 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
7341 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
7342 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
7343 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
7344
19932
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7345 " 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
7346 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
7347 call TermWait(buf)
19932
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7348 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
7349 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
7350 call TermWait(buf)
19932
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19724
diff changeset
7351
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7352 "let l = ''
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7353 "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
7354 " 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
7355 "endfor
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7356 "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
7357
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7358 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
7359 endfunc
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
7360
19724
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
7361 " 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
7362 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
7363 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
7364 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
7365 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
7366 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
7367 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
7368 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
7369 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
7370 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
7371 endfunc
b3e93a05c3ca patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19689
diff changeset
7372
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
7373 " 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
7374 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
7375 " 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
7376 let caught_e128 = 0
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7377 try
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7378 func! g:test()
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7379 echo "test"
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7380 endfunc
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7381 catch /E128:/
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7382 let caught_e128 = 1
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7383 endtry
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7384 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
7385
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7386 " 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
7387 let caught_e884 = 0
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7388 try
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7389 func! b:test()
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7390 echo "test"
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7391 endfunc
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7392 catch /E884:/
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7393 let caught_e884 = 1
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7394 endtry
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7395 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
7396
23229
b545334ae654 patch 8.2.2160: various typos
Bram Moolenaar <Bram@vim.org>
parents: 23191
diff changeset
7397 " 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
7398 let caught_e128 = 0
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7399 try
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7400 func! test2() "#
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7401 echo "test2"
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7402 endfunc
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7403 catch /E128:/
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7404 let caught_e128 = 1
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7405 endtry
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7406 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
7407
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7408 " 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
7409 function! g:Foo(n)
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7410 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
7411 endfunction
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7412 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
7413 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
7414 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
7415 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
7416 delfunc g:Foo
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7417
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7418 " 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
7419 let lines =<< trim END
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7420 func s:Testje()
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7421 return "foo"
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7422 endfunc
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7423 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
7424 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
7425 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
7426 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
7427 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
7428 END
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
7429 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
7430 source Xscript
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7431 endfunc
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7432
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
7433 " 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
7434 func Test_substring_var()
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7435 let str = 'abcdef'
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7436 let n = 3
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7437 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
7438 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
7439 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
7440 unlet n
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7441 let nn = 3
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7442 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
7443 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
7444 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
7445 unlet nn
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7446 let b:nn = 4
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7447 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
7448 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
7449 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
7450 unlet b:nn
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7451 endfunc
e82996ad131f patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents: 20093
diff changeset
7452
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
7453 " 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
7454 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
7455 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
7456
8fb0e507491d patch 8.2.1106: crash when trying to use s: variable in typed command
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
7457 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
7458
8fb0e507491d patch 8.2.1106: crash when trying to use s: variable in typed command
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
7459 " 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
7460 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
7461 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
7462 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
7463
8fb0e507491d patch 8.2.1106: crash when trying to use s: variable in typed command
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
7464 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
7465 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
7466
21925
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7467 " Test for issue6776 {{{1
27901
dd7d94b911fa patch 8.2.4476: operator name spelled wrong
Bram Moolenaar <Bram@vim.org>
parents: 26606
diff changeset
7468 func Test_ternary_expression()
21925
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7469 try
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7470 call eval('0 ? 0')
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7471 catch
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7472 endtry
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7473 " 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
7474 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
7475
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7476 try
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7477 call eval('0 ? "burp')
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7478 catch
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7479 endtry
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7480 " 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
7481 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
7482
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7483 try
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7484 call eval('1 ? 0 : "burp')
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7485 catch
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7486 endtry
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7487 " 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
7488 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
7489 endfunction
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21781
diff changeset
7490
24234
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7491 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
7492 let res = ''
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7493 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
7494 let res ..= c .. '-'
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7495 endfor
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7496 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
7497
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7498 let res = ''
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7499 for c in ''
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7500 let res ..= c .. '-'
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7501 endfor
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7502 call assert_equal('', res)
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7503
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7504 let res = ''
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7505 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
7506 let res ..= c .. '-'
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7507 endfor
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7508 call assert_equal('', res)
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7509 endfunc
7ffc795288dd patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents: 24160
diff changeset
7510
29305
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7511 " 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
7512 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
7513 let lines =<< trim END
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7514
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7515 so
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7516 sil 0scr
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7517 delete
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7518 so
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7519 0
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7520 END
30867
0913cd44fdfa patch 9.0.0768: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30687
diff changeset
7521 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
7522
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7523 " this must not crash
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7524 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
7525 call system(cmd)
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7526 endfunc
949e8978ea43 patch 8.2.5169: nested :source may use NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 28735
diff changeset
7527
11461
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11352
diff changeset
7528 "-------------------------------------------------------------------------------
10942
e05695e59f6d patch 8.0.0360: sometimes VimL is used instead of "Vim script"
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7529 " Modelines {{{1
18504
ece46bd3c9af patch 8.1.2246: some tests are still in old style
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
7530 " 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
7531 "-------------------------------------------------------------------------------