Mercurial > vim
annotate src/testdir/test_vim9_script.vim @ 26739:47ad45fb433a v8.2.3898
patch 8.2.3898: Vim9: not sufficient testing for variable initialization
Commit: https://github.com/vim/vim/commit/fb9dcb080b5143d3021a8c1d6deaf143f2ca3a48
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Dec 25 22:00:49 2021 +0000
patch 8.2.3898: Vim9: not sufficient testing for variable initialization
Problem: Vim9: not sufficient testing for variable initialization.
Solution: Add another test case.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 25 Dec 2021 23:15:03 +0100 |
parents | 10d3105030ab |
children | dcd1c244e332 |
rev | line source |
---|---|
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 " Test various aspects of the Vim9 script language. |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 |
19183
1168c53d1b49
patch 8.2.0150: cannot define python function when using :execute
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
3 source check.vim |
20881
58137dbee8da
patch 8.2.0992: Vim9: crash when using :import in the Vim command
Bram Moolenaar <Bram@vim.org>
parents:
20871
diff
changeset
|
4 source term_util.vim |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
5 source view_util.vim |
20170
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
6 source vim9.vim |
21979
a98211c3e14e
patch 8.2.1539: using invalid script ID causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
21957
diff
changeset
|
7 source shared.vim |
24079
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
24077
diff
changeset
|
8 source screendump.vim |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 |
21901
1ebcce655dd3
patch 8.2.1500: Vim9: error when using address without a command
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
10 def Test_range_only() |
1ebcce655dd3
patch 8.2.1500: Vim9: error when using address without a command
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
11 new |
1ebcce655dd3
patch 8.2.1500: Vim9: error when using address without a command
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
12 setline(1, ['blah', 'Blah']) |
1ebcce655dd3
patch 8.2.1500: Vim9: error when using address without a command
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
13 :/Blah/ |
1ebcce655dd3
patch 8.2.1500: Vim9: error when using address without a command
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
14 assert_equal(2, getcurpos()[1]) |
21939
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
15 bwipe! |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
16 |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
17 # without range commands use current line |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
18 new |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
19 setline(1, ['one', 'two', 'three']) |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
20 :2 |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
21 print |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
22 assert_equal('two', Screenline(&lines)) |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
23 :3 |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
24 list |
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
25 assert_equal('three$', Screenline(&lines)) |
23954
9c8a20cfa540
patch 8.2.2519: Vim9: no reason to keep strange Vi behavior
Bram Moolenaar <Bram@vim.org>
parents:
23950
diff
changeset
|
26 |
9c8a20cfa540
patch 8.2.2519: Vim9: no reason to keep strange Vi behavior
Bram Moolenaar <Bram@vim.org>
parents:
23950
diff
changeset
|
27 # missing command does not print the line |
9c8a20cfa540
patch 8.2.2519: Vim9: no reason to keep strange Vi behavior
Bram Moolenaar <Bram@vim.org>
parents:
23950
diff
changeset
|
28 var lines =<< trim END |
9c8a20cfa540
patch 8.2.2519: Vim9: no reason to keep strange Vi behavior
Bram Moolenaar <Bram@vim.org>
parents:
23950
diff
changeset
|
29 vim9script |
9c8a20cfa540
patch 8.2.2519: Vim9: no reason to keep strange Vi behavior
Bram Moolenaar <Bram@vim.org>
parents:
23950
diff
changeset
|
30 :1| |
9c8a20cfa540
patch 8.2.2519: Vim9: no reason to keep strange Vi behavior
Bram Moolenaar <Bram@vim.org>
parents:
23950
diff
changeset
|
31 assert_equal('three$', Screenline(&lines)) |
9c8a20cfa540
patch 8.2.2519: Vim9: no reason to keep strange Vi behavior
Bram Moolenaar <Bram@vim.org>
parents:
23950
diff
changeset
|
32 :| |
9c8a20cfa540
patch 8.2.2519: Vim9: no reason to keep strange Vi behavior
Bram Moolenaar <Bram@vim.org>
parents:
23950
diff
changeset
|
33 assert_equal('three$', Screenline(&lines)) |
9c8a20cfa540
patch 8.2.2519: Vim9: no reason to keep strange Vi behavior
Bram Moolenaar <Bram@vim.org>
parents:
23950
diff
changeset
|
34 END |
9c8a20cfa540
patch 8.2.2519: Vim9: no reason to keep strange Vi behavior
Bram Moolenaar <Bram@vim.org>
parents:
23950
diff
changeset
|
35 CheckScriptSuccess(lines) |
9c8a20cfa540
patch 8.2.2519: Vim9: no reason to keep strange Vi behavior
Bram Moolenaar <Bram@vim.org>
parents:
23950
diff
changeset
|
36 |
21939
8350bdbdbb28
patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents:
21937
diff
changeset
|
37 bwipe! |
23197
4ba101403fa2
patch 8.2.2144: Vim9: some corner cases not tested
Bram Moolenaar <Bram@vim.org>
parents:
23185
diff
changeset
|
38 |
4ba101403fa2
patch 8.2.2144: Vim9: some corner cases not tested
Bram Moolenaar <Bram@vim.org>
parents:
23185
diff
changeset
|
39 # won't generate anything |
4ba101403fa2
patch 8.2.2144: Vim9: some corner cases not tested
Bram Moolenaar <Bram@vim.org>
parents:
23185
diff
changeset
|
40 if false |
4ba101403fa2
patch 8.2.2144: Vim9: some corner cases not tested
Bram Moolenaar <Bram@vim.org>
parents:
23185
diff
changeset
|
41 :123 |
4ba101403fa2
patch 8.2.2144: Vim9: some corner cases not tested
Bram Moolenaar <Bram@vim.org>
parents:
23185
diff
changeset
|
42 endif |
21901
1ebcce655dd3
patch 8.2.1500: Vim9: error when using address without a command
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
43 enddef |
1ebcce655dd3
patch 8.2.1500: Vim9: error when using address without a command
Bram Moolenaar <Bram@vim.org>
parents:
21883
diff
changeset
|
44 |
20419
d54dfb5f12db
patch 8.2.0764: Vim9: assigning to option not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
20401
diff
changeset
|
45 let g:alist = [7] |
d54dfb5f12db
patch 8.2.0764: Vim9: assigning to option not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
20401
diff
changeset
|
46 let g:astring = 'text' |
21365
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
47 let g:anumber = 123 |
19326
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
48 |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
49 def Test_delfunction() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
50 # Check function is defined in script namespace |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
51 CheckScriptSuccess([ |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
52 'vim9script', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
53 'func CheckMe()', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
54 ' return 123', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
55 'endfunc', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
56 'assert_equal(123, s:CheckMe())', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
57 ]) |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
58 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
59 # Check function in script namespace cannot be deleted |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
60 CheckScriptFailure([ |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
61 'vim9script', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
62 'func DeleteMe1()', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
63 'endfunc', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
64 'delfunction DeleteMe1', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
65 ], 'E1084:') |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
66 CheckScriptFailure([ |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
67 'vim9script', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
68 'func DeleteMe2()', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
69 'endfunc', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
70 'def DoThat()', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
71 ' delfunction DeleteMe2', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
72 'enddef', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
73 'DoThat()', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
74 ], 'E1084:') |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
75 CheckScriptFailure([ |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
76 'vim9script', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
77 'def DeleteMe3()', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
78 'enddef', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
79 'delfunction DeleteMe3', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
80 ], 'E1084:') |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
81 CheckScriptFailure([ |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
82 'vim9script', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
83 'def DeleteMe4()', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
84 'enddef', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
85 'def DoThat()', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
86 ' delfunction DeleteMe4', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
87 'enddef', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
88 'DoThat()', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
89 ], 'E1084:') |
21479
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
90 |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
91 # Check that global :def function can be replaced and deleted |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
92 var lines =<< trim END |
21479
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
93 vim9script |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
94 def g:Global(): string |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
95 return "yes" |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
96 enddef |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
97 assert_equal("yes", g:Global()) |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
98 def! g:Global(): string |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
99 return "no" |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
100 enddef |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
101 assert_equal("no", g:Global()) |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
102 delfunc g:Global |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
103 assert_false(exists('*g:Global')) |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
104 END |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
105 CheckScriptSuccess(lines) |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
106 |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
107 # Check that global function can be replaced by a :def function and deleted |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
108 lines =<< trim END |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
109 vim9script |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
110 func g:Global() |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
111 return "yes" |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
112 endfunc |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
113 assert_equal("yes", g:Global()) |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
114 def! g:Global(): string |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
115 return "no" |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
116 enddef |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
117 assert_equal("no", g:Global()) |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
118 delfunc g:Global |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
119 assert_false(exists('*g:Global')) |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
120 END |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
121 CheckScriptSuccess(lines) |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
122 |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
123 # Check that global :def function can be replaced by a function and deleted |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
124 lines =<< trim END |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
125 vim9script |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
126 def g:Global(): string |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
127 return "yes" |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
128 enddef |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
129 assert_equal("yes", g:Global()) |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
130 func! g:Global() |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
131 return "no" |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
132 endfunc |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
133 assert_equal("no", g:Global()) |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
134 delfunc g:Global |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
135 assert_false(exists('*g:Global')) |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
136 END |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
137 CheckScriptSuccess(lines) |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
138 enddef |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
139 |
22264
e0a4d029cb87
patch 8.2.1681: Vim9: unnessary :call commands in tests
Bram Moolenaar <Bram@vim.org>
parents:
22250
diff
changeset
|
140 def Test_wrong_type() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
141 CheckDefFailure(['var name: list<nothing>'], 'E1010:') |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
142 CheckDefFailure(['var name: list<list<nothing>>'], 'E1010:') |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
143 CheckDefFailure(['var name: dict<nothing>'], 'E1010:') |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
144 CheckDefFailure(['var name: dict<dict<nothing>>'], 'E1010:') |
22264
e0a4d029cb87
patch 8.2.1681: Vim9: unnessary :call commands in tests
Bram Moolenaar <Bram@vim.org>
parents:
22250
diff
changeset
|
145 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
146 CheckDefFailure(['var name: dict<number'], 'E1009:') |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
147 CheckDefFailure(['var name: dict<list<number>'], 'E1009:') |
22264
e0a4d029cb87
patch 8.2.1681: Vim9: unnessary :call commands in tests
Bram Moolenaar <Bram@vim.org>
parents:
22250
diff
changeset
|
148 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
149 CheckDefFailure(['var name: ally'], 'E1010:') |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
150 CheckDefFailure(['var name: bram'], 'E1010:') |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
151 CheckDefFailure(['var name: cathy'], 'E1010:') |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
152 CheckDefFailure(['var name: dom'], 'E1010:') |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
153 CheckDefFailure(['var name: freddy'], 'E1010:') |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
154 CheckDefFailure(['var name: john'], 'E1010:') |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
155 CheckDefFailure(['var name: larry'], 'E1010:') |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
156 CheckDefFailure(['var name: ned'], 'E1010:') |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
157 CheckDefFailure(['var name: pam'], 'E1010:') |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
158 CheckDefFailure(['var name: sam'], 'E1010:') |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
159 CheckDefFailure(['var name: vim'], 'E1010:') |
22264
e0a4d029cb87
patch 8.2.1681: Vim9: unnessary :call commands in tests
Bram Moolenaar <Bram@vim.org>
parents:
22250
diff
changeset
|
160 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
161 CheckDefFailure(['var Ref: number', 'Ref()'], 'E1085:') |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
162 CheckDefFailure(['var Ref: string', 'var res = Ref()'], 'E1085:') |
22264
e0a4d029cb87
patch 8.2.1681: Vim9: unnessary :call commands in tests
Bram Moolenaar <Bram@vim.org>
parents:
22250
diff
changeset
|
163 enddef |
e0a4d029cb87
patch 8.2.1681: Vim9: unnessary :call commands in tests
Bram Moolenaar <Bram@vim.org>
parents:
22250
diff
changeset
|
164 |
22529
35ef9b0a81a3
patch 8.2.1813: Vim9: can assign wrong type to script dict
Bram Moolenaar <Bram@vim.org>
parents:
22500
diff
changeset
|
165 def Test_script_wrong_type() |
35ef9b0a81a3
patch 8.2.1813: Vim9: can assign wrong type to script dict
Bram Moolenaar <Bram@vim.org>
parents:
22500
diff
changeset
|
166 var lines =<< trim END |
35ef9b0a81a3
patch 8.2.1813: Vim9: can assign wrong type to script dict
Bram Moolenaar <Bram@vim.org>
parents:
22500
diff
changeset
|
167 vim9script |
35ef9b0a81a3
patch 8.2.1813: Vim9: can assign wrong type to script dict
Bram Moolenaar <Bram@vim.org>
parents:
22500
diff
changeset
|
168 var s:dict: dict<string> |
35ef9b0a81a3
patch 8.2.1813: Vim9: can assign wrong type to script dict
Bram Moolenaar <Bram@vim.org>
parents:
22500
diff
changeset
|
169 s:dict['a'] = ['x'] |
35ef9b0a81a3
patch 8.2.1813: Vim9: can assign wrong type to script dict
Bram Moolenaar <Bram@vim.org>
parents:
22500
diff
changeset
|
170 END |
35ef9b0a81a3
patch 8.2.1813: Vim9: can assign wrong type to script dict
Bram Moolenaar <Bram@vim.org>
parents:
22500
diff
changeset
|
171 CheckScriptFailure(lines, 'E1012: Type mismatch; expected string but got list<string>', 3) |
35ef9b0a81a3
patch 8.2.1813: Vim9: can assign wrong type to script dict
Bram Moolenaar <Bram@vim.org>
parents:
22500
diff
changeset
|
172 enddef |
35ef9b0a81a3
patch 8.2.1813: Vim9: can assign wrong type to script dict
Bram Moolenaar <Bram@vim.org>
parents:
22500
diff
changeset
|
173 |
22264
e0a4d029cb87
patch 8.2.1681: Vim9: unnessary :call commands in tests
Bram Moolenaar <Bram@vim.org>
parents:
22250
diff
changeset
|
174 def Test_const() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
175 CheckDefFailure(['final name = 234', 'name = 99'], 'E1018:') |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
176 CheckDefFailure(['final one = 234', 'var one = 99'], 'E1017:') |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
177 CheckDefFailure(['final list = [1, 2]', 'var list = [3, 4]'], 'E1017:') |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22387
diff
changeset
|
178 CheckDefFailure(['final two'], 'E1125:') |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22387
diff
changeset
|
179 CheckDefFailure(['final &option'], 'E996:') |
22266
23f5750146d9
patch 8.2.1682: Vim9: const works in an unexpected way
Bram Moolenaar <Bram@vim.org>
parents:
22264
diff
changeset
|
180 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
181 var lines =<< trim END |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22387
diff
changeset
|
182 final list = [1, 2, 3] |
22266
23f5750146d9
patch 8.2.1682: Vim9: const works in an unexpected way
Bram Moolenaar <Bram@vim.org>
parents:
22264
diff
changeset
|
183 list[0] = 4 |
22272
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
184 list->assert_equal([4, 2, 3]) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22387
diff
changeset
|
185 const other = [5, 6, 7] |
22272
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
186 other->assert_equal([5, 6, 7]) |
22274
1634ca41e4d3
patch 8.2.1686: Vim9: "const!" not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
22272
diff
changeset
|
187 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
188 var varlist = [7, 8] |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22387
diff
changeset
|
189 const constlist = [1, varlist, 3] |
22274
1634ca41e4d3
patch 8.2.1686: Vim9: "const!" not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
22272
diff
changeset
|
190 varlist[0] = 77 |
25489
911fdca7f736
patch 8.2.3281: Vim9: TODO items in tests can be taken care of
Bram Moolenaar <Bram@vim.org>
parents:
25469
diff
changeset
|
191 constlist[1][1] = 88 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
192 var cl = constlist[1] |
22274
1634ca41e4d3
patch 8.2.1686: Vim9: "const!" not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
22272
diff
changeset
|
193 cl[1] = 88 |
1634ca41e4d3
patch 8.2.1686: Vim9: "const!" not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
22272
diff
changeset
|
194 constlist->assert_equal([1, [77, 88], 3]) |
1634ca41e4d3
patch 8.2.1686: Vim9: "const!" not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
22272
diff
changeset
|
195 |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23068
diff
changeset
|
196 var vardict = {five: 5, six: 6} |
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23068
diff
changeset
|
197 const constdict = {one: 1, two: vardict, three: 3} |
22274
1634ca41e4d3
patch 8.2.1686: Vim9: "const!" not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
22272
diff
changeset
|
198 vardict['five'] = 55 |
25489
911fdca7f736
patch 8.2.3281: Vim9: TODO items in tests can be taken care of
Bram Moolenaar <Bram@vim.org>
parents:
25469
diff
changeset
|
199 constdict['two']['six'] = 66 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
200 var cd = constdict['two'] |
22274
1634ca41e4d3
patch 8.2.1686: Vim9: "const!" not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
22272
diff
changeset
|
201 cd['six'] = 66 |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23068
diff
changeset
|
202 constdict->assert_equal({one: 1, two: {five: 55, six: 66}, three: 3}) |
22266
23f5750146d9
patch 8.2.1682: Vim9: const works in an unexpected way
Bram Moolenaar <Bram@vim.org>
parents:
22264
diff
changeset
|
203 END |
23f5750146d9
patch 8.2.1682: Vim9: const works in an unexpected way
Bram Moolenaar <Bram@vim.org>
parents:
22264
diff
changeset
|
204 CheckDefAndScriptSuccess(lines) |
22264
e0a4d029cb87
patch 8.2.1681: Vim9: unnessary :call commands in tests
Bram Moolenaar <Bram@vim.org>
parents:
22250
diff
changeset
|
205 enddef |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
206 |
22272
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
207 def Test_const_bang() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
208 var lines =<< trim END |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22387
diff
changeset
|
209 const var = 234 |
22272
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
210 var = 99 |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
211 END |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
212 CheckDefExecFailure(lines, 'E1018:', 2) |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
213 CheckScriptFailure(['vim9script'] + lines, 'E46:', 3) |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
214 |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
215 lines =<< trim END |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22387
diff
changeset
|
216 const ll = [2, 3, 4] |
22272
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
217 ll[0] = 99 |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
218 END |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
219 CheckDefExecFailure(lines, 'E1119:', 2) |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
220 CheckScriptFailure(['vim9script'] + lines, 'E741:', 3) |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
221 |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
222 lines =<< trim END |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22387
diff
changeset
|
223 const ll = [2, 3, 4] |
22272
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
224 ll[3] = 99 |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
225 END |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
226 CheckDefExecFailure(lines, 'E1118:', 2) |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
227 CheckScriptFailure(['vim9script'] + lines, 'E684:', 3) |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
228 |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
229 lines =<< trim END |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23068
diff
changeset
|
230 const dd = {one: 1, two: 2} |
22272
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
231 dd["one"] = 99 |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
232 END |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
233 CheckDefExecFailure(lines, 'E1121:', 2) |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
234 CheckScriptFailure(['vim9script'] + lines, 'E741:', 3) |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
235 |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
236 lines =<< trim END |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23068
diff
changeset
|
237 const dd = {one: 1, two: 2} |
22272
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
238 dd["three"] = 99 |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
239 END |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
240 CheckDefExecFailure(lines, 'E1120:') |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
241 CheckScriptFailure(['vim9script'] + lines, 'E741:', 3) |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
242 enddef |
eb1f5f618c75
patch 8.2.1685: Vim9: cannot declare a constant value
Bram Moolenaar <Bram@vim.org>
parents:
22266
diff
changeset
|
243 |
20982
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
244 def Test_range_no_colon() |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
245 CheckDefFailure(['%s/a/b/'], 'E1050:') |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
246 CheckDefFailure(['+ s/a/b/'], 'E1050:') |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
247 CheckDefFailure(['- s/a/b/'], 'E1050:') |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
248 CheckDefFailure(['. s/a/b/'], 'E1050:') |
20982
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
249 enddef |
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
250 |
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
251 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
252 def Test_block() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
253 var outer = 1 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
254 { |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
255 var inner = 2 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
256 assert_equal(1, outer) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
257 assert_equal(2, inner) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
258 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
259 assert_equal(1, outer) |
24027
8298c0798040
patch 8.2.2555: Vim9: missing test for 8.2.2553
Bram Moolenaar <Bram@vim.org>
parents:
24025
diff
changeset
|
260 |
8298c0798040
patch 8.2.2555: Vim9: missing test for 8.2.2553
Bram Moolenaar <Bram@vim.org>
parents:
24025
diff
changeset
|
261 {|echo 'yes'|} |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
262 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
263 |
22264
e0a4d029cb87
patch 8.2.1681: Vim9: unnessary :call commands in tests
Bram Moolenaar <Bram@vim.org>
parents:
22250
diff
changeset
|
264 def Test_block_failure() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
265 CheckDefFailure(['{', 'var inner = 1', '}', 'echo inner'], 'E1001:') |
22264
e0a4d029cb87
patch 8.2.1681: Vim9: unnessary :call commands in tests
Bram Moolenaar <Bram@vim.org>
parents:
22250
diff
changeset
|
266 CheckDefFailure(['}'], 'E1025:') |
e0a4d029cb87
patch 8.2.1681: Vim9: unnessary :call commands in tests
Bram Moolenaar <Bram@vim.org>
parents:
22250
diff
changeset
|
267 CheckDefFailure(['{', 'echo 1'], 'E1026:') |
e0a4d029cb87
patch 8.2.1681: Vim9: unnessary :call commands in tests
Bram Moolenaar <Bram@vim.org>
parents:
22250
diff
changeset
|
268 enddef |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
269 |
22596
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
270 def Test_block_local_vars() |
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
271 var lines =<< trim END |
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
272 vim9script |
22602
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
273 v:testing = 1 |
22596
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
274 if true |
22602
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
275 var text = ['hello'] |
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
276 def SayHello(): list<string> |
22596
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
277 return text |
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
278 enddef |
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
279 def SetText(v: string) |
22602
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
280 text = [v] |
22596
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
281 enddef |
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
282 endif |
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
283 |
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
284 if true |
22602
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
285 var text = ['again'] |
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
286 def SayAgain(): list<string> |
22596
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
287 return text |
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
288 enddef |
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
289 endif |
22602
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
290 |
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
291 # test that the "text" variables are not cleaned up |
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
292 test_garbagecollect_now() |
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
293 |
22596
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
294 defcompile |
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
295 |
22602
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
296 assert_equal(['hello'], SayHello()) |
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
297 assert_equal(['again'], SayAgain()) |
22596
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
298 |
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
299 SetText('foobar') |
22602
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
300 assert_equal(['foobar'], SayHello()) |
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
301 |
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
302 call writefile(['ok'], 'Xdidit') |
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
303 qall! |
22596
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
304 END |
22602
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
305 |
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
306 # need to execute this with a separate Vim instance to avoid the current |
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
307 # context gets garbage collected. |
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
308 writefile(lines, 'Xscript') |
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
309 RunVim([], [], '-S Xscript') |
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
310 assert_equal(['ok'], readfile('Xdidit')) |
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
311 |
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
312 delete('Xscript') |
2c77ec32deeb
patch 8.2.1849: Vim9: garbage collection frees block-local variables
Bram Moolenaar <Bram@vim.org>
parents:
22596
diff
changeset
|
313 delete('Xdidit') |
22596
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
314 enddef |
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
315 |
22643
71b57779177d
patch 8.2.1870: Vim9: no need to keep all script variables
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
316 def Test_block_local_vars_with_func() |
71b57779177d
patch 8.2.1870: Vim9: no need to keep all script variables
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
317 var lines =<< trim END |
71b57779177d
patch 8.2.1870: Vim9: no need to keep all script variables
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
318 vim9script |
71b57779177d
patch 8.2.1870: Vim9: no need to keep all script variables
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
319 if true |
71b57779177d
patch 8.2.1870: Vim9: no need to keep all script variables
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
320 var foo = 'foo' |
71b57779177d
patch 8.2.1870: Vim9: no need to keep all script variables
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
321 if true |
71b57779177d
patch 8.2.1870: Vim9: no need to keep all script variables
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
322 var bar = 'bar' |
71b57779177d
patch 8.2.1870: Vim9: no need to keep all script variables
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
323 def Func(): list<string> |
71b57779177d
patch 8.2.1870: Vim9: no need to keep all script variables
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
324 return [foo, bar] |
71b57779177d
patch 8.2.1870: Vim9: no need to keep all script variables
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
325 enddef |
71b57779177d
patch 8.2.1870: Vim9: no need to keep all script variables
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
326 endif |
71b57779177d
patch 8.2.1870: Vim9: no need to keep all script variables
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
327 endif |
71b57779177d
patch 8.2.1870: Vim9: no need to keep all script variables
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
328 # function is compiled here, after blocks have finished, can still access |
71b57779177d
patch 8.2.1870: Vim9: no need to keep all script variables
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
329 # "foo" and "bar" |
71b57779177d
patch 8.2.1870: Vim9: no need to keep all script variables
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
330 assert_equal(['foo', 'bar'], Func()) |
71b57779177d
patch 8.2.1870: Vim9: no need to keep all script variables
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
331 END |
71b57779177d
patch 8.2.1870: Vim9: no need to keep all script variables
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
332 CheckScriptSuccess(lines) |
71b57779177d
patch 8.2.1870: Vim9: no need to keep all script variables
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
333 enddef |
71b57779177d
patch 8.2.1870: Vim9: no need to keep all script variables
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
334 |
25469
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
335 " legacy func for command that's defined later |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
336 func InvokeSomeCommand() |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
337 SomeCommand |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
338 endfunc |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
339 |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
340 def Test_autocommand_block() |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
341 com SomeCommand { |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
342 g:someVar = 'some' |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
343 } |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
344 InvokeSomeCommand() |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
345 assert_equal('some', g:someVar) |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
346 |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
347 delcommand SomeCommand |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
348 unlet g:someVar |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
349 enddef |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
350 |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
351 def Test_command_block() |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
352 au BufNew *.xml { |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
353 g:otherVar = 'other' |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
354 } |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
355 split other.xml |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
356 assert_equal('other', g:otherVar) |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
357 |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
358 bwipe! |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
359 au! BufNew *.xml |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
360 unlet g:otherVar |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
361 enddef |
dcd45fe7fe2e
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25425
diff
changeset
|
362 |
21375
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
363 func g:NoSuchFunc() |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
364 echo 'none' |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
365 endfunc |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
366 |
23576
4cd173b3d572
patch 8.2.2330: Vim9: crash when using :trow in a not executed block
Bram Moolenaar <Bram@vim.org>
parents:
23571
diff
changeset
|
367 def Test_try_catch_throw() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
368 var l = [] |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
369 try # comment |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
370 add(l, '1') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
371 throw 'wrong' |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
372 add(l, '2') |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
373 catch # comment |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
374 add(l, v:exception) |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
375 finally # comment |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
376 add(l, '3') |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
377 endtry # comment |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
378 assert_equal(['1', 'wrong', '3'], l) |
21359
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
379 |
21371
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
380 l = [] |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
381 try |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
382 try |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
383 add(l, '1') |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
384 throw 'wrong' |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
385 add(l, '2') |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
386 catch /right/ |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
387 add(l, v:exception) |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
388 endtry |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
389 catch /wrong/ |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
390 add(l, 'caught') |
22395
03249b8976a9
patch 8.2.1746: Vim9: cannot use "fina" for "finally"
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
391 fina |
21371
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
392 add(l, 'finally') |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
393 endtry |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
394 assert_equal(['1', 'caught', 'finally'], l) |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
395 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
396 var n: number |
21359
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
397 try |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
398 n = l[3] |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
399 catch /E684:/ |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
400 n = 99 |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
401 endtry |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
402 assert_equal(99, n) |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
403 |
23440
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
404 var done = 'no' |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
405 if 0 |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
406 try | catch | endtry |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
407 else |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
408 done = 'yes' |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
409 endif |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
410 assert_equal('yes', done) |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
411 |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
412 done = 'no' |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
413 if 1 |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
414 done = 'yes' |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
415 else |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
416 try | catch | endtry |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
417 done = 'never' |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
418 endif |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
419 assert_equal('yes', done) |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
420 |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
421 if 1 |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
422 else |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
423 try | catch /pat/ | endtry |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
424 try | catch /pat/ |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
425 endtry |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
426 try |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
427 catch /pat/ | endtry |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
428 try |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
429 catch /pat/ |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
430 endtry |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
431 endif |
b0587f7ec422
patch 8.2.2263: Vim9: compilation error with try-catch in skipped block
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
432 |
21359
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
433 try |
21833
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
434 # string slice returns a string, not a number |
21359
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
435 n = g:astring[3] |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22274
diff
changeset
|
436 catch /E1012:/ |
21359
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
437 n = 77 |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
438 endtry |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
439 assert_equal(77, n) |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
440 |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
441 try |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
442 n = l[g:astring] |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22274
diff
changeset
|
443 catch /E1012:/ |
21831
d8422de73113
patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
444 n = 88 |
21359
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
445 endtry |
21831
d8422de73113
patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
446 assert_equal(88, n) |
21359
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
447 |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
448 try |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
449 n = s:does_not_exist |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
450 catch /E121:/ |
21365
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
451 n = 111 |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
452 endtry |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
453 assert_equal(111, n) |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
454 |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
455 try |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
456 n = g:does_not_exist |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
457 catch /E121:/ |
21359
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
458 n = 121 |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
459 endtry |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
460 assert_equal(121, n) |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
461 |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23068
diff
changeset
|
462 var d = {one: 1} |
21359
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
463 try |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
464 n = d[g:astring] |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
465 catch /E716:/ |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
466 n = 222 |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
467 endtry |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
468 assert_equal(222, n) |
21365
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
469 |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
470 try |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
471 n = -g:astring |
25634
27cb2e79ccde
patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25551
diff
changeset
|
472 catch /E1012:/ |
21365
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
473 n = 233 |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
474 endtry |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
475 assert_equal(233, n) |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
476 |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
477 try |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
478 n = +g:astring |
25634
27cb2e79ccde
patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25551
diff
changeset
|
479 catch /E1012:/ |
21365
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
480 n = 244 |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
481 endtry |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
482 assert_equal(244, n) |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
483 |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
484 try |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
485 n = +g:alist |
25634
27cb2e79ccde
patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25551
diff
changeset
|
486 catch /E1012:/ |
21365
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
487 n = 255 |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
488 endtry |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
489 assert_equal(255, n) |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
490 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
491 var nd: dict<any> |
21365
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
492 try |
23827
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23790
diff
changeset
|
493 nd = {[g:alist]: 1} |
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23790
diff
changeset
|
494 catch /E1105:/ |
21365
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
495 n = 266 |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
496 endtry |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
497 assert_equal(266, n) |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
498 |
26372
f5727e2603f0
patch 8.2.3717: Vim9: error for constant list size is only given at runtime
Bram Moolenaar <Bram@vim.org>
parents:
26238
diff
changeset
|
499 l = [1, 2, 3] |
21365
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
500 try |
26372
f5727e2603f0
patch 8.2.3717: Vim9: error for constant list size is only given at runtime
Bram Moolenaar <Bram@vim.org>
parents:
26238
diff
changeset
|
501 [n] = l |
21365
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
502 catch /E1093:/ |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
503 n = 277 |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
504 endtry |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
505 assert_equal(277, n) |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
506 |
21371
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
507 try |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
508 &ts = g:astring |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22274
diff
changeset
|
509 catch /E1012:/ |
21371
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
510 n = 288 |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
511 endtry |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
512 assert_equal(288, n) |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
513 |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
514 try |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
515 &backspace = 'asdf' |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
516 catch /E474:/ |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
517 n = 299 |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
518 endtry |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
519 assert_equal(299, n) |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
520 |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
521 l = [1] |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
522 try |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
523 l[3] = 3 |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
524 catch /E684:/ |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
525 n = 300 |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
526 endtry |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
527 assert_equal(300, n) |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
528 |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
529 try |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
530 unlet g:does_not_exist |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
531 catch /E108:/ |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
532 n = 322 |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
533 endtry |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
534 assert_equal(322, n) |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
535 |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
536 try |
22936
00b0275ffe7f
patch 8.2.2015: Vim9: literal dict #{} is not like any other language
Bram Moolenaar <Bram@vim.org>
parents:
22810
diff
changeset
|
537 d = {text: 1, [g:astring]: 2} |
21371
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
538 catch /E721:/ |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
539 n = 333 |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
540 endtry |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
541 assert_equal(333, n) |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
542 |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
543 try |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
544 l = DeletedFunc() |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
545 catch /E933:/ |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
546 n = 344 |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
547 endtry |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
548 assert_equal(344, n) |
21375
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
549 |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
550 try |
25368
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25358
diff
changeset
|
551 echo range(1, 2, 0) |
1ffa8eb30353
patch 8.2.3221: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25358
diff
changeset
|
552 catch /E726:/ |
21375
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
553 n = 355 |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
554 endtry |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
555 assert_equal(355, n) |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
556 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
557 var P = function('g:NoSuchFunc') |
21375
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
558 delfunc g:NoSuchFunc |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
559 try |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
560 echo P() |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
561 catch /E117:/ |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
562 n = 366 |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
563 endtry |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
564 assert_equal(366, n) |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
565 |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
566 try |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
567 echo g:NoSuchFunc() |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
568 catch /E117:/ |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
569 n = 377 |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
570 endtry |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
571 assert_equal(377, n) |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
572 |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
573 try |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
574 echo g:alist + 4 |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
575 catch /E745:/ |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
576 n = 388 |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
577 endtry |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
578 assert_equal(388, n) |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
579 |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
580 try |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
581 echo 4 + g:alist |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
582 catch /E745:/ |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
583 n = 399 |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
584 endtry |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
585 assert_equal(399, n) |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
586 |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
587 try |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
588 echo g:alist.member |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
589 catch /E715:/ |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
590 n = 400 |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
591 endtry |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
592 assert_equal(400, n) |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
593 |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
594 try |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
595 echo d.member |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
596 catch /E716:/ |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
597 n = 411 |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
598 endtry |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
599 assert_equal(411, n) |
23921
a834f9c082e3
patch 8.2.2503: Vim9: a caught error may leave something on the stack
Bram Moolenaar <Bram@vim.org>
parents:
23886
diff
changeset
|
600 |
a834f9c082e3
patch 8.2.2503: Vim9: a caught error may leave something on the stack
Bram Moolenaar <Bram@vim.org>
parents:
23886
diff
changeset
|
601 var counter = 0 |
a834f9c082e3
patch 8.2.2503: Vim9: a caught error may leave something on the stack
Bram Moolenaar <Bram@vim.org>
parents:
23886
diff
changeset
|
602 for i in range(4) |
a834f9c082e3
patch 8.2.2503: Vim9: a caught error may leave something on the stack
Bram Moolenaar <Bram@vim.org>
parents:
23886
diff
changeset
|
603 try |
a834f9c082e3
patch 8.2.2503: Vim9: a caught error may leave something on the stack
Bram Moolenaar <Bram@vim.org>
parents:
23886
diff
changeset
|
604 eval [][0] |
a834f9c082e3
patch 8.2.2503: Vim9: a caught error may leave something on the stack
Bram Moolenaar <Bram@vim.org>
parents:
23886
diff
changeset
|
605 catch |
a834f9c082e3
patch 8.2.2503: Vim9: a caught error may leave something on the stack
Bram Moolenaar <Bram@vim.org>
parents:
23886
diff
changeset
|
606 endtry |
a834f9c082e3
patch 8.2.2503: Vim9: a caught error may leave something on the stack
Bram Moolenaar <Bram@vim.org>
parents:
23886
diff
changeset
|
607 counter += 1 |
a834f9c082e3
patch 8.2.2503: Vim9: a caught error may leave something on the stack
Bram Moolenaar <Bram@vim.org>
parents:
23886
diff
changeset
|
608 endfor |
a834f9c082e3
patch 8.2.2503: Vim9: a caught error may leave something on the stack
Bram Moolenaar <Bram@vim.org>
parents:
23886
diff
changeset
|
609 assert_equal(4, counter) |
23994
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23980
diff
changeset
|
610 |
25304
d39c12f97298
patch 8.2.3189: Vim9: error when using "try|"
Bram Moolenaar <Bram@vim.org>
parents:
25298
diff
changeset
|
611 # no requirement for spaces before | |
d39c12f97298
patch 8.2.3189: Vim9: error when using "try|"
Bram Moolenaar <Bram@vim.org>
parents:
25298
diff
changeset
|
612 try|echo 0|catch|endtry |
d39c12f97298
patch 8.2.3189: Vim9: error when using "try|"
Bram Moolenaar <Bram@vim.org>
parents:
25298
diff
changeset
|
613 |
26658
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
614 # return in try with finally |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
615 def ReturnInTry(): number |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
616 var ret = 4 |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
617 try |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
618 return ret |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
619 catch /this/ |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
620 return -1 |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
621 catch /that/ |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
622 return -1 |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
623 finally |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
624 # changing ret has no effect |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
625 ret = 7 |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
626 endtry |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
627 return -2 |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
628 enddef |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
629 assert_equal(4, ReturnInTry()) |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
630 |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
631 # return in catch with finally |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
632 def ReturnInCatch(): number |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
633 var ret = 5 |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
634 try |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
635 throw 'getout' |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
636 return -1 |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
637 catch /getout/ |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
638 # ret is evaluated here |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
639 return ret |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
640 finally |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
641 # changing ret later has no effect |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
642 ret = -3 |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
643 endtry |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
644 return -2 |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
645 enddef |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
646 assert_equal(5, ReturnInCatch()) |
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
647 |
23994
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23980
diff
changeset
|
648 # return in finally after empty catch |
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23980
diff
changeset
|
649 def ReturnInFinally(): number |
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23980
diff
changeset
|
650 try |
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23980
diff
changeset
|
651 finally |
26658
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
652 return 6 |
23994
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23980
diff
changeset
|
653 endtry |
26658
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
654 return -1 |
23994
3daeb2060f25
patch 8.2.2539: Vim9: return from finally block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
23980
diff
changeset
|
655 enddef |
26658
ed73553992bf
patch 8.2.3858: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
656 assert_equal(6, ReturnInFinally()) |
24934
75bd12f3bfeb
patch 8.2.3004: Vim9: error for missing colon given while skipping
Bram Moolenaar <Bram@vim.org>
parents:
24786
diff
changeset
|
657 |
75bd12f3bfeb
patch 8.2.3004: Vim9: error for missing colon given while skipping
Bram Moolenaar <Bram@vim.org>
parents:
24786
diff
changeset
|
658 var lines =<< trim END |
75bd12f3bfeb
patch 8.2.3004: Vim9: error for missing colon given while skipping
Bram Moolenaar <Bram@vim.org>
parents:
24786
diff
changeset
|
659 vim9script |
75bd12f3bfeb
patch 8.2.3004: Vim9: error for missing colon given while skipping
Bram Moolenaar <Bram@vim.org>
parents:
24786
diff
changeset
|
660 try |
75bd12f3bfeb
patch 8.2.3004: Vim9: error for missing colon given while skipping
Bram Moolenaar <Bram@vim.org>
parents:
24786
diff
changeset
|
661 acos('0.5') |
75bd12f3bfeb
patch 8.2.3004: Vim9: error for missing colon given while skipping
Bram Moolenaar <Bram@vim.org>
parents:
24786
diff
changeset
|
662 ->setline(1) |
75bd12f3bfeb
patch 8.2.3004: Vim9: error for missing colon given while skipping
Bram Moolenaar <Bram@vim.org>
parents:
24786
diff
changeset
|
663 catch |
75bd12f3bfeb
patch 8.2.3004: Vim9: error for missing colon given while skipping
Bram Moolenaar <Bram@vim.org>
parents:
24786
diff
changeset
|
664 g:caught = v:exception |
75bd12f3bfeb
patch 8.2.3004: Vim9: error for missing colon given while skipping
Bram Moolenaar <Bram@vim.org>
parents:
24786
diff
changeset
|
665 endtry |
75bd12f3bfeb
patch 8.2.3004: Vim9: error for missing colon given while skipping
Bram Moolenaar <Bram@vim.org>
parents:
24786
diff
changeset
|
666 END |
75bd12f3bfeb
patch 8.2.3004: Vim9: error for missing colon given while skipping
Bram Moolenaar <Bram@vim.org>
parents:
24786
diff
changeset
|
667 CheckScriptSuccess(lines) |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25368
diff
changeset
|
668 assert_match('E1219: Float or Number required for argument 1', g:caught) |
24934
75bd12f3bfeb
patch 8.2.3004: Vim9: error for missing colon given while skipping
Bram Moolenaar <Bram@vim.org>
parents:
24786
diff
changeset
|
669 unlet g:caught |
25124
075790758d11
patch 8.2.3099: Vim9: missing catch/finally not reported at script level
Bram Moolenaar <Bram@vim.org>
parents:
25082
diff
changeset
|
670 |
075790758d11
patch 8.2.3099: Vim9: missing catch/finally not reported at script level
Bram Moolenaar <Bram@vim.org>
parents:
25082
diff
changeset
|
671 # missing catch and/or finally |
075790758d11
patch 8.2.3099: Vim9: missing catch/finally not reported at script level
Bram Moolenaar <Bram@vim.org>
parents:
25082
diff
changeset
|
672 lines =<< trim END |
075790758d11
patch 8.2.3099: Vim9: missing catch/finally not reported at script level
Bram Moolenaar <Bram@vim.org>
parents:
25082
diff
changeset
|
673 vim9script |
075790758d11
patch 8.2.3099: Vim9: missing catch/finally not reported at script level
Bram Moolenaar <Bram@vim.org>
parents:
25082
diff
changeset
|
674 try |
075790758d11
patch 8.2.3099: Vim9: missing catch/finally not reported at script level
Bram Moolenaar <Bram@vim.org>
parents:
25082
diff
changeset
|
675 echo 'something' |
075790758d11
patch 8.2.3099: Vim9: missing catch/finally not reported at script level
Bram Moolenaar <Bram@vim.org>
parents:
25082
diff
changeset
|
676 endtry |
075790758d11
patch 8.2.3099: Vim9: missing catch/finally not reported at script level
Bram Moolenaar <Bram@vim.org>
parents:
25082
diff
changeset
|
677 END |
075790758d11
patch 8.2.3099: Vim9: missing catch/finally not reported at script level
Bram Moolenaar <Bram@vim.org>
parents:
25082
diff
changeset
|
678 CheckScriptFailure(lines, 'E1032:') |
25537
e0d6268c153a
patch 8.2.3305: Vim9: :finally in skipped block not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
679 |
e0d6268c153a
patch 8.2.3305: Vim9: :finally in skipped block not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
680 # skipping try-finally-endtry when try-finally-endtry is used in another block |
e0d6268c153a
patch 8.2.3305: Vim9: :finally in skipped block not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
681 lines =<< trim END |
e0d6268c153a
patch 8.2.3305: Vim9: :finally in skipped block not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
682 if v:true |
e0d6268c153a
patch 8.2.3305: Vim9: :finally in skipped block not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
683 try |
e0d6268c153a
patch 8.2.3305: Vim9: :finally in skipped block not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
684 finally |
e0d6268c153a
patch 8.2.3305: Vim9: :finally in skipped block not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
685 endtry |
e0d6268c153a
patch 8.2.3305: Vim9: :finally in skipped block not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
686 else |
e0d6268c153a
patch 8.2.3305: Vim9: :finally in skipped block not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
687 try |
e0d6268c153a
patch 8.2.3305: Vim9: :finally in skipped block not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
688 finally |
e0d6268c153a
patch 8.2.3305: Vim9: :finally in skipped block not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
689 endtry |
e0d6268c153a
patch 8.2.3305: Vim9: :finally in skipped block not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
690 endif |
e0d6268c153a
patch 8.2.3305: Vim9: :finally in skipped block not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
691 END |
e0d6268c153a
patch 8.2.3305: Vim9: :finally in skipped block not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
692 CheckDefAndScriptSuccess(lines) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
693 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
694 |
25078
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
695 def Test_try_in_catch() |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
696 var lines =<< trim END |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
697 vim9script |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
698 var seq = [] |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
699 def DoIt() |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
700 try |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
701 seq->add('throw 1') |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
702 eval [][0] |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
703 seq->add('notreached') |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
704 catch |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
705 seq->add('catch') |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
706 try |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
707 seq->add('throw 2') |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
708 eval [][0] |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
709 seq->add('notreached') |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
710 catch /nothing/ |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
711 seq->add('notreached') |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
712 endtry |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
713 seq->add('done') |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
714 endtry |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
715 enddef |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
716 DoIt() |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
717 assert_equal(['throw 1', 'catch', 'throw 2', 'done'], seq) |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
718 END |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
719 enddef |
eac6e5a94e9d
patch 8.2.3076: Vim9: using try in catch block causes a hang
Bram Moolenaar <Bram@vim.org>
parents:
25057
diff
changeset
|
720 |
25080
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
721 def Test_error_in_catch() |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
722 var lines =<< trim END |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
723 try |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
724 eval [][0] |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
725 catch /E684:/ |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
726 eval [][0] |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
727 endtry |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
728 END |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
729 CheckDefExecFailure(lines, 'E684:', 4) |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
730 enddef |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
731 |
24122
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
732 " :while at the very start of a function that :continue jumps to |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
733 def TryContinueFunc() |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
734 while g:Count < 2 |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
735 g:sequence ..= 't' |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
736 try |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
737 echoerr 'Test' |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
738 catch |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
739 g:Count += 1 |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
740 g:sequence ..= 'c' |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
741 continue |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
742 endtry |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
743 g:sequence ..= 'e' |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
744 g:Count += 1 |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
745 endwhile |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
746 enddef |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
747 |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
748 def Test_continue_in_try_in_while() |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
749 g:Count = 0 |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
750 g:sequence = '' |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
751 TryContinueFunc() |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
752 assert_equal('tctc', g:sequence) |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
753 unlet g:Count |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
754 unlet g:sequence |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
755 enddef |
e8b21a3bb0d5
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Bram Moolenaar <Bram@vim.org>
parents:
24114
diff
changeset
|
756 |
24002
5dbed4837ea3
patch 8.2.2543: Vim9: a return inside try/catch does not restore properly
Bram Moolenaar <Bram@vim.org>
parents:
23994
diff
changeset
|
757 def Test_nocatch_return_in_try() |
5dbed4837ea3
patch 8.2.2543: Vim9: a return inside try/catch does not restore properly
Bram Moolenaar <Bram@vim.org>
parents:
23994
diff
changeset
|
758 # return in try block returns normally |
5dbed4837ea3
patch 8.2.2543: Vim9: a return inside try/catch does not restore properly
Bram Moolenaar <Bram@vim.org>
parents:
23994
diff
changeset
|
759 def ReturnInTry(): string |
5dbed4837ea3
patch 8.2.2543: Vim9: a return inside try/catch does not restore properly
Bram Moolenaar <Bram@vim.org>
parents:
23994
diff
changeset
|
760 try |
5dbed4837ea3
patch 8.2.2543: Vim9: a return inside try/catch does not restore properly
Bram Moolenaar <Bram@vim.org>
parents:
23994
diff
changeset
|
761 return '"some message"' |
5dbed4837ea3
patch 8.2.2543: Vim9: a return inside try/catch does not restore properly
Bram Moolenaar <Bram@vim.org>
parents:
23994
diff
changeset
|
762 catch |
5dbed4837ea3
patch 8.2.2543: Vim9: a return inside try/catch does not restore properly
Bram Moolenaar <Bram@vim.org>
parents:
23994
diff
changeset
|
763 endtry |
5dbed4837ea3
patch 8.2.2543: Vim9: a return inside try/catch does not restore properly
Bram Moolenaar <Bram@vim.org>
parents:
23994
diff
changeset
|
764 return 'not reached' |
5dbed4837ea3
patch 8.2.2543: Vim9: a return inside try/catch does not restore properly
Bram Moolenaar <Bram@vim.org>
parents:
23994
diff
changeset
|
765 enddef |
5dbed4837ea3
patch 8.2.2543: Vim9: a return inside try/catch does not restore properly
Bram Moolenaar <Bram@vim.org>
parents:
23994
diff
changeset
|
766 exe 'echoerr ' .. ReturnInTry() |
5dbed4837ea3
patch 8.2.2543: Vim9: a return inside try/catch does not restore properly
Bram Moolenaar <Bram@vim.org>
parents:
23994
diff
changeset
|
767 enddef |
5dbed4837ea3
patch 8.2.2543: Vim9: a return inside try/catch does not restore properly
Bram Moolenaar <Bram@vim.org>
parents:
23994
diff
changeset
|
768 |
23656
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
769 def Test_cnext_works_in_catch() |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
770 var lines =<< trim END |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
771 vim9script |
25202
e5d85e83a887
patch 8.2.3137: Vim9: no error when a line only has a variable name
Bram Moolenaar <Bram@vim.org>
parents:
25188
diff
changeset
|
772 au BufEnter * eval 1 + 2 |
23656
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
773 writefile(['text'], 'Xfile1') |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
774 writefile(['text'], 'Xfile2') |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
775 var items = [ |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
776 {lnum: 1, filename: 'Xfile1', valid: true}, |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
777 {lnum: 1, filename: 'Xfile2', valid: true} |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
778 ] |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
779 setqflist([], ' ', {items: items}) |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
780 cwindow |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
781 |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
782 def CnextOrCfirst() |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
783 # if cnext fails, cfirst is used |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
784 try |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
785 cnext |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
786 catch |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
787 cfirst |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
788 endtry |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
789 enddef |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
790 |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
791 CnextOrCfirst() |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
792 CnextOrCfirst() |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
793 writefile([getqflist({idx: 0}).idx], 'Xresult') |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
794 qall |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
795 END |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
796 writefile(lines, 'XCatchCnext') |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
797 RunVim([], [], '--clean -S XCatchCnext') |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
798 assert_equal(['1'], readfile('Xresult')) |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
799 |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
800 delete('Xfile1') |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
801 delete('Xfile2') |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
802 delete('XCatchCnext') |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
803 delete('Xresult') |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
804 enddef |
c6f7df86cd9d
patch 8.2.2370: Vim9: command fails in catch block
Bram Moolenaar <Bram@vim.org>
parents:
23618
diff
changeset
|
805 |
23576
4cd173b3d572
patch 8.2.2330: Vim9: crash when using :trow in a not executed block
Bram Moolenaar <Bram@vim.org>
parents:
23571
diff
changeset
|
806 def Test_throw_skipped() |
4cd173b3d572
patch 8.2.2330: Vim9: crash when using :trow in a not executed block
Bram Moolenaar <Bram@vim.org>
parents:
23571
diff
changeset
|
807 if 0 |
4cd173b3d572
patch 8.2.2330: Vim9: crash when using :trow in a not executed block
Bram Moolenaar <Bram@vim.org>
parents:
23571
diff
changeset
|
808 throw dontgethere |
4cd173b3d572
patch 8.2.2330: Vim9: crash when using :trow in a not executed block
Bram Moolenaar <Bram@vim.org>
parents:
23571
diff
changeset
|
809 endif |
4cd173b3d572
patch 8.2.2330: Vim9: crash when using :trow in a not executed block
Bram Moolenaar <Bram@vim.org>
parents:
23571
diff
changeset
|
810 enddef |
4cd173b3d572
patch 8.2.2330: Vim9: crash when using :trow in a not executed block
Bram Moolenaar <Bram@vim.org>
parents:
23571
diff
changeset
|
811 |
23618
d228ca435f3a
patch 8.2.2351: Vim9: error msg for "throw" in function called with "silent!"
Bram Moolenaar <Bram@vim.org>
parents:
23576
diff
changeset
|
812 def Test_nocatch_throw_silenced() |
d228ca435f3a
patch 8.2.2351: Vim9: error msg for "throw" in function called with "silent!"
Bram Moolenaar <Bram@vim.org>
parents:
23576
diff
changeset
|
813 var lines =<< trim END |
d228ca435f3a
patch 8.2.2351: Vim9: error msg for "throw" in function called with "silent!"
Bram Moolenaar <Bram@vim.org>
parents:
23576
diff
changeset
|
814 vim9script |
d228ca435f3a
patch 8.2.2351: Vim9: error msg for "throw" in function called with "silent!"
Bram Moolenaar <Bram@vim.org>
parents:
23576
diff
changeset
|
815 def Func() |
d228ca435f3a
patch 8.2.2351: Vim9: error msg for "throw" in function called with "silent!"
Bram Moolenaar <Bram@vim.org>
parents:
23576
diff
changeset
|
816 throw 'error' |
d228ca435f3a
patch 8.2.2351: Vim9: error msg for "throw" in function called with "silent!"
Bram Moolenaar <Bram@vim.org>
parents:
23576
diff
changeset
|
817 enddef |
d228ca435f3a
patch 8.2.2351: Vim9: error msg for "throw" in function called with "silent!"
Bram Moolenaar <Bram@vim.org>
parents:
23576
diff
changeset
|
818 silent! Func() |
d228ca435f3a
patch 8.2.2351: Vim9: error msg for "throw" in function called with "silent!"
Bram Moolenaar <Bram@vim.org>
parents:
23576
diff
changeset
|
819 END |
d228ca435f3a
patch 8.2.2351: Vim9: error msg for "throw" in function called with "silent!"
Bram Moolenaar <Bram@vim.org>
parents:
23576
diff
changeset
|
820 writefile(lines, 'XthrowSilenced') |
d228ca435f3a
patch 8.2.2351: Vim9: error msg for "throw" in function called with "silent!"
Bram Moolenaar <Bram@vim.org>
parents:
23576
diff
changeset
|
821 source XthrowSilenced |
d228ca435f3a
patch 8.2.2351: Vim9: error msg for "throw" in function called with "silent!"
Bram Moolenaar <Bram@vim.org>
parents:
23576
diff
changeset
|
822 delete('XthrowSilenced') |
d228ca435f3a
patch 8.2.2351: Vim9: error msg for "throw" in function called with "silent!"
Bram Moolenaar <Bram@vim.org>
parents:
23576
diff
changeset
|
823 enddef |
d228ca435f3a
patch 8.2.2351: Vim9: error msg for "throw" in function called with "silent!"
Bram Moolenaar <Bram@vim.org>
parents:
23576
diff
changeset
|
824 |
21371
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
825 def DeletedFunc(): list<any> |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
826 return ['delete me'] |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
827 enddef |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
828 defcompile |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
829 delfunc DeletedFunc |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
830 |
19445
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
831 def ThrowFromDef() |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
832 throw "getout" # comment |
19445
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
833 enddef |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
834 |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
835 func CatchInFunc() |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
836 try |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
837 call ThrowFromDef() |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
838 catch |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
839 let g:thrown_func = v:exception |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
840 endtry |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
841 endfunc |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
842 |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
843 def CatchInDef() |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
844 try |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
845 ThrowFromDef() |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
846 catch |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
847 g:thrown_def = v:exception |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
848 endtry |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
849 enddef |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
850 |
19459
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
851 def ReturnFinally(): string |
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
852 try |
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
853 return 'intry' |
22395
03249b8976a9
patch 8.2.1746: Vim9: cannot use "fina" for "finally"
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
854 finall |
19459
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
855 g:in_finally = 'finally' |
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
856 endtry |
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
857 return 'end' |
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
858 enddef |
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
859 |
19445
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
860 def Test_try_catch_nested() |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
861 CatchInFunc() |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
862 assert_equal('getout', g:thrown_func) |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
863 |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
864 CatchInDef() |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
865 assert_equal('getout', g:thrown_def) |
19459
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
866 |
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
867 assert_equal('intry', ReturnFinally()) |
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
868 assert_equal('finally', g:in_finally) |
25080
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
869 |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
870 var l = [] |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
871 try |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
872 l->add('1') |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
873 throw 'bad' |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
874 l->add('x') |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
875 catch /bad/ |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
876 l->add('2') |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
877 try |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
878 l->add('3') |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
879 throw 'one' |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
880 l->add('x') |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
881 catch /one/ |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
882 l->add('4') |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
883 try |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
884 l->add('5') |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
885 throw 'more' |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
886 l->add('x') |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
887 catch /more/ |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
888 l->add('6') |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
889 endtry |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
890 endtry |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
891 endtry |
146c9720e563
patch 8.2.3077: Vim9: an error in a catch block is not reported
Bram Moolenaar <Bram@vim.org>
parents:
25078
diff
changeset
|
892 assert_equal(['1', '2', '3', '4', '5', '6'], l) |
25082
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
893 |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
894 l = [] |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
895 try |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
896 try |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
897 l->add('1') |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
898 throw 'foo' |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
899 l->add('x') |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
900 catch |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
901 l->add('2') |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
902 throw 'bar' |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
903 l->add('x') |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
904 finally |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
905 l->add('3') |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
906 endtry |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
907 l->add('x') |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
908 catch /bar/ |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
909 l->add('4') |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
910 endtry |
5c7a09cf97a1
patch 8.2.3078: Vim9: profile test fails
Bram Moolenaar <Bram@vim.org>
parents:
25080
diff
changeset
|
911 assert_equal(['1', '2', '3', '4'], l) |
19459
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
912 enddef |
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
913 |
22302
36e8e046c335
patch 8.2.1700: Vim9: try/catch causes wrong value to be returned
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
914 def TryOne(): number |
36e8e046c335
patch 8.2.1700: Vim9: try/catch causes wrong value to be returned
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
915 try |
36e8e046c335
patch 8.2.1700: Vim9: try/catch causes wrong value to be returned
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
916 return 0 |
36e8e046c335
patch 8.2.1700: Vim9: try/catch causes wrong value to be returned
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
917 catch |
36e8e046c335
patch 8.2.1700: Vim9: try/catch causes wrong value to be returned
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
918 endtry |
36e8e046c335
patch 8.2.1700: Vim9: try/catch causes wrong value to be returned
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
919 return 0 |
36e8e046c335
patch 8.2.1700: Vim9: try/catch causes wrong value to be returned
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
920 enddef |
36e8e046c335
patch 8.2.1700: Vim9: try/catch causes wrong value to be returned
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
921 |
36e8e046c335
patch 8.2.1700: Vim9: try/catch causes wrong value to be returned
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
922 def TryTwo(n: number): string |
36e8e046c335
patch 8.2.1700: Vim9: try/catch causes wrong value to be returned
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
923 try |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
924 var x = {} |
22302
36e8e046c335
patch 8.2.1700: Vim9: try/catch causes wrong value to be returned
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
925 catch |
36e8e046c335
patch 8.2.1700: Vim9: try/catch causes wrong value to be returned
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
926 endtry |
36e8e046c335
patch 8.2.1700: Vim9: try/catch causes wrong value to be returned
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
927 return 'text' |
36e8e046c335
patch 8.2.1700: Vim9: try/catch causes wrong value to be returned
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
928 enddef |
36e8e046c335
patch 8.2.1700: Vim9: try/catch causes wrong value to be returned
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
929 |
36e8e046c335
patch 8.2.1700: Vim9: try/catch causes wrong value to be returned
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
930 def Test_try_catch_twice() |
36e8e046c335
patch 8.2.1700: Vim9: try/catch causes wrong value to be returned
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
931 assert_equal('text', TryOne()->TryTwo()) |
36e8e046c335
patch 8.2.1700: Vim9: try/catch causes wrong value to be returned
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
932 enddef |
36e8e046c335
patch 8.2.1700: Vim9: try/catch causes wrong value to be returned
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
933 |
19459
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
934 def Test_try_catch_match() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
935 var seq = 'a' |
19459
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
936 try |
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
937 throw 'something' |
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
938 catch /nothing/ |
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
939 seq ..= 'x' |
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
940 catch /some/ |
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
941 seq ..= 'b' |
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
942 catch /asdf/ |
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
943 seq ..= 'x' |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
944 catch ?a\?sdf? |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
945 seq ..= 'y' |
19459
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
946 finally |
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
947 seq ..= 'c' |
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
948 endtry |
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
949 assert_equal('abc', seq) |
19445
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
950 enddef |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
951 |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
952 def Test_try_catch_fails() |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
953 CheckDefFailure(['catch'], 'E603:') |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
954 CheckDefFailure(['try', 'echo 0', 'catch', 'catch'], 'E1033:') |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
955 CheckDefFailure(['try', 'echo 0', 'catch /pat'], 'E1067:') |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
956 CheckDefFailure(['finally'], 'E606:') |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
957 CheckDefFailure(['try', 'echo 0', 'finally', 'echo 1', 'finally'], 'E607:') |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
958 CheckDefFailure(['endtry'], 'E602:') |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
959 CheckDefFailure(['while 1', 'endtry'], 'E170:') |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
960 CheckDefFailure(['for i in range(5)', 'endtry'], 'E170:') |
22500
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22458
diff
changeset
|
961 CheckDefFailure(['if 1', 'endtry'], 'E171:') |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
962 CheckDefFailure(['try', 'echo 1', 'endtry'], 'E1032:') |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
963 |
23183
4d5d12138b36
patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents:
23179
diff
changeset
|
964 CheckDefFailure(['throw'], 'E1143:') |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
965 CheckDefFailure(['throw xxx'], 'E1001:') |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
966 enddef |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
967 |
23950
4279c1c66df1
patch 8.2.2517: Vim9: fix for s390 not tested on other systems
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
968 def Try_catch_skipped() |
4279c1c66df1
patch 8.2.2517: Vim9: fix for s390 not tested on other systems
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
969 var l = [] |
4279c1c66df1
patch 8.2.2517: Vim9: fix for s390 not tested on other systems
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
970 try |
4279c1c66df1
patch 8.2.2517: Vim9: fix for s390 not tested on other systems
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
971 finally |
4279c1c66df1
patch 8.2.2517: Vim9: fix for s390 not tested on other systems
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
972 endtry |
4279c1c66df1
patch 8.2.2517: Vim9: fix for s390 not tested on other systems
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
973 |
4279c1c66df1
patch 8.2.2517: Vim9: fix for s390 not tested on other systems
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
974 if 1 |
4279c1c66df1
patch 8.2.2517: Vim9: fix for s390 not tested on other systems
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
975 else |
4279c1c66df1
patch 8.2.2517: Vim9: fix for s390 not tested on other systems
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
976 try |
4279c1c66df1
patch 8.2.2517: Vim9: fix for s390 not tested on other systems
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
977 endtry |
4279c1c66df1
patch 8.2.2517: Vim9: fix for s390 not tested on other systems
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
978 endif |
4279c1c66df1
patch 8.2.2517: Vim9: fix for s390 not tested on other systems
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
979 enddef |
4279c1c66df1
patch 8.2.2517: Vim9: fix for s390 not tested on other systems
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
980 |
4279c1c66df1
patch 8.2.2517: Vim9: fix for s390 not tested on other systems
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
981 " The skipped try/endtry was updating the wrong instruction. |
4279c1c66df1
patch 8.2.2517: Vim9: fix for s390 not tested on other systems
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
982 def Test_try_catch_skipped() |
4279c1c66df1
patch 8.2.2517: Vim9: fix for s390 not tested on other systems
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
983 var instr = execute('disassemble Try_catch_skipped') |
4279c1c66df1
patch 8.2.2517: Vim9: fix for s390 not tested on other systems
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
984 assert_match("NEWLIST size 0\n", instr) |
4279c1c66df1
patch 8.2.2517: Vim9: fix for s390 not tested on other systems
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
985 enddef |
4279c1c66df1
patch 8.2.2517: Vim9: fix for s390 not tested on other systems
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
986 |
4279c1c66df1
patch 8.2.2517: Vim9: fix for s390 not tested on other systems
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
987 |
4279c1c66df1
patch 8.2.2517: Vim9: fix for s390 not tested on other systems
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
988 |
21094
376b520312d6
patch 8.2.1098: Vim9: cannot use line break in :throw argument
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
989 def Test_throw_vimscript() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
990 # only checks line continuation |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
991 var lines =<< trim END |
21094
376b520312d6
patch 8.2.1098: Vim9: cannot use line break in :throw argument
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
992 vim9script |
376b520312d6
patch 8.2.1098: Vim9: cannot use line break in :throw argument
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
993 try |
376b520312d6
patch 8.2.1098: Vim9: cannot use line break in :throw argument
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
994 throw 'one' |
376b520312d6
patch 8.2.1098: Vim9: cannot use line break in :throw argument
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
995 .. 'two' |
376b520312d6
patch 8.2.1098: Vim9: cannot use line break in :throw argument
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
996 catch |
376b520312d6
patch 8.2.1098: Vim9: cannot use line break in :throw argument
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
997 assert_equal('onetwo', v:exception) |
376b520312d6
patch 8.2.1098: Vim9: cannot use line break in :throw argument
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
998 endtry |
376b520312d6
patch 8.2.1098: Vim9: cannot use line break in :throw argument
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
999 END |
376b520312d6
patch 8.2.1098: Vim9: cannot use line break in :throw argument
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
1000 CheckScriptSuccess(lines) |
22612
b08f435d5b86
patch 8.2.1854: Vim9: crash when throwing exception for NULL string
Bram Moolenaar <Bram@vim.org>
parents:
22602
diff
changeset
|
1001 |
b08f435d5b86
patch 8.2.1854: Vim9: crash when throwing exception for NULL string
Bram Moolenaar <Bram@vim.org>
parents:
22602
diff
changeset
|
1002 lines =<< trim END |
b08f435d5b86
patch 8.2.1854: Vim9: crash when throwing exception for NULL string
Bram Moolenaar <Bram@vim.org>
parents:
22602
diff
changeset
|
1003 vim9script |
22621
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22612
diff
changeset
|
1004 @r = '' |
22612
b08f435d5b86
patch 8.2.1854: Vim9: crash when throwing exception for NULL string
Bram Moolenaar <Bram@vim.org>
parents:
22602
diff
changeset
|
1005 def Func() |
b08f435d5b86
patch 8.2.1854: Vim9: crash when throwing exception for NULL string
Bram Moolenaar <Bram@vim.org>
parents:
22602
diff
changeset
|
1006 throw @r |
b08f435d5b86
patch 8.2.1854: Vim9: crash when throwing exception for NULL string
Bram Moolenaar <Bram@vim.org>
parents:
22602
diff
changeset
|
1007 enddef |
b08f435d5b86
patch 8.2.1854: Vim9: crash when throwing exception for NULL string
Bram Moolenaar <Bram@vim.org>
parents:
22602
diff
changeset
|
1008 var result = '' |
b08f435d5b86
patch 8.2.1854: Vim9: crash when throwing exception for NULL string
Bram Moolenaar <Bram@vim.org>
parents:
22602
diff
changeset
|
1009 try |
b08f435d5b86
patch 8.2.1854: Vim9: crash when throwing exception for NULL string
Bram Moolenaar <Bram@vim.org>
parents:
22602
diff
changeset
|
1010 Func() |
b08f435d5b86
patch 8.2.1854: Vim9: crash when throwing exception for NULL string
Bram Moolenaar <Bram@vim.org>
parents:
22602
diff
changeset
|
1011 catch /E1129:/ |
b08f435d5b86
patch 8.2.1854: Vim9: crash when throwing exception for NULL string
Bram Moolenaar <Bram@vim.org>
parents:
22602
diff
changeset
|
1012 result = 'caught' |
b08f435d5b86
patch 8.2.1854: Vim9: crash when throwing exception for NULL string
Bram Moolenaar <Bram@vim.org>
parents:
22602
diff
changeset
|
1013 endtry |
b08f435d5b86
patch 8.2.1854: Vim9: crash when throwing exception for NULL string
Bram Moolenaar <Bram@vim.org>
parents:
22602
diff
changeset
|
1014 assert_equal('caught', result) |
b08f435d5b86
patch 8.2.1854: Vim9: crash when throwing exception for NULL string
Bram Moolenaar <Bram@vim.org>
parents:
22602
diff
changeset
|
1015 END |
b08f435d5b86
patch 8.2.1854: Vim9: crash when throwing exception for NULL string
Bram Moolenaar <Bram@vim.org>
parents:
22602
diff
changeset
|
1016 CheckScriptSuccess(lines) |
21094
376b520312d6
patch 8.2.1098: Vim9: cannot use line break in :throw argument
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
1017 enddef |
376b520312d6
patch 8.2.1098: Vim9: cannot use line break in :throw argument
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
1018 |
21757
6c03897bcd60
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Bram Moolenaar <Bram@vim.org>
parents:
21709
diff
changeset
|
1019 def Test_error_in_nested_function() |
23940
949238ccbd50
patch 8.2.2512: Vim9: compiling error test sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
23927
diff
changeset
|
1020 # an error in a nested :function aborts executing in the calling :def function |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1021 var lines =<< trim END |
21757
6c03897bcd60
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Bram Moolenaar <Bram@vim.org>
parents:
21709
diff
changeset
|
1022 vim9script |
6c03897bcd60
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Bram Moolenaar <Bram@vim.org>
parents:
21709
diff
changeset
|
1023 def Func() |
6c03897bcd60
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Bram Moolenaar <Bram@vim.org>
parents:
21709
diff
changeset
|
1024 Error() |
6c03897bcd60
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Bram Moolenaar <Bram@vim.org>
parents:
21709
diff
changeset
|
1025 g:test_var = 1 |
6c03897bcd60
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Bram Moolenaar <Bram@vim.org>
parents:
21709
diff
changeset
|
1026 enddef |
6c03897bcd60
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Bram Moolenaar <Bram@vim.org>
parents:
21709
diff
changeset
|
1027 func Error() abort |
6c03897bcd60
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Bram Moolenaar <Bram@vim.org>
parents:
21709
diff
changeset
|
1028 eval [][0] |
6c03897bcd60
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Bram Moolenaar <Bram@vim.org>
parents:
21709
diff
changeset
|
1029 endfunc |
6c03897bcd60
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Bram Moolenaar <Bram@vim.org>
parents:
21709
diff
changeset
|
1030 Func() |
6c03897bcd60
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Bram Moolenaar <Bram@vim.org>
parents:
21709
diff
changeset
|
1031 END |
6c03897bcd60
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Bram Moolenaar <Bram@vim.org>
parents:
21709
diff
changeset
|
1032 g:test_var = 0 |
6c03897bcd60
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Bram Moolenaar <Bram@vim.org>
parents:
21709
diff
changeset
|
1033 CheckScriptFailure(lines, 'E684:') |
6c03897bcd60
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Bram Moolenaar <Bram@vim.org>
parents:
21709
diff
changeset
|
1034 assert_equal(0, g:test_var) |
6c03897bcd60
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Bram Moolenaar <Bram@vim.org>
parents:
21709
diff
changeset
|
1035 enddef |
6c03897bcd60
patch 8.2.1428: Vim9: :def function does not abort on nested function error
Bram Moolenaar <Bram@vim.org>
parents:
21709
diff
changeset
|
1036 |
24555
83877a1b66fd
patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
1037 def Test_abort_after_error() |
83877a1b66fd
patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
1038 var lines =<< trim END |
83877a1b66fd
patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
1039 vim9script |
83877a1b66fd
patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
1040 while true |
83877a1b66fd
patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
1041 echo notfound |
83877a1b66fd
patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
1042 endwhile |
83877a1b66fd
patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
1043 g:gotthere = true |
83877a1b66fd
patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
1044 END |
83877a1b66fd
patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
1045 g:gotthere = false |
83877a1b66fd
patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
1046 CheckScriptFailure(lines, 'E121:') |
83877a1b66fd
patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
1047 assert_false(g:gotthere) |
83877a1b66fd
patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
1048 unlet g:gotthere |
83877a1b66fd
patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
1049 enddef |
83877a1b66fd
patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
1050 |
21096
74e5e212e550
patch 8.2.1099: Vim9: cannot use line break in :cexpr argument
Bram Moolenaar <Bram@vim.org>
parents:
21094
diff
changeset
|
1051 def Test_cexpr_vimscript() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
1052 # only checks line continuation |
21096
74e5e212e550
patch 8.2.1099: Vim9: cannot use line break in :cexpr argument
Bram Moolenaar <Bram@vim.org>
parents:
21094
diff
changeset
|
1053 set errorformat=File\ %f\ line\ %l |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1054 var lines =<< trim END |
21096
74e5e212e550
patch 8.2.1099: Vim9: cannot use line break in :cexpr argument
Bram Moolenaar <Bram@vim.org>
parents:
21094
diff
changeset
|
1055 vim9script |
74e5e212e550
patch 8.2.1099: Vim9: cannot use line break in :cexpr argument
Bram Moolenaar <Bram@vim.org>
parents:
21094
diff
changeset
|
1056 cexpr 'File' |
74e5e212e550
patch 8.2.1099: Vim9: cannot use line break in :cexpr argument
Bram Moolenaar <Bram@vim.org>
parents:
21094
diff
changeset
|
1057 .. ' someFile' .. |
74e5e212e550
patch 8.2.1099: Vim9: cannot use line break in :cexpr argument
Bram Moolenaar <Bram@vim.org>
parents:
21094
diff
changeset
|
1058 ' line 19' |
74e5e212e550
patch 8.2.1099: Vim9: cannot use line break in :cexpr argument
Bram Moolenaar <Bram@vim.org>
parents:
21094
diff
changeset
|
1059 assert_equal(19, getqflist()[0].lnum) |
74e5e212e550
patch 8.2.1099: Vim9: cannot use line break in :cexpr argument
Bram Moolenaar <Bram@vim.org>
parents:
21094
diff
changeset
|
1060 END |
74e5e212e550
patch 8.2.1099: Vim9: cannot use line break in :cexpr argument
Bram Moolenaar <Bram@vim.org>
parents:
21094
diff
changeset
|
1061 CheckScriptSuccess(lines) |
74e5e212e550
patch 8.2.1099: Vim9: cannot use line break in :cexpr argument
Bram Moolenaar <Bram@vim.org>
parents:
21094
diff
changeset
|
1062 set errorformat& |
74e5e212e550
patch 8.2.1099: Vim9: cannot use line break in :cexpr argument
Bram Moolenaar <Bram@vim.org>
parents:
21094
diff
changeset
|
1063 enddef |
74e5e212e550
patch 8.2.1099: Vim9: cannot use line break in :cexpr argument
Bram Moolenaar <Bram@vim.org>
parents:
21094
diff
changeset
|
1064 |
21775
6922d78b4d52
patch 8.2.1437: Vim9: 'statusline' is evaluated using Vim9 script syntax
Bram Moolenaar <Bram@vim.org>
parents:
21757
diff
changeset
|
1065 def Test_statusline_syntax() |
6922d78b4d52
patch 8.2.1437: Vim9: 'statusline' is evaluated using Vim9 script syntax
Bram Moolenaar <Bram@vim.org>
parents:
21757
diff
changeset
|
1066 # legacy syntax is used for 'statusline' |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1067 var lines =<< trim END |
21775
6922d78b4d52
patch 8.2.1437: Vim9: 'statusline' is evaluated using Vim9 script syntax
Bram Moolenaar <Bram@vim.org>
parents:
21757
diff
changeset
|
1068 vim9script |
6922d78b4d52
patch 8.2.1437: Vim9: 'statusline' is evaluated using Vim9 script syntax
Bram Moolenaar <Bram@vim.org>
parents:
21757
diff
changeset
|
1069 func g:Status() |
6922d78b4d52
patch 8.2.1437: Vim9: 'statusline' is evaluated using Vim9 script syntax
Bram Moolenaar <Bram@vim.org>
parents:
21757
diff
changeset
|
1070 return '%{"x" is# "x"}' |
6922d78b4d52
patch 8.2.1437: Vim9: 'statusline' is evaluated using Vim9 script syntax
Bram Moolenaar <Bram@vim.org>
parents:
21757
diff
changeset
|
1071 endfunc |
6922d78b4d52
patch 8.2.1437: Vim9: 'statusline' is evaluated using Vim9 script syntax
Bram Moolenaar <Bram@vim.org>
parents:
21757
diff
changeset
|
1072 set laststatus=2 statusline=%!Status() |
6922d78b4d52
patch 8.2.1437: Vim9: 'statusline' is evaluated using Vim9 script syntax
Bram Moolenaar <Bram@vim.org>
parents:
21757
diff
changeset
|
1073 redrawstatus |
6922d78b4d52
patch 8.2.1437: Vim9: 'statusline' is evaluated using Vim9 script syntax
Bram Moolenaar <Bram@vim.org>
parents:
21757
diff
changeset
|
1074 set laststatus statusline= |
6922d78b4d52
patch 8.2.1437: Vim9: 'statusline' is evaluated using Vim9 script syntax
Bram Moolenaar <Bram@vim.org>
parents:
21757
diff
changeset
|
1075 END |
6922d78b4d52
patch 8.2.1437: Vim9: 'statusline' is evaluated using Vim9 script syntax
Bram Moolenaar <Bram@vim.org>
parents:
21757
diff
changeset
|
1076 CheckScriptSuccess(lines) |
6922d78b4d52
patch 8.2.1437: Vim9: 'statusline' is evaluated using Vim9 script syntax
Bram Moolenaar <Bram@vim.org>
parents:
21757
diff
changeset
|
1077 enddef |
6922d78b4d52
patch 8.2.1437: Vim9: 'statusline' is evaluated using Vim9 script syntax
Bram Moolenaar <Bram@vim.org>
parents:
21757
diff
changeset
|
1078 |
21391
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1079 def Test_list_vimscript() |
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1080 # checks line continuation and comments |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1081 var lines =<< trim END |
21391
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1082 vim9script |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1083 var mylist = [ |
21391
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1084 'one', |
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1085 # comment |
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1086 'two', # empty line follows |
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1087 |
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1088 'three', |
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1089 ] |
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1090 assert_equal(['one', 'two', 'three'], mylist) |
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1091 END |
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1092 CheckScriptSuccess(lines) |
21883
a427f5f26419
patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents:
21881
diff
changeset
|
1093 |
a427f5f26419
patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents:
21881
diff
changeset
|
1094 # check all lines from heredoc are kept |
a427f5f26419
patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents:
21881
diff
changeset
|
1095 lines =<< trim END |
a427f5f26419
patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents:
21881
diff
changeset
|
1096 # comment 1 |
a427f5f26419
patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents:
21881
diff
changeset
|
1097 two |
a427f5f26419
patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents:
21881
diff
changeset
|
1098 # comment 3 |
a427f5f26419
patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents:
21881
diff
changeset
|
1099 |
a427f5f26419
patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents:
21881
diff
changeset
|
1100 five |
a427f5f26419
patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents:
21881
diff
changeset
|
1101 # comment 6 |
a427f5f26419
patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents:
21881
diff
changeset
|
1102 END |
a427f5f26419
patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents:
21881
diff
changeset
|
1103 assert_equal(['# comment 1', 'two', '# comment 3', '', 'five', '# comment 6'], lines) |
23703
6bfb302d8392
patch 8.2.2393: Vim9: error message when script line starts with "[{"
Bram Moolenaar <Bram@vim.org>
parents:
23658
diff
changeset
|
1104 |
6bfb302d8392
patch 8.2.2393: Vim9: error message when script line starts with "[{"
Bram Moolenaar <Bram@vim.org>
parents:
23658
diff
changeset
|
1105 lines =<< trim END |
6bfb302d8392
patch 8.2.2393: Vim9: error message when script line starts with "[{"
Bram Moolenaar <Bram@vim.org>
parents:
23658
diff
changeset
|
1106 [{ |
6bfb302d8392
patch 8.2.2393: Vim9: error message when script line starts with "[{"
Bram Moolenaar <Bram@vim.org>
parents:
23658
diff
changeset
|
1107 a: 0}]->string()->assert_equal("[{'a': 0}]") |
6bfb302d8392
patch 8.2.2393: Vim9: error message when script line starts with "[{"
Bram Moolenaar <Bram@vim.org>
parents:
23658
diff
changeset
|
1108 END |
6bfb302d8392
patch 8.2.2393: Vim9: error message when script line starts with "[{"
Bram Moolenaar <Bram@vim.org>
parents:
23658
diff
changeset
|
1109 CheckDefAndScriptSuccess(lines) |
21391
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1110 enddef |
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1111 |
20291
f7b1e43beb8f
patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents:
20289
diff
changeset
|
1112 if has('channel') |
f7b1e43beb8f
patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents:
20289
diff
changeset
|
1113 let someJob = test_null_job() |
20289
208b38bddc36
patch 8.2.0700: Vim9: converting error message to exception not tested
Bram Moolenaar <Bram@vim.org>
parents:
20203
diff
changeset
|
1114 |
20291
f7b1e43beb8f
patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents:
20289
diff
changeset
|
1115 def FuncWithError() |
f7b1e43beb8f
patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents:
20289
diff
changeset
|
1116 echomsg g:someJob |
f7b1e43beb8f
patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents:
20289
diff
changeset
|
1117 enddef |
20289
208b38bddc36
patch 8.2.0700: Vim9: converting error message to exception not tested
Bram Moolenaar <Bram@vim.org>
parents:
20203
diff
changeset
|
1118 |
20291
f7b1e43beb8f
patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents:
20289
diff
changeset
|
1119 func Test_convert_emsg_to_exception() |
f7b1e43beb8f
patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents:
20289
diff
changeset
|
1120 try |
f7b1e43beb8f
patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents:
20289
diff
changeset
|
1121 call FuncWithError() |
f7b1e43beb8f
patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents:
20289
diff
changeset
|
1122 catch |
f7b1e43beb8f
patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents:
20289
diff
changeset
|
1123 call assert_match('Vim:E908:', v:exception) |
f7b1e43beb8f
patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents:
20289
diff
changeset
|
1124 endtry |
f7b1e43beb8f
patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents:
20289
diff
changeset
|
1125 endfunc |
f7b1e43beb8f
patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents:
20289
diff
changeset
|
1126 endif |
20289
208b38bddc36
patch 8.2.0700: Vim9: converting error message to exception not tested
Bram Moolenaar <Bram@vim.org>
parents:
20203
diff
changeset
|
1127 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1128 let s:export_script_lines =<< trim END |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1129 vim9script |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1130 var name: string = 'bob' |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1131 def Concat(arg: string): string |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1132 return name .. arg |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1133 enddef |
20401
918b9a05cf35
patch 8.2.0755: Vim9: No error when variable initializer is not a constant
Bram Moolenaar <Bram@vim.org>
parents:
20399
diff
changeset
|
1134 g:result = Concat('bie') |
918b9a05cf35
patch 8.2.0755: Vim9: No error when variable initializer is not a constant
Bram Moolenaar <Bram@vim.org>
parents:
20399
diff
changeset
|
1135 g:localname = name |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1136 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1137 export const CONST = 1234 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1138 export var exported = 9876 |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1139 export var exp_name = 'John' |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1140 export def Exported(): string |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1141 return 'Exported' |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1142 enddef |
25284
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1143 export def ExportedValue(): number |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1144 return exported |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1145 enddef |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1146 export def ExportedInc() |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1147 exported += 5 |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1148 enddef |
24025
edcb6cf55a26
patch 8.2.2554: Vim9: exporting a final is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24002
diff
changeset
|
1149 export final theList = [1] |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1150 END |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1151 |
21709
16d6b626aa8f
patch 8.2.1404: Vim9: script test fails in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
21707
diff
changeset
|
1152 def Undo_export_script_lines() |
16d6b626aa8f
patch 8.2.1404: Vim9: script test fails in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
21707
diff
changeset
|
1153 unlet g:result |
16d6b626aa8f
patch 8.2.1404: Vim9: script test fails in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
21707
diff
changeset
|
1154 unlet g:localname |
16d6b626aa8f
patch 8.2.1404: Vim9: script test fails in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
21707
diff
changeset
|
1155 enddef |
16d6b626aa8f
patch 8.2.1404: Vim9: script test fails in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
21707
diff
changeset
|
1156 |
19623
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1157 def Test_vim9_import_export() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1158 var import_script_lines =<< trim END |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1159 vim9script |
25284
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1160 import {exported, Exported, ExportedValue} from './Xexport.vim' |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1161 g:exported1 = exported |
19326
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
1162 exported += 3 |
25284
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1163 g:exported2 = exported |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1164 g:exported3 = ExportedValue() |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1165 |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1166 import ExportedInc from './Xexport.vim' |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1167 ExportedInc() |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1168 g:exported_i1 = exported |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1169 g:exported_i2 = ExportedValue() |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1170 |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1171 exported = 11 |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1172 g:exported_s1 = exported |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1173 g:exported_s2 = ExportedValue() |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1174 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1175 g:imported_func = Exported() |
19326
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
1176 |
21473
8bcd1ee2630b
patch 8.2.1287: Vim9: crash when using an imported function
Bram Moolenaar <Bram@vim.org>
parents:
21471
diff
changeset
|
1177 def GetExported(): string |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23068
diff
changeset
|
1178 var local_dict = {ref: Exported} |
21473
8bcd1ee2630b
patch 8.2.1287: Vim9: crash when using an imported function
Bram Moolenaar <Bram@vim.org>
parents:
21471
diff
changeset
|
1179 return local_dict.ref() |
8bcd1ee2630b
patch 8.2.1287: Vim9: crash when using an imported function
Bram Moolenaar <Bram@vim.org>
parents:
21471
diff
changeset
|
1180 enddef |
8bcd1ee2630b
patch 8.2.1287: Vim9: crash when using an imported function
Bram Moolenaar <Bram@vim.org>
parents:
21471
diff
changeset
|
1181 g:funcref_result = GetExported() |
8bcd1ee2630b
patch 8.2.1287: Vim9: crash when using an imported function
Bram Moolenaar <Bram@vim.org>
parents:
21471
diff
changeset
|
1182 |
25282
9bce044c7643
patch 8.2.3178: Vim9: the file name of an :import cannot be an expression
Bram Moolenaar <Bram@vim.org>
parents:
25280
diff
changeset
|
1183 var dir = './' |
9bce044c7643
patch 8.2.3178: Vim9: the file name of an :import cannot be an expression
Bram Moolenaar <Bram@vim.org>
parents:
25280
diff
changeset
|
1184 var ext = ".vim" |
9bce044c7643
patch 8.2.3178: Vim9: the file name of an :import cannot be an expression
Bram Moolenaar <Bram@vim.org>
parents:
25280
diff
changeset
|
1185 import {exp_name} from dir .. 'Xexport' .. ext |
19326
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
1186 g:imported_name = exp_name |
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
1187 exp_name ..= ' Doe' |
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
1188 g:imported_name_appended = exp_name |
25284
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1189 g:exported_later = exported |
24025
edcb6cf55a26
patch 8.2.2554: Vim9: exporting a final is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24002
diff
changeset
|
1190 |
edcb6cf55a26
patch 8.2.2554: Vim9: exporting a final is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24002
diff
changeset
|
1191 import theList from './Xexport.vim' |
edcb6cf55a26
patch 8.2.2554: Vim9: exporting a final is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24002
diff
changeset
|
1192 theList->add(2) |
edcb6cf55a26
patch 8.2.2554: Vim9: exporting a final is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24002
diff
changeset
|
1193 assert_equal([1, 2], theList) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1194 END |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1195 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1196 writefile(import_script_lines, 'Ximport.vim') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1197 writefile(s:export_script_lines, 'Xexport.vim') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1198 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1199 source Ximport.vim |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1200 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1201 assert_equal('bobbie', g:result) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1202 assert_equal('bob', g:localname) |
25284
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1203 assert_equal(9876, g:exported1) |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1204 assert_equal(9879, g:exported2) |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1205 assert_equal(9879, g:exported3) |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1206 |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1207 assert_equal(9884, g:exported_i1) |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1208 assert_equal(9884, g:exported_i2) |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1209 |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1210 assert_equal(11, g:exported_s1) |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1211 assert_equal(11, g:exported_s2) |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1212 assert_equal(11, g:exported_later) |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1213 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1214 assert_equal('Exported', g:imported_func) |
21473
8bcd1ee2630b
patch 8.2.1287: Vim9: crash when using an imported function
Bram Moolenaar <Bram@vim.org>
parents:
21471
diff
changeset
|
1215 assert_equal('Exported', g:funcref_result) |
19326
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
1216 assert_equal('John', g:imported_name) |
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
1217 assert_equal('John Doe', g:imported_name_appended) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1218 assert_false(exists('g:name')) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1219 |
21709
16d6b626aa8f
patch 8.2.1404: Vim9: script test fails in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
21707
diff
changeset
|
1220 Undo_export_script_lines() |
25284
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1221 unlet g:exported1 |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1222 unlet g:exported2 |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1223 unlet g:exported3 |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1224 unlet g:exported_i1 |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1225 unlet g:exported_i2 |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1226 unlet g:exported_later |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1227 unlet g:imported_func |
19326
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
1228 unlet g:imported_name g:imported_name_appended |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1229 delete('Ximport.vim') |
19509
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1230 |
21146
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1231 # similar, with line breaks |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1232 var import_line_break_script_lines =<< trim END |
21146
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1233 vim9script |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1234 import { |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1235 exported, |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1236 Exported, |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1237 } |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1238 from |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1239 './Xexport.vim' |
25284
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1240 g:exported = exported |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1241 exported += 7 |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1242 g:exported_added = exported |
21146
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1243 g:imported_func = Exported() |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1244 END |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1245 writefile(import_line_break_script_lines, 'Ximport_lbr.vim') |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1246 source Ximport_lbr.vim |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1247 |
25284
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1248 assert_equal(11, g:exported) |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1249 assert_equal(18, g:exported_added) |
21146
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1250 assert_equal('Exported', g:imported_func) |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1251 |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1252 # exported script not sourced again |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1253 assert_false(exists('g:result')) |
25284
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1254 unlet g:exported |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1255 unlet g:exported_added |
21146
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1256 unlet g:imported_func |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1257 delete('Ximport_lbr.vim') |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1258 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1259 var import_star_as_lines =<< trim END |
19509
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1260 vim9script |
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1261 import * as Export from './Xexport.vim' |
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1262 def UseExport() |
25284
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1263 g:exported_def = Export.exported |
19509
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1264 enddef |
25284
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1265 g:exported_script = Export.exported |
24112
0346a59ed5bf
patch 8.2.2597: Vim9: "import * as" does not work at script level
Bram Moolenaar <Bram@vim.org>
parents:
24081
diff
changeset
|
1266 assert_equal(1, exists('Export.exported')) |
0346a59ed5bf
patch 8.2.2597: Vim9: "import * as" does not work at script level
Bram Moolenaar <Bram@vim.org>
parents:
24081
diff
changeset
|
1267 assert_equal(0, exists('Export.notexported')) |
19509
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1268 UseExport() |
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1269 END |
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1270 writefile(import_star_as_lines, 'Ximport.vim') |
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1271 source Ximport.vim |
25284
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1272 |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1273 assert_equal(18, g:exported_def) |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1274 assert_equal(18, g:exported_script) |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1275 unlet g:exported_def |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1276 unlet g:exported_script |
19509
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1277 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1278 var import_star_as_lines_no_dot =<< trim END |
19818
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1279 vim9script |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1280 import * as Export from './Xexport.vim' |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1281 def Func() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1282 var dummy = 1 |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1283 var imported = Export + dummy |
19818
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1284 enddef |
20528
489cb75c76b6
patch 8.2.0818: Vim9: using a discovery phase doesn't work well
Bram Moolenaar <Bram@vim.org>
parents:
20504
diff
changeset
|
1285 defcompile |
19818
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1286 END |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1287 writefile(import_star_as_lines_no_dot, 'Ximport.vim') |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22147
diff
changeset
|
1288 assert_fails('source Ximport.vim', 'E1060:', '', 2, 'Func') |
19818
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1289 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1290 var import_star_as_lines_dot_space =<< trim END |
19818
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1291 vim9script |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1292 import * as Export from './Xexport.vim' |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1293 def Func() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1294 var imported = Export . exported |
19818
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1295 enddef |
20528
489cb75c76b6
patch 8.2.0818: Vim9: using a discovery phase doesn't work well
Bram Moolenaar <Bram@vim.org>
parents:
20504
diff
changeset
|
1296 defcompile |
19818
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1297 END |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1298 writefile(import_star_as_lines_dot_space, 'Ximport.vim') |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22147
diff
changeset
|
1299 assert_fails('source Ximport.vim', 'E1074:', '', 1, 'Func') |
19818
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1300 |
25423
3e56078569ca
patch 8.2.3248: Vim9: error message for wrong input uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
1301 var import_func_duplicated =<< trim END |
3e56078569ca
patch 8.2.3248: Vim9: error message for wrong input uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
1302 vim9script |
3e56078569ca
patch 8.2.3248: Vim9: error message for wrong input uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
1303 import ExportedInc from './Xexport.vim' |
3e56078569ca
patch 8.2.3248: Vim9: error message for wrong input uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
1304 import ExportedInc from './Xexport.vim' |
3e56078569ca
patch 8.2.3248: Vim9: error message for wrong input uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
1305 |
3e56078569ca
patch 8.2.3248: Vim9: error message for wrong input uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
1306 ExportedInc() |
3e56078569ca
patch 8.2.3248: Vim9: error message for wrong input uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
1307 END |
3e56078569ca
patch 8.2.3248: Vim9: error message for wrong input uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
1308 writefile(import_func_duplicated, 'Ximport.vim') |
3e56078569ca
patch 8.2.3248: Vim9: error message for wrong input uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
1309 assert_fails('source Ximport.vim', 'E1073:', '', 3, 'Ximport.vim') |
3e56078569ca
patch 8.2.3248: Vim9: error message for wrong input uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
1310 |
23364
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
1311 var import_star_as_duplicated =<< trim END |
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
1312 vim9script |
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
1313 import * as Export from './Xexport.vim' |
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
1314 var some = 'other' |
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
1315 import * as Export from './Xexport.vim' |
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
1316 defcompile |
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
1317 END |
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
1318 writefile(import_star_as_duplicated, 'Ximport.vim') |
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
1319 assert_fails('source Ximport.vim', 'E1073:', '', 4, 'Ximport.vim') |
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
1320 |
24112
0346a59ed5bf
patch 8.2.2597: Vim9: "import * as" does not work at script level
Bram Moolenaar <Bram@vim.org>
parents:
24081
diff
changeset
|
1321 var import_star_as_lines_script_no_dot =<< trim END |
0346a59ed5bf
patch 8.2.2597: Vim9: "import * as" does not work at script level
Bram Moolenaar <Bram@vim.org>
parents:
24081
diff
changeset
|
1322 vim9script |
0346a59ed5bf
patch 8.2.2597: Vim9: "import * as" does not work at script level
Bram Moolenaar <Bram@vim.org>
parents:
24081
diff
changeset
|
1323 import * as Export from './Xexport.vim' |
0346a59ed5bf
patch 8.2.2597: Vim9: "import * as" does not work at script level
Bram Moolenaar <Bram@vim.org>
parents:
24081
diff
changeset
|
1324 g:imported_script = Export exported |
0346a59ed5bf
patch 8.2.2597: Vim9: "import * as" does not work at script level
Bram Moolenaar <Bram@vim.org>
parents:
24081
diff
changeset
|
1325 END |
0346a59ed5bf
patch 8.2.2597: Vim9: "import * as" does not work at script level
Bram Moolenaar <Bram@vim.org>
parents:
24081
diff
changeset
|
1326 writefile(import_star_as_lines_script_no_dot, 'Ximport.vim') |
0346a59ed5bf
patch 8.2.2597: Vim9: "import * as" does not work at script level
Bram Moolenaar <Bram@vim.org>
parents:
24081
diff
changeset
|
1327 assert_fails('source Ximport.vim', 'E1029:') |
0346a59ed5bf
patch 8.2.2597: Vim9: "import * as" does not work at script level
Bram Moolenaar <Bram@vim.org>
parents:
24081
diff
changeset
|
1328 |
0346a59ed5bf
patch 8.2.2597: Vim9: "import * as" does not work at script level
Bram Moolenaar <Bram@vim.org>
parents:
24081
diff
changeset
|
1329 var import_star_as_lines_script_space_after_dot =<< trim END |
0346a59ed5bf
patch 8.2.2597: Vim9: "import * as" does not work at script level
Bram Moolenaar <Bram@vim.org>
parents:
24081
diff
changeset
|
1330 vim9script |
0346a59ed5bf
patch 8.2.2597: Vim9: "import * as" does not work at script level
Bram Moolenaar <Bram@vim.org>
parents:
24081
diff
changeset
|
1331 import * as Export from './Xexport.vim' |
0346a59ed5bf
patch 8.2.2597: Vim9: "import * as" does not work at script level
Bram Moolenaar <Bram@vim.org>
parents:
24081
diff
changeset
|
1332 g:imported_script = Export. exported |
0346a59ed5bf
patch 8.2.2597: Vim9: "import * as" does not work at script level
Bram Moolenaar <Bram@vim.org>
parents:
24081
diff
changeset
|
1333 END |
0346a59ed5bf
patch 8.2.2597: Vim9: "import * as" does not work at script level
Bram Moolenaar <Bram@vim.org>
parents:
24081
diff
changeset
|
1334 writefile(import_star_as_lines_script_space_after_dot, 'Ximport.vim') |
0346a59ed5bf
patch 8.2.2597: Vim9: "import * as" does not work at script level
Bram Moolenaar <Bram@vim.org>
parents:
24081
diff
changeset
|
1335 assert_fails('source Ximport.vim', 'E1074:') |
0346a59ed5bf
patch 8.2.2597: Vim9: "import * as" does not work at script level
Bram Moolenaar <Bram@vim.org>
parents:
24081
diff
changeset
|
1336 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1337 var import_star_as_lines_missing_name =<< trim END |
19818
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1338 vim9script |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1339 import * as Export from './Xexport.vim' |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1340 def Func() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1341 var imported = Export. |
19818
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1342 enddef |
20528
489cb75c76b6
patch 8.2.0818: Vim9: using a discovery phase doesn't work well
Bram Moolenaar <Bram@vim.org>
parents:
20504
diff
changeset
|
1343 defcompile |
19818
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1344 END |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1345 writefile(import_star_as_lines_missing_name, 'Ximport.vim') |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22147
diff
changeset
|
1346 assert_fails('source Ximport.vim', 'E1048:', '', 1, 'Func') |
19818
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1347 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1348 var import_star_as_lbr_lines =<< trim END |
21146
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1349 vim9script |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1350 import * |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1351 as Export |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1352 from |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1353 './Xexport.vim' |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1354 def UseExport() |
25284
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1355 g:exported = Export.exported |
21146
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1356 enddef |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1357 UseExport() |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1358 END |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1359 writefile(import_star_as_lbr_lines, 'Ximport.vim') |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1360 source Ximport.vim |
25284
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1361 assert_equal(18, g:exported) |
29191571eceb
patch 8.2.3179: Vim9: cannot assign to an imported variable at script level
Bram Moolenaar <Bram@vim.org>
parents:
25282
diff
changeset
|
1362 unlet g:exported |
21146
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1363 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1364 var import_star_lines =<< trim END |
19509
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1365 vim9script |
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1366 import * from './Xexport.vim' |
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1367 END |
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1368 writefile(import_star_lines, 'Ximport.vim') |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22147
diff
changeset
|
1369 assert_fails('source Ximport.vim', 'E1045:', '', 2, 'Ximport.vim') |
19509
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1370 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
1371 # try to import something that exists but is not exported |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1372 var import_not_exported_lines =<< trim END |
19511
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1373 vim9script |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1374 import name from './Xexport.vim' |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1375 END |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1376 writefile(import_not_exported_lines, 'Ximport.vim') |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22147
diff
changeset
|
1377 assert_fails('source Ximport.vim', 'E1049:', '', 2, 'Ximport.vim') |
19511
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1378 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
1379 # try to import something that is already defined |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1380 var import_already_defined =<< trim END |
19623
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1381 vim9script |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1382 var exported = 'something' |
19623
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1383 import exported from './Xexport.vim' |
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1384 END |
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1385 writefile(import_already_defined, 'Ximport.vim') |
24033
308d29307910
patch 8.2.2558: no error if a lambda argument shadows a variable
Bram Moolenaar <Bram@vim.org>
parents:
24029
diff
changeset
|
1386 assert_fails('source Ximport.vim', 'E1054:', '', 3, 'Ximport.vim') |
19623
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1387 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
1388 # try to import something that is already defined |
19623
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1389 import_already_defined =<< trim END |
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1390 vim9script |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1391 var exported = 'something' |
19623
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1392 import * as exported from './Xexport.vim' |
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1393 END |
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1394 writefile(import_already_defined, 'Ximport.vim') |
24033
308d29307910
patch 8.2.2558: no error if a lambda argument shadows a variable
Bram Moolenaar <Bram@vim.org>
parents:
24029
diff
changeset
|
1395 assert_fails('source Ximport.vim', 'E1054:', '', 3, 'Ximport.vim') |
19623
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1396 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
1397 # try to import something that is already defined |
19623
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1398 import_already_defined =<< trim END |
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1399 vim9script |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1400 var exported = 'something' |
19623
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1401 import {exported} from './Xexport.vim' |
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1402 END |
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1403 writefile(import_already_defined, 'Ximport.vim') |
24033
308d29307910
patch 8.2.2558: no error if a lambda argument shadows a variable
Bram Moolenaar <Bram@vim.org>
parents:
24029
diff
changeset
|
1404 assert_fails('source Ximport.vim', 'E1054:', '', 3, 'Ximport.vim') |
19623
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1405 |
23106
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
1406 # try changing an imported const |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
1407 var import_assign_to_const =<< trim END |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
1408 vim9script |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
1409 import CONST from './Xexport.vim' |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
1410 def Assign() |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
1411 CONST = 987 |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
1412 enddef |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
1413 defcompile |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
1414 END |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
1415 writefile(import_assign_to_const, 'Ximport.vim') |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
1416 assert_fails('source Ximport.vim', 'E46:', '', 1, '_Assign') |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
1417 |
24025
edcb6cf55a26
patch 8.2.2554: Vim9: exporting a final is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24002
diff
changeset
|
1418 # try changing an imported final |
edcb6cf55a26
patch 8.2.2554: Vim9: exporting a final is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24002
diff
changeset
|
1419 var import_assign_to_final =<< trim END |
edcb6cf55a26
patch 8.2.2554: Vim9: exporting a final is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24002
diff
changeset
|
1420 vim9script |
edcb6cf55a26
patch 8.2.2554: Vim9: exporting a final is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24002
diff
changeset
|
1421 import theList from './Xexport.vim' |
edcb6cf55a26
patch 8.2.2554: Vim9: exporting a final is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24002
diff
changeset
|
1422 def Assign() |
edcb6cf55a26
patch 8.2.2554: Vim9: exporting a final is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24002
diff
changeset
|
1423 theList = [2] |
edcb6cf55a26
patch 8.2.2554: Vim9: exporting a final is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24002
diff
changeset
|
1424 enddef |
edcb6cf55a26
patch 8.2.2554: Vim9: exporting a final is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24002
diff
changeset
|
1425 defcompile |
edcb6cf55a26
patch 8.2.2554: Vim9: exporting a final is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24002
diff
changeset
|
1426 END |
edcb6cf55a26
patch 8.2.2554: Vim9: exporting a final is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24002
diff
changeset
|
1427 writefile(import_assign_to_final, 'Ximport.vim') |
edcb6cf55a26
patch 8.2.2554: Vim9: exporting a final is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24002
diff
changeset
|
1428 assert_fails('source Ximport.vim', 'E46:', '', 1, '_Assign') |
edcb6cf55a26
patch 8.2.2554: Vim9: exporting a final is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24002
diff
changeset
|
1429 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
1430 # import a very long name, requires making a copy |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1431 var import_long_name_lines =<< trim END |
19511
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1432 vim9script |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1433 import name012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 from './Xexport.vim' |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1434 END |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1435 writefile(import_long_name_lines, 'Ximport.vim') |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22147
diff
changeset
|
1436 assert_fails('source Ximport.vim', 'E1048:', '', 2, 'Ximport.vim') |
19511
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1437 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1438 var import_no_from_lines =<< trim END |
19511
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1439 vim9script |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1440 import name './Xexport.vim' |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1441 END |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1442 writefile(import_no_from_lines, 'Ximport.vim') |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22147
diff
changeset
|
1443 assert_fails('source Ximport.vim', 'E1070:', '', 2, 'Ximport.vim') |
19511
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1444 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1445 var import_invalid_string_lines =<< trim END |
19511
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1446 vim9script |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1447 import name from Xexport.vim |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1448 END |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1449 writefile(import_invalid_string_lines, 'Ximport.vim') |
25282
9bce044c7643
patch 8.2.3178: Vim9: the file name of an :import cannot be an expression
Bram Moolenaar <Bram@vim.org>
parents:
25280
diff
changeset
|
1450 assert_fails('source Ximport.vim', 'E121:', '', 2, 'Ximport.vim') |
19511
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1451 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1452 var import_wrong_name_lines =<< trim END |
19511
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1453 vim9script |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1454 import name from './XnoExport.vim' |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1455 END |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1456 writefile(import_wrong_name_lines, 'Ximport.vim') |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22147
diff
changeset
|
1457 assert_fails('source Ximport.vim', 'E1053:', '', 2, 'Ximport.vim') |
19511
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1458 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1459 var import_missing_comma_lines =<< trim END |
19511
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1460 vim9script |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1461 import {exported name} from './Xexport.vim' |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1462 END |
19623
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1463 writefile(import_missing_comma_lines, 'Ximport3.vim') |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22147
diff
changeset
|
1464 assert_fails('source Ximport3.vim', 'E1046:', '', 2, 'Ximport3.vim') |
19511
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1465 |
25298
90fa50a31994
patch 8.2.3186: Vim9: not all failures for import tested
Bram Moolenaar <Bram@vim.org>
parents:
25284
diff
changeset
|
1466 var import_redefining_lines =<< trim END |
90fa50a31994
patch 8.2.3186: Vim9: not all failures for import tested
Bram Moolenaar <Bram@vim.org>
parents:
25284
diff
changeset
|
1467 vim9script |
90fa50a31994
patch 8.2.3186: Vim9: not all failures for import tested
Bram Moolenaar <Bram@vim.org>
parents:
25284
diff
changeset
|
1468 import exported from './Xexport.vim' |
90fa50a31994
patch 8.2.3186: Vim9: not all failures for import tested
Bram Moolenaar <Bram@vim.org>
parents:
25284
diff
changeset
|
1469 var exported = 5 |
90fa50a31994
patch 8.2.3186: Vim9: not all failures for import tested
Bram Moolenaar <Bram@vim.org>
parents:
25284
diff
changeset
|
1470 END |
90fa50a31994
patch 8.2.3186: Vim9: not all failures for import tested
Bram Moolenaar <Bram@vim.org>
parents:
25284
diff
changeset
|
1471 writefile(import_redefining_lines, 'Ximport.vim') |
90fa50a31994
patch 8.2.3186: Vim9: not all failures for import tested
Bram Moolenaar <Bram@vim.org>
parents:
25284
diff
changeset
|
1472 assert_fails('source Ximport.vim', 'E1213: Redefining imported item "exported"', '', 3) |
90fa50a31994
patch 8.2.3186: Vim9: not all failures for import tested
Bram Moolenaar <Bram@vim.org>
parents:
25284
diff
changeset
|
1473 |
90fa50a31994
patch 8.2.3186: Vim9: not all failures for import tested
Bram Moolenaar <Bram@vim.org>
parents:
25284
diff
changeset
|
1474 var import_assign_wrong_type_lines =<< trim END |
90fa50a31994
patch 8.2.3186: Vim9: not all failures for import tested
Bram Moolenaar <Bram@vim.org>
parents:
25284
diff
changeset
|
1475 vim9script |
90fa50a31994
patch 8.2.3186: Vim9: not all failures for import tested
Bram Moolenaar <Bram@vim.org>
parents:
25284
diff
changeset
|
1476 import exported from './Xexport.vim' |
90fa50a31994
patch 8.2.3186: Vim9: not all failures for import tested
Bram Moolenaar <Bram@vim.org>
parents:
25284
diff
changeset
|
1477 exported = 'xxx' |
90fa50a31994
patch 8.2.3186: Vim9: not all failures for import tested
Bram Moolenaar <Bram@vim.org>
parents:
25284
diff
changeset
|
1478 END |
90fa50a31994
patch 8.2.3186: Vim9: not all failures for import tested
Bram Moolenaar <Bram@vim.org>
parents:
25284
diff
changeset
|
1479 writefile(import_assign_wrong_type_lines, 'Ximport.vim') |
90fa50a31994
patch 8.2.3186: Vim9: not all failures for import tested
Bram Moolenaar <Bram@vim.org>
parents:
25284
diff
changeset
|
1480 assert_fails('source Ximport.vim', 'E1012: Type mismatch; expected number but got string', '', 3) |
90fa50a31994
patch 8.2.3186: Vim9: not all failures for import tested
Bram Moolenaar <Bram@vim.org>
parents:
25284
diff
changeset
|
1481 |
90fa50a31994
patch 8.2.3186: Vim9: not all failures for import tested
Bram Moolenaar <Bram@vim.org>
parents:
25284
diff
changeset
|
1482 var import_assign_const_lines =<< trim END |
90fa50a31994
patch 8.2.3186: Vim9: not all failures for import tested
Bram Moolenaar <Bram@vim.org>
parents:
25284
diff
changeset
|
1483 vim9script |
90fa50a31994
patch 8.2.3186: Vim9: not all failures for import tested
Bram Moolenaar <Bram@vim.org>
parents:
25284
diff
changeset
|
1484 import CONST from './Xexport.vim' |
90fa50a31994
patch 8.2.3186: Vim9: not all failures for import tested
Bram Moolenaar <Bram@vim.org>
parents:
25284
diff
changeset
|
1485 CONST = 4321 |
90fa50a31994
patch 8.2.3186: Vim9: not all failures for import tested
Bram Moolenaar <Bram@vim.org>
parents:
25284
diff
changeset
|
1486 END |
90fa50a31994
patch 8.2.3186: Vim9: not all failures for import tested
Bram Moolenaar <Bram@vim.org>
parents:
25284
diff
changeset
|
1487 writefile(import_assign_const_lines, 'Ximport.vim') |
90fa50a31994
patch 8.2.3186: Vim9: not all failures for import tested
Bram Moolenaar <Bram@vim.org>
parents:
25284
diff
changeset
|
1488 assert_fails('source Ximport.vim', 'E741: Value is locked: CONST', '', 3) |
90fa50a31994
patch 8.2.3186: Vim9: not all failures for import tested
Bram Moolenaar <Bram@vim.org>
parents:
25284
diff
changeset
|
1489 |
19509
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1490 delete('Ximport.vim') |
19623
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1491 delete('Ximport3.vim') |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1492 delete('Xexport.vim') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1493 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
1494 # Check that in a Vim9 script 'cpo' is set to the Vim default. |
24150
4919f2d8d7fd
patch 8.2.2616: Vim9: if 'cpo' is change in Vim9 script it may be restored
Bram Moolenaar <Bram@vim.org>
parents:
24148
diff
changeset
|
1495 # Flags added or removed are also applied to the restored value. |
4919f2d8d7fd
patch 8.2.2616: Vim9: if 'cpo' is change in Vim9 script it may be restored
Bram Moolenaar <Bram@vim.org>
parents:
24148
diff
changeset
|
1496 set cpo=abcd |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1497 var lines =<< trim END |
19507
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1498 vim9script |
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1499 g:cpo_in_vim9script = &cpo |
24150
4919f2d8d7fd
patch 8.2.2616: Vim9: if 'cpo' is change in Vim9 script it may be restored
Bram Moolenaar <Bram@vim.org>
parents:
24148
diff
changeset
|
1500 set cpo+=f |
4919f2d8d7fd
patch 8.2.2616: Vim9: if 'cpo' is change in Vim9 script it may be restored
Bram Moolenaar <Bram@vim.org>
parents:
24148
diff
changeset
|
1501 set cpo-=c |
4919f2d8d7fd
patch 8.2.2616: Vim9: if 'cpo' is change in Vim9 script it may be restored
Bram Moolenaar <Bram@vim.org>
parents:
24148
diff
changeset
|
1502 g:cpo_after_vim9script = &cpo |
19507
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1503 END |
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1504 writefile(lines, 'Xvim9_script') |
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1505 source Xvim9_script |
24150
4919f2d8d7fd
patch 8.2.2616: Vim9: if 'cpo' is change in Vim9 script it may be restored
Bram Moolenaar <Bram@vim.org>
parents:
24148
diff
changeset
|
1506 assert_equal('fabd', &cpo) |
19507
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1507 set cpo&vim |
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1508 assert_equal(&cpo, g:cpo_in_vim9script) |
24150
4919f2d8d7fd
patch 8.2.2616: Vim9: if 'cpo' is change in Vim9 script it may be restored
Bram Moolenaar <Bram@vim.org>
parents:
24148
diff
changeset
|
1509 var newcpo = substitute(&cpo, 'c', '', '') .. 'f' |
4919f2d8d7fd
patch 8.2.2616: Vim9: if 'cpo' is change in Vim9 script it may be restored
Bram Moolenaar <Bram@vim.org>
parents:
24148
diff
changeset
|
1510 assert_equal(newcpo, g:cpo_after_vim9script) |
4919f2d8d7fd
patch 8.2.2616: Vim9: if 'cpo' is change in Vim9 script it may be restored
Bram Moolenaar <Bram@vim.org>
parents:
24148
diff
changeset
|
1511 |
19507
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1512 delete('Xvim9_script') |
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1513 enddef |
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1514 |
26046
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1515 def Test_import_funcref() |
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1516 var lines =<< trim END |
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1517 vim9script |
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1518 export def F(): number |
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1519 return 42 |
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1520 enddef |
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1521 export const G = F |
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1522 END |
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1523 writefile(lines, 'Xlib.vim') |
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1524 |
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1525 lines =<< trim END |
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1526 vim9script |
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1527 import {G} from './Xlib.vim' |
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1528 const Foo = G() |
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1529 assert_equal(42, Foo) |
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1530 |
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1531 def DoTest() |
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1532 const Goo = G() |
26048
e8592947d90b
patch 8.2.3558: Vim9: asserting the wrong variable
Bram Moolenaar <Bram@vim.org>
parents:
26046
diff
changeset
|
1533 assert_equal(42, Goo) |
26046
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1534 enddef |
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1535 DoTest() |
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1536 END |
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1537 CheckScriptSuccess(lines) |
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1538 |
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1539 delete('Xlib.vim') |
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1540 enddef |
f773ef3c641d
patch 8.2.3557: Vim9: cannot call imported funcref at script level
Bram Moolenaar <Bram@vim.org>
parents:
25846
diff
changeset
|
1541 |
25751
fc8046209eaa
patch 8.2.3411: Vim9: crash when using base name of import
Bram Moolenaar <Bram@vim.org>
parents:
25656
diff
changeset
|
1542 def Test_import_star_fails() |
fc8046209eaa
patch 8.2.3411: Vim9: crash when using base name of import
Bram Moolenaar <Bram@vim.org>
parents:
25656
diff
changeset
|
1543 writefile([], 'Xfoo.vim') |
fc8046209eaa
patch 8.2.3411: Vim9: crash when using base name of import
Bram Moolenaar <Bram@vim.org>
parents:
25656
diff
changeset
|
1544 var lines =<< trim END |
25753
c50b3eff7a64
patch 8.2.3412: Vim9: importing the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
25751
diff
changeset
|
1545 import * as foo from './Xfoo.vim' |
25751
fc8046209eaa
patch 8.2.3411: Vim9: crash when using base name of import
Bram Moolenaar <Bram@vim.org>
parents:
25656
diff
changeset
|
1546 foo = 'bar' |
fc8046209eaa
patch 8.2.3411: Vim9: crash when using base name of import
Bram Moolenaar <Bram@vim.org>
parents:
25656
diff
changeset
|
1547 END |
26650
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
26556
diff
changeset
|
1548 CheckDefAndScriptFailure(lines, ['E1094:', 'E1236: Cannot use foo itself']) |
25751
fc8046209eaa
patch 8.2.3411: Vim9: crash when using base name of import
Bram Moolenaar <Bram@vim.org>
parents:
25656
diff
changeset
|
1549 lines =<< trim END |
fc8046209eaa
patch 8.2.3411: Vim9: crash when using base name of import
Bram Moolenaar <Bram@vim.org>
parents:
25656
diff
changeset
|
1550 vim9script |
25753
c50b3eff7a64
patch 8.2.3412: Vim9: importing the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
25751
diff
changeset
|
1551 import * as foo from './Xfoo.vim' |
25751
fc8046209eaa
patch 8.2.3411: Vim9: crash when using base name of import
Bram Moolenaar <Bram@vim.org>
parents:
25656
diff
changeset
|
1552 var that = foo |
fc8046209eaa
patch 8.2.3411: Vim9: crash when using base name of import
Bram Moolenaar <Bram@vim.org>
parents:
25656
diff
changeset
|
1553 END |
fc8046209eaa
patch 8.2.3411: Vim9: crash when using base name of import
Bram Moolenaar <Bram@vim.org>
parents:
25656
diff
changeset
|
1554 CheckScriptFailure(lines, 'E1029: Expected ''.''') |
25755
33ebec729787
patch 8.2.3413: Vim9: too many characters are allowed in import name
Bram Moolenaar <Bram@vim.org>
parents:
25753
diff
changeset
|
1555 |
33ebec729787
patch 8.2.3413: Vim9: too many characters are allowed in import name
Bram Moolenaar <Bram@vim.org>
parents:
25753
diff
changeset
|
1556 lines =<< trim END |
33ebec729787
patch 8.2.3413: Vim9: too many characters are allowed in import name
Bram Moolenaar <Bram@vim.org>
parents:
25753
diff
changeset
|
1557 vim9script |
33ebec729787
patch 8.2.3413: Vim9: too many characters are allowed in import name
Bram Moolenaar <Bram@vim.org>
parents:
25753
diff
changeset
|
1558 import * as 9foo from './Xfoo.vim' |
33ebec729787
patch 8.2.3413: Vim9: too many characters are allowed in import name
Bram Moolenaar <Bram@vim.org>
parents:
25753
diff
changeset
|
1559 END |
33ebec729787
patch 8.2.3413: Vim9: too many characters are allowed in import name
Bram Moolenaar <Bram@vim.org>
parents:
25753
diff
changeset
|
1560 CheckScriptFailure(lines, 'E1047:') |
33ebec729787
patch 8.2.3413: Vim9: too many characters are allowed in import name
Bram Moolenaar <Bram@vim.org>
parents:
25753
diff
changeset
|
1561 lines =<< trim END |
33ebec729787
patch 8.2.3413: Vim9: too many characters are allowed in import name
Bram Moolenaar <Bram@vim.org>
parents:
25753
diff
changeset
|
1562 vim9script |
33ebec729787
patch 8.2.3413: Vim9: too many characters are allowed in import name
Bram Moolenaar <Bram@vim.org>
parents:
25753
diff
changeset
|
1563 import * as the#foo from './Xfoo.vim' |
33ebec729787
patch 8.2.3413: Vim9: too many characters are allowed in import name
Bram Moolenaar <Bram@vim.org>
parents:
25753
diff
changeset
|
1564 END |
33ebec729787
patch 8.2.3413: Vim9: too many characters are allowed in import name
Bram Moolenaar <Bram@vim.org>
parents:
25753
diff
changeset
|
1565 CheckScriptFailure(lines, 'E1047:') |
33ebec729787
patch 8.2.3413: Vim9: too many characters are allowed in import name
Bram Moolenaar <Bram@vim.org>
parents:
25753
diff
changeset
|
1566 lines =<< trim END |
33ebec729787
patch 8.2.3413: Vim9: too many characters are allowed in import name
Bram Moolenaar <Bram@vim.org>
parents:
25753
diff
changeset
|
1567 vim9script |
33ebec729787
patch 8.2.3413: Vim9: too many characters are allowed in import name
Bram Moolenaar <Bram@vim.org>
parents:
25753
diff
changeset
|
1568 import * as g:foo from './Xfoo.vim' |
33ebec729787
patch 8.2.3413: Vim9: too many characters are allowed in import name
Bram Moolenaar <Bram@vim.org>
parents:
25753
diff
changeset
|
1569 END |
33ebec729787
patch 8.2.3413: Vim9: too many characters are allowed in import name
Bram Moolenaar <Bram@vim.org>
parents:
25753
diff
changeset
|
1570 CheckScriptFailure(lines, 'E1047:') |
33ebec729787
patch 8.2.3413: Vim9: too many characters are allowed in import name
Bram Moolenaar <Bram@vim.org>
parents:
25753
diff
changeset
|
1571 |
25753
c50b3eff7a64
patch 8.2.3412: Vim9: importing the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
25751
diff
changeset
|
1572 delete('Xfoo.vim') |
26556
dff04b7fa6b2
patch 8.2.3807: Vim9: can call import with star directly
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1573 |
dff04b7fa6b2
patch 8.2.3807: Vim9: can call import with star directly
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1574 lines =<< trim END |
dff04b7fa6b2
patch 8.2.3807: Vim9: can call import with star directly
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1575 vim9script |
dff04b7fa6b2
patch 8.2.3807: Vim9: can call import with star directly
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1576 def TheFunc() |
dff04b7fa6b2
patch 8.2.3807: Vim9: can call import with star directly
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1577 echo 'the func' |
dff04b7fa6b2
patch 8.2.3807: Vim9: can call import with star directly
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1578 enddef |
dff04b7fa6b2
patch 8.2.3807: Vim9: can call import with star directly
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1579 export var Ref = TheFunc |
dff04b7fa6b2
patch 8.2.3807: Vim9: can call import with star directly
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1580 END |
dff04b7fa6b2
patch 8.2.3807: Vim9: can call import with star directly
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1581 writefile([], 'Xthat.vim') |
dff04b7fa6b2
patch 8.2.3807: Vim9: can call import with star directly
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1582 lines =<< trim END |
dff04b7fa6b2
patch 8.2.3807: Vim9: can call import with star directly
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1583 import * as That from './Xthat.vim' |
dff04b7fa6b2
patch 8.2.3807: Vim9: can call import with star directly
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1584 That() |
dff04b7fa6b2
patch 8.2.3807: Vim9: can call import with star directly
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1585 END |
26650
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
26556
diff
changeset
|
1586 CheckDefAndScriptFailure(lines, ['E1094:', 'E1236: Cannot use That itself']) |
26556
dff04b7fa6b2
patch 8.2.3807: Vim9: can call import with star directly
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1587 delete('Xthat.vim') |
25751
fc8046209eaa
patch 8.2.3411: Vim9: crash when using base name of import
Bram Moolenaar <Bram@vim.org>
parents:
25656
diff
changeset
|
1588 enddef |
fc8046209eaa
patch 8.2.3411: Vim9: crash when using base name of import
Bram Moolenaar <Bram@vim.org>
parents:
25656
diff
changeset
|
1589 |
24029
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1590 def Test_import_as() |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1591 var export_lines =<< trim END |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1592 vim9script |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1593 export var one = 1 |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1594 export var yes = 'yes' |
25186
0a3b1c66d3f2
patch 8.2.3129: Vim9: imported uninitialized list does not get type checked
Bram Moolenaar <Bram@vim.org>
parents:
25180
diff
changeset
|
1595 export var slist: list<string> |
24029
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1596 END |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1597 writefile(export_lines, 'XexportAs') |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1598 |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1599 var import_lines =<< trim END |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1600 vim9script |
24469
e5db23a8ad98
patch 8.2.2774: Vim9: cannot import an existing name even when using "as"
Bram Moolenaar <Bram@vim.org>
parents:
24460
diff
changeset
|
1601 var one = 'notused' |
e5db23a8ad98
patch 8.2.2774: Vim9: cannot import an existing name even when using "as"
Bram Moolenaar <Bram@vim.org>
parents:
24460
diff
changeset
|
1602 var yes = 777 |
24029
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1603 import one as thatOne from './XexportAs' |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1604 assert_equal(1, thatOne) |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1605 import yes as yesYes from './XexportAs' |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1606 assert_equal('yes', yesYes) |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1607 END |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1608 CheckScriptSuccess(import_lines) |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1609 |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1610 import_lines =<< trim END |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1611 vim9script |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1612 import {one as thatOne, yes as yesYes} from './XexportAs' |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1613 assert_equal(1, thatOne) |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1614 assert_equal('yes', yesYes) |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1615 assert_fails('echo one', 'E121:') |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1616 assert_fails('echo yes', 'E121:') |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1617 END |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1618 CheckScriptSuccess(import_lines) |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1619 |
25186
0a3b1c66d3f2
patch 8.2.3129: Vim9: imported uninitialized list does not get type checked
Bram Moolenaar <Bram@vim.org>
parents:
25180
diff
changeset
|
1620 import_lines =<< trim END |
0a3b1c66d3f2
patch 8.2.3129: Vim9: imported uninitialized list does not get type checked
Bram Moolenaar <Bram@vim.org>
parents:
25180
diff
changeset
|
1621 vim9script |
0a3b1c66d3f2
patch 8.2.3129: Vim9: imported uninitialized list does not get type checked
Bram Moolenaar <Bram@vim.org>
parents:
25180
diff
changeset
|
1622 import {slist as impSlist} from './XexportAs' |
0a3b1c66d3f2
patch 8.2.3129: Vim9: imported uninitialized list does not get type checked
Bram Moolenaar <Bram@vim.org>
parents:
25180
diff
changeset
|
1623 impSlist->add(123) |
0a3b1c66d3f2
patch 8.2.3129: Vim9: imported uninitialized list does not get type checked
Bram Moolenaar <Bram@vim.org>
parents:
25180
diff
changeset
|
1624 END |
0a3b1c66d3f2
patch 8.2.3129: Vim9: imported uninitialized list does not get type checked
Bram Moolenaar <Bram@vim.org>
parents:
25180
diff
changeset
|
1625 CheckScriptFailure(import_lines, 'E1012: Type mismatch; expected string but got number') |
0a3b1c66d3f2
patch 8.2.3129: Vim9: imported uninitialized list does not get type checked
Bram Moolenaar <Bram@vim.org>
parents:
25180
diff
changeset
|
1626 |
24029
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1627 delete('XexportAs') |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1628 enddef |
429b4f8d2fac
patch 8.2.2556: Vim9: :import with "as" not fully supported
Bram Moolenaar <Bram@vim.org>
parents:
24027
diff
changeset
|
1629 |
21652
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1630 func g:Trigger() |
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1631 source Ximport.vim |
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1632 return "echo 'yes'\<CR>" |
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1633 endfunc |
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1634 |
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1635 def Test_import_export_expr_map() |
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1636 # check that :import and :export work when buffer is locked |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1637 var export_lines =<< trim END |
21652
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1638 vim9script |
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1639 export def That(): string |
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1640 return 'yes' |
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1641 enddef |
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1642 END |
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1643 writefile(export_lines, 'Xexport_that.vim') |
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1644 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1645 var import_lines =<< trim END |
21652
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1646 vim9script |
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1647 import That from './Xexport_that.vim' |
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1648 assert_equal('yes', That()) |
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1649 END |
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1650 writefile(import_lines, 'Ximport.vim') |
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1651 |
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1652 nnoremap <expr> trigger g:Trigger() |
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1653 feedkeys('trigger', "xt") |
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1654 |
21701
6bb806a0238c
patch 8.2.1400: Vim9: test does not delete written files
Bram Moolenaar <Bram@vim.org>
parents:
21699
diff
changeset
|
1655 delete('Xexport_that.vim') |
21652
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1656 delete('Ximport.vim') |
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1657 nunmap trigger |
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1658 enddef |
befb512e0762
patch 8.2.1376: Vim9: expression mapping causes error for using :import
Bram Moolenaar <Bram@vim.org>
parents:
21648
diff
changeset
|
1659 |
21664
60ba361a7fdb
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21652
diff
changeset
|
1660 def Test_import_in_filetype() |
60ba361a7fdb
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21652
diff
changeset
|
1661 # check that :import works when the buffer is locked |
60ba361a7fdb
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21652
diff
changeset
|
1662 mkdir('ftplugin', 'p') |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1663 var export_lines =<< trim END |
21664
60ba361a7fdb
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21652
diff
changeset
|
1664 vim9script |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1665 export var That = 'yes' |
21664
60ba361a7fdb
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21652
diff
changeset
|
1666 END |
21701
6bb806a0238c
patch 8.2.1400: Vim9: test does not delete written files
Bram Moolenaar <Bram@vim.org>
parents:
21699
diff
changeset
|
1667 writefile(export_lines, 'ftplugin/Xexport_ft.vim') |
21664
60ba361a7fdb
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21652
diff
changeset
|
1668 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1669 var import_lines =<< trim END |
21664
60ba361a7fdb
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21652
diff
changeset
|
1670 vim9script |
21701
6bb806a0238c
patch 8.2.1400: Vim9: test does not delete written files
Bram Moolenaar <Bram@vim.org>
parents:
21699
diff
changeset
|
1671 import That from './Xexport_ft.vim' |
21664
60ba361a7fdb
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21652
diff
changeset
|
1672 assert_equal('yes', That) |
60ba361a7fdb
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21652
diff
changeset
|
1673 g:did_load_mytpe = 1 |
60ba361a7fdb
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21652
diff
changeset
|
1674 END |
60ba361a7fdb
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21652
diff
changeset
|
1675 writefile(import_lines, 'ftplugin/qf.vim') |
60ba361a7fdb
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21652
diff
changeset
|
1676 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1677 var save_rtp = &rtp |
21664
60ba361a7fdb
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21652
diff
changeset
|
1678 &rtp = getcwd() .. ',' .. &rtp |
60ba361a7fdb
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21652
diff
changeset
|
1679 |
60ba361a7fdb
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21652
diff
changeset
|
1680 filetype plugin on |
60ba361a7fdb
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21652
diff
changeset
|
1681 copen |
60ba361a7fdb
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21652
diff
changeset
|
1682 assert_equal(1, g:did_load_mytpe) |
60ba361a7fdb
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21652
diff
changeset
|
1683 |
60ba361a7fdb
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21652
diff
changeset
|
1684 quit! |
21701
6bb806a0238c
patch 8.2.1400: Vim9: test does not delete written files
Bram Moolenaar <Bram@vim.org>
parents:
21699
diff
changeset
|
1685 delete('Xexport_ft.vim') |
21664
60ba361a7fdb
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21652
diff
changeset
|
1686 delete('ftplugin', 'rf') |
60ba361a7fdb
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21652
diff
changeset
|
1687 &rtp = save_rtp |
60ba361a7fdb
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21652
diff
changeset
|
1688 enddef |
60ba361a7fdb
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21652
diff
changeset
|
1689 |
21699
1b96535705a0
patch 8.2.1399: Vim9: may find imported item in wrong script
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1690 def Test_use_import_in_mapping() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1691 var lines =<< trim END |
21699
1b96535705a0
patch 8.2.1399: Vim9: may find imported item in wrong script
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1692 vim9script |
1b96535705a0
patch 8.2.1399: Vim9: may find imported item in wrong script
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1693 export def Funcx() |
1b96535705a0
patch 8.2.1399: Vim9: may find imported item in wrong script
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1694 g:result = 42 |
1b96535705a0
patch 8.2.1399: Vim9: may find imported item in wrong script
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1695 enddef |
1b96535705a0
patch 8.2.1399: Vim9: may find imported item in wrong script
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1696 END |
1b96535705a0
patch 8.2.1399: Vim9: may find imported item in wrong script
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1697 writefile(lines, 'XsomeExport.vim') |
1b96535705a0
patch 8.2.1399: Vim9: may find imported item in wrong script
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1698 lines =<< trim END |
1b96535705a0
patch 8.2.1399: Vim9: may find imported item in wrong script
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1699 vim9script |
1b96535705a0
patch 8.2.1399: Vim9: may find imported item in wrong script
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1700 import Funcx from './XsomeExport.vim' |
21709
16d6b626aa8f
patch 8.2.1404: Vim9: script test fails in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
21707
diff
changeset
|
1701 nnoremap <F3> :call <sid>Funcx()<cr> |
21699
1b96535705a0
patch 8.2.1399: Vim9: may find imported item in wrong script
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1702 END |
1b96535705a0
patch 8.2.1399: Vim9: may find imported item in wrong script
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1703 writefile(lines, 'Xmapscript.vim') |
1b96535705a0
patch 8.2.1399: Vim9: may find imported item in wrong script
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1704 |
1b96535705a0
patch 8.2.1399: Vim9: may find imported item in wrong script
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1705 source Xmapscript.vim |
21709
16d6b626aa8f
patch 8.2.1404: Vim9: script test fails in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
21707
diff
changeset
|
1706 feedkeys("\<F3>", "xt") |
21699
1b96535705a0
patch 8.2.1399: Vim9: may find imported item in wrong script
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1707 assert_equal(42, g:result) |
1b96535705a0
patch 8.2.1399: Vim9: may find imported item in wrong script
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1708 |
1b96535705a0
patch 8.2.1399: Vim9: may find imported item in wrong script
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1709 unlet g:result |
1b96535705a0
patch 8.2.1399: Vim9: may find imported item in wrong script
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1710 delete('XsomeExport.vim') |
1b96535705a0
patch 8.2.1399: Vim9: may find imported item in wrong script
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1711 delete('Xmapscript.vim') |
21709
16d6b626aa8f
patch 8.2.1404: Vim9: script test fails in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
21707
diff
changeset
|
1712 nunmap <F3> |
21699
1b96535705a0
patch 8.2.1399: Vim9: may find imported item in wrong script
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1713 enddef |
1b96535705a0
patch 8.2.1399: Vim9: may find imported item in wrong script
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1714 |
23974
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23954
diff
changeset
|
1715 def Test_vim9script_mix() |
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23954
diff
changeset
|
1716 var lines =<< trim END |
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23954
diff
changeset
|
1717 if has(g:feature) |
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23954
diff
changeset
|
1718 " legacy script |
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23954
diff
changeset
|
1719 let g:legacy = 1 |
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23954
diff
changeset
|
1720 finish |
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23954
diff
changeset
|
1721 endif |
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23954
diff
changeset
|
1722 vim9script |
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23954
diff
changeset
|
1723 g:legacy = 0 |
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23954
diff
changeset
|
1724 END |
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23954
diff
changeset
|
1725 g:feature = 'eval' |
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23954
diff
changeset
|
1726 g:legacy = -1 |
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23954
diff
changeset
|
1727 CheckScriptSuccess(lines) |
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23954
diff
changeset
|
1728 assert_equal(1, g:legacy) |
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23954
diff
changeset
|
1729 |
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23954
diff
changeset
|
1730 g:feature = 'noteval' |
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23954
diff
changeset
|
1731 g:legacy = -1 |
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23954
diff
changeset
|
1732 CheckScriptSuccess(lines) |
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23954
diff
changeset
|
1733 assert_equal(0, g:legacy) |
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23954
diff
changeset
|
1734 enddef |
d4f7e4138544
patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents:
23954
diff
changeset
|
1735 |
19507
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1736 def Test_vim9script_fails() |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1737 CheckScriptFailure(['scriptversion 2', 'vim9script'], 'E1039:') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1738 CheckScriptFailure(['vim9script', 'scriptversion 2'], 'E1040:') |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1739 CheckScriptFailure(['export var some = 123'], 'E1042:') |
20816
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
1740 CheckScriptFailure(['import some from "./Xexport.vim"'], 'E1048:') |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1741 CheckScriptFailure(['vim9script', 'export var g:some'], 'E1022:') |
19507
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1742 CheckScriptFailure(['vim9script', 'export echo 134'], 'E1043:') |
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1743 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1744 CheckScriptFailure(['vim9script', 'var str: string', 'str = 1234'], 'E1012:') |
20919
96bf2b304932
patch 8.2.1011: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
20915
diff
changeset
|
1745 CheckScriptFailure(['vim9script', 'const str = "asdf"', 'str = "xxx"'], 'E46:') |
96bf2b304932
patch 8.2.1011: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
20915
diff
changeset
|
1746 |
22087
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
21987
diff
changeset
|
1747 assert_fails('vim9script', 'E1038:') |
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
21987
diff
changeset
|
1748 assert_fails('export something', 'E1043:') |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1749 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1750 |
20883
8bc11506d787
patch 8.2.0993: Vim9 script test fails with normal features
Bram Moolenaar <Bram@vim.org>
parents:
20881
diff
changeset
|
1751 func Test_import_fails_without_script() |
20881
58137dbee8da
patch 8.2.0992: Vim9: crash when using :import in the Vim command
Bram Moolenaar <Bram@vim.org>
parents:
20871
diff
changeset
|
1752 CheckRunVimInTerminal |
58137dbee8da
patch 8.2.0992: Vim9: crash when using :import in the Vim command
Bram Moolenaar <Bram@vim.org>
parents:
20871
diff
changeset
|
1753 |
20885
b70555af8908
patch 8.2.0994: Vim9: missing function causes compilation error
Bram Moolenaar <Bram@vim.org>
parents:
20883
diff
changeset
|
1754 " call indirectly to avoid compilation error for missing functions |
21206
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1755 call Run_Test_import_fails_on_command_line() |
20885
b70555af8908
patch 8.2.0994: Vim9: missing function causes compilation error
Bram Moolenaar <Bram@vim.org>
parents:
20883
diff
changeset
|
1756 endfunc |
b70555af8908
patch 8.2.0994: Vim9: missing function causes compilation error
Bram Moolenaar <Bram@vim.org>
parents:
20883
diff
changeset
|
1757 |
21206
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1758 def Run_Test_import_fails_on_command_line() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1759 var export =<< trim END |
20881
58137dbee8da
patch 8.2.0992: Vim9: crash when using :import in the Vim command
Bram Moolenaar <Bram@vim.org>
parents:
20871
diff
changeset
|
1760 vim9script |
58137dbee8da
patch 8.2.0992: Vim9: crash when using :import in the Vim command
Bram Moolenaar <Bram@vim.org>
parents:
20871
diff
changeset
|
1761 export def Foo(): number |
58137dbee8da
patch 8.2.0992: Vim9: crash when using :import in the Vim command
Bram Moolenaar <Bram@vim.org>
parents:
20871
diff
changeset
|
1762 return 0 |
58137dbee8da
patch 8.2.0992: Vim9: crash when using :import in the Vim command
Bram Moolenaar <Bram@vim.org>
parents:
20871
diff
changeset
|
1763 enddef |
58137dbee8da
patch 8.2.0992: Vim9: crash when using :import in the Vim command
Bram Moolenaar <Bram@vim.org>
parents:
20871
diff
changeset
|
1764 END |
21701
6bb806a0238c
patch 8.2.1400: Vim9: test does not delete written files
Bram Moolenaar <Bram@vim.org>
parents:
21699
diff
changeset
|
1765 writefile(export, 'XexportCmd.vim') |
6bb806a0238c
patch 8.2.1400: Vim9: test does not delete written files
Bram Moolenaar <Bram@vim.org>
parents:
21699
diff
changeset
|
1766 |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23068
diff
changeset
|
1767 var buf = RunVimInTerminal('-c "import Foo from ''./XexportCmd.vim''"', { |
20885
b70555af8908
patch 8.2.0994: Vim9: missing function causes compilation error
Bram Moolenaar <Bram@vim.org>
parents:
20883
diff
changeset
|
1768 rows: 6, wait_for_ruler: 0}) |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23364
diff
changeset
|
1769 WaitForAssert(() => assert_match('^E1094:', term_getline(buf, 5))) |
20881
58137dbee8da
patch 8.2.0992: Vim9: crash when using :import in the Vim command
Bram Moolenaar <Bram@vim.org>
parents:
20871
diff
changeset
|
1770 |
21701
6bb806a0238c
patch 8.2.1400: Vim9: test does not delete written files
Bram Moolenaar <Bram@vim.org>
parents:
21699
diff
changeset
|
1771 delete('XexportCmd.vim') |
20885
b70555af8908
patch 8.2.0994: Vim9: missing function causes compilation error
Bram Moolenaar <Bram@vim.org>
parents:
20883
diff
changeset
|
1772 StopVimInTerminal(buf) |
b70555af8908
patch 8.2.0994: Vim9: missing function causes compilation error
Bram Moolenaar <Bram@vim.org>
parents:
20883
diff
changeset
|
1773 enddef |
20881
58137dbee8da
patch 8.2.0992: Vim9: crash when using :import in the Vim command
Bram Moolenaar <Bram@vim.org>
parents:
20871
diff
changeset
|
1774 |
23358
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1775 def Test_vim9script_reload_noclear() |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1776 var lines =<< trim END |
23364
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
1777 vim9script |
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
1778 export var exported = 'thexport' |
25425
effe5f2b4d01
patch 8.2.3249: Vim9: error for re-imported function with default argument
Bram Moolenaar <Bram@vim.org>
parents:
25423
diff
changeset
|
1779 |
effe5f2b4d01
patch 8.2.3249: Vim9: error for re-imported function with default argument
Bram Moolenaar <Bram@vim.org>
parents:
25423
diff
changeset
|
1780 export def TheFunc(x = 0) |
effe5f2b4d01
patch 8.2.3249: Vim9: error for re-imported function with default argument
Bram Moolenaar <Bram@vim.org>
parents:
25423
diff
changeset
|
1781 enddef |
23364
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
1782 END |
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
1783 writefile(lines, 'XExportReload') |
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
1784 lines =<< trim END |
23358
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1785 vim9script noclear |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1786 g:loadCount += 1 |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1787 var s:reloaded = 'init' |
23364
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
1788 import exported from './XExportReload' |
23358
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1789 |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1790 def Again(): string |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1791 return 'again' |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1792 enddef |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1793 |
25425
effe5f2b4d01
patch 8.2.3249: Vim9: error for re-imported function with default argument
Bram Moolenaar <Bram@vim.org>
parents:
25423
diff
changeset
|
1794 import TheFunc from './XExportReload' |
effe5f2b4d01
patch 8.2.3249: Vim9: error for re-imported function with default argument
Bram Moolenaar <Bram@vim.org>
parents:
25423
diff
changeset
|
1795 TheFunc() |
effe5f2b4d01
patch 8.2.3249: Vim9: error for re-imported function with default argument
Bram Moolenaar <Bram@vim.org>
parents:
25423
diff
changeset
|
1796 |
23358
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1797 if exists('s:loaded') | finish | endif |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1798 var s:loaded = true |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1799 |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1800 var s:notReloaded = 'yes' |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1801 s:reloaded = 'first' |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1802 def g:Values(): list<string> |
23364
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
1803 return [s:reloaded, s:notReloaded, Again(), Once(), exported] |
23358
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1804 enddef |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1805 |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1806 def Once(): string |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1807 return 'once' |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1808 enddef |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1809 END |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1810 writefile(lines, 'XReloaded') |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1811 g:loadCount = 0 |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1812 source XReloaded |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1813 assert_equal(1, g:loadCount) |
23364
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
1814 assert_equal(['first', 'yes', 'again', 'once', 'thexport'], g:Values()) |
23358
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1815 source XReloaded |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1816 assert_equal(2, g:loadCount) |
23364
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
1817 assert_equal(['init', 'yes', 'again', 'once', 'thexport'], g:Values()) |
23358
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1818 source XReloaded |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1819 assert_equal(3, g:loadCount) |
23364
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
1820 assert_equal(['init', 'yes', 'again', 'once', 'thexport'], g:Values()) |
23358
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1821 |
23571
b02ac00aacbf
patch 8.2.2328: some test files may not be deleted
Bram Moolenaar <Bram@vim.org>
parents:
23440
diff
changeset
|
1822 delete('XReloaded') |
23364
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
1823 delete('XExportReload') |
23358
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1824 delfunc g:Values |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1825 unlet g:loadCount |
25057
ffc3e1164652
patch 8.2.3065: Vim9: error when sourcing script twice and reusing function
Bram Moolenaar <Bram@vim.org>
parents:
25028
diff
changeset
|
1826 |
ffc3e1164652
patch 8.2.3065: Vim9: error when sourcing script twice and reusing function
Bram Moolenaar <Bram@vim.org>
parents:
25028
diff
changeset
|
1827 lines =<< trim END |
ffc3e1164652
patch 8.2.3065: Vim9: error when sourcing script twice and reusing function
Bram Moolenaar <Bram@vim.org>
parents:
25028
diff
changeset
|
1828 vim9script |
ffc3e1164652
patch 8.2.3065: Vim9: error when sourcing script twice and reusing function
Bram Moolenaar <Bram@vim.org>
parents:
25028
diff
changeset
|
1829 def Inner() |
ffc3e1164652
patch 8.2.3065: Vim9: error when sourcing script twice and reusing function
Bram Moolenaar <Bram@vim.org>
parents:
25028
diff
changeset
|
1830 enddef |
ffc3e1164652
patch 8.2.3065: Vim9: error when sourcing script twice and reusing function
Bram Moolenaar <Bram@vim.org>
parents:
25028
diff
changeset
|
1831 END |
ffc3e1164652
patch 8.2.3065: Vim9: error when sourcing script twice and reusing function
Bram Moolenaar <Bram@vim.org>
parents:
25028
diff
changeset
|
1832 lines->writefile('XreloadScript.vim') |
ffc3e1164652
patch 8.2.3065: Vim9: error when sourcing script twice and reusing function
Bram Moolenaar <Bram@vim.org>
parents:
25028
diff
changeset
|
1833 source XreloadScript.vim |
ffc3e1164652
patch 8.2.3065: Vim9: error when sourcing script twice and reusing function
Bram Moolenaar <Bram@vim.org>
parents:
25028
diff
changeset
|
1834 |
ffc3e1164652
patch 8.2.3065: Vim9: error when sourcing script twice and reusing function
Bram Moolenaar <Bram@vim.org>
parents:
25028
diff
changeset
|
1835 lines =<< trim END |
ffc3e1164652
patch 8.2.3065: Vim9: error when sourcing script twice and reusing function
Bram Moolenaar <Bram@vim.org>
parents:
25028
diff
changeset
|
1836 vim9script |
ffc3e1164652
patch 8.2.3065: Vim9: error when sourcing script twice and reusing function
Bram Moolenaar <Bram@vim.org>
parents:
25028
diff
changeset
|
1837 def Outer() |
ffc3e1164652
patch 8.2.3065: Vim9: error when sourcing script twice and reusing function
Bram Moolenaar <Bram@vim.org>
parents:
25028
diff
changeset
|
1838 def Inner() |
ffc3e1164652
patch 8.2.3065: Vim9: error when sourcing script twice and reusing function
Bram Moolenaar <Bram@vim.org>
parents:
25028
diff
changeset
|
1839 enddef |
ffc3e1164652
patch 8.2.3065: Vim9: error when sourcing script twice and reusing function
Bram Moolenaar <Bram@vim.org>
parents:
25028
diff
changeset
|
1840 enddef |
ffc3e1164652
patch 8.2.3065: Vim9: error when sourcing script twice and reusing function
Bram Moolenaar <Bram@vim.org>
parents:
25028
diff
changeset
|
1841 defcompile |
ffc3e1164652
patch 8.2.3065: Vim9: error when sourcing script twice and reusing function
Bram Moolenaar <Bram@vim.org>
parents:
25028
diff
changeset
|
1842 END |
ffc3e1164652
patch 8.2.3065: Vim9: error when sourcing script twice and reusing function
Bram Moolenaar <Bram@vim.org>
parents:
25028
diff
changeset
|
1843 lines->writefile('XreloadScript.vim') |
ffc3e1164652
patch 8.2.3065: Vim9: error when sourcing script twice and reusing function
Bram Moolenaar <Bram@vim.org>
parents:
25028
diff
changeset
|
1844 source XreloadScript.vim |
ffc3e1164652
patch 8.2.3065: Vim9: error when sourcing script twice and reusing function
Bram Moolenaar <Bram@vim.org>
parents:
25028
diff
changeset
|
1845 |
ffc3e1164652
patch 8.2.3065: Vim9: error when sourcing script twice and reusing function
Bram Moolenaar <Bram@vim.org>
parents:
25028
diff
changeset
|
1846 delete('XreloadScript.vim') |
23358
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1847 enddef |
b3142fc0a414
patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents:
23342
diff
changeset
|
1848 |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1849 def Test_vim9script_reload_import() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1850 var lines =<< trim END |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1851 vim9script |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1852 const var = '' |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1853 var valone = 1234 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1854 def MyFunc(arg: string) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1855 valone = 5678 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1856 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1857 END |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1858 var morelines =<< trim END |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1859 var valtwo = 222 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1860 export def GetValtwo(): number |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1861 return valtwo |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1862 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1863 END |
20195
a2447c58da25
patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
1864 writefile(lines + morelines, 'Xreload.vim') |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1865 source Xreload.vim |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1866 source Xreload.vim |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1867 source Xreload.vim |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1868 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
1869 # cannot declare a var twice |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1870 lines =<< trim END |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1871 vim9script |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1872 var valone = 1234 |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1873 var valone = 5678 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1874 END |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1875 writefile(lines, 'Xreload.vim') |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22147
diff
changeset
|
1876 assert_fails('source Xreload.vim', 'E1041:', '', 3, 'Xreload.vim') |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1877 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1878 delete('Xreload.vim') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1879 delete('Ximport.vim') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1880 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1881 |
23362
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1882 " if a script is reloaded with a script-local variable that changed its type, a |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1883 " compiled function using that variable must fail. |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1884 def Test_script_reload_change_type() |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1885 var lines =<< trim END |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1886 vim9script noclear |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1887 var str = 'string' |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1888 def g:GetStr(): string |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1889 return str .. 'xxx' |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1890 enddef |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1891 END |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1892 writefile(lines, 'Xreload.vim') |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1893 source Xreload.vim |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1894 echo g:GetStr() |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1895 |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1896 lines =<< trim END |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1897 vim9script noclear |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1898 var str = 1234 |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1899 END |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1900 writefile(lines, 'Xreload.vim') |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1901 source Xreload.vim |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1902 assert_fails('echo g:GetStr()', 'E1150:') |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1903 |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1904 delfunc g:GetStr |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1905 delete('Xreload.vim') |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1906 enddef |
f181fe2150ab
patch 8.2.2224: Vim9: crash if script reloaded with different variable type
Bram Moolenaar <Bram@vim.org>
parents:
23360
diff
changeset
|
1907 |
24146
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1908 " Define CallFunc so that the test can be compiled |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1909 command CallFunc echo 'nop' |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1910 |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1911 def Test_script_reload_from_function() |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1912 var lines =<< trim END |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1913 vim9script |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1914 |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1915 if exists('g:loaded') |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1916 finish |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1917 endif |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1918 g:loaded = 1 |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1919 delcommand CallFunc |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1920 command CallFunc Func() |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1921 def Func() |
24148
0edc315f2d0c
patch 8.2.2615: test is sourcing the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
24146
diff
changeset
|
1922 so XreloadFunc.vim |
24146
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1923 g:didTheFunc = 1 |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1924 enddef |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1925 END |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1926 writefile(lines, 'XreloadFunc.vim') |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1927 source XreloadFunc.vim |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1928 CallFunc |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1929 assert_equal(1, g:didTheFunc) |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1930 |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1931 delete('XreloadFunc.vim') |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1932 delcommand CallFunc |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1933 unlet g:loaded |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1934 unlet g:didTheFunc |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1935 enddef |
03fc95628eb0
patch 8.2.2614: Vim9: function is deleted while executing
Bram Moolenaar <Bram@vim.org>
parents:
24122
diff
changeset
|
1936 |
24051
da8347e453b4
patch 8.2.2567: Vim9: no error if variable is defined for existing function
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1937 def Test_script_var_shadows_function() |
da8347e453b4
patch 8.2.2567: Vim9: no error if variable is defined for existing function
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1938 var lines =<< trim END |
da8347e453b4
patch 8.2.2567: Vim9: no error if variable is defined for existing function
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1939 vim9script |
da8347e453b4
patch 8.2.2567: Vim9: no error if variable is defined for existing function
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1940 def Func(): number |
da8347e453b4
patch 8.2.2567: Vim9: no error if variable is defined for existing function
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1941 return 123 |
da8347e453b4
patch 8.2.2567: Vim9: no error if variable is defined for existing function
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1942 enddef |
da8347e453b4
patch 8.2.2567: Vim9: no error if variable is defined for existing function
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1943 var Func = 1 |
da8347e453b4
patch 8.2.2567: Vim9: no error if variable is defined for existing function
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1944 END |
da8347e453b4
patch 8.2.2567: Vim9: no error if variable is defined for existing function
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1945 CheckScriptFailure(lines, 'E1041:', 5) |
da8347e453b4
patch 8.2.2567: Vim9: no error if variable is defined for existing function
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1946 enddef |
da8347e453b4
patch 8.2.2567: Vim9: no error if variable is defined for existing function
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1947 |
26504
7821550ba3a8
patch 8.2.3782: Vim9: no error if a function shadows a script variable
Bram Moolenaar <Bram@vim.org>
parents:
26496
diff
changeset
|
1948 def Test_function_shadows_script_var() |
7821550ba3a8
patch 8.2.3782: Vim9: no error if a function shadows a script variable
Bram Moolenaar <Bram@vim.org>
parents:
26496
diff
changeset
|
1949 var lines =<< trim END |
7821550ba3a8
patch 8.2.3782: Vim9: no error if a function shadows a script variable
Bram Moolenaar <Bram@vim.org>
parents:
26496
diff
changeset
|
1950 vim9script |
7821550ba3a8
patch 8.2.3782: Vim9: no error if a function shadows a script variable
Bram Moolenaar <Bram@vim.org>
parents:
26496
diff
changeset
|
1951 var Func = 1 |
7821550ba3a8
patch 8.2.3782: Vim9: no error if a function shadows a script variable
Bram Moolenaar <Bram@vim.org>
parents:
26496
diff
changeset
|
1952 def Func(): number |
7821550ba3a8
patch 8.2.3782: Vim9: no error if a function shadows a script variable
Bram Moolenaar <Bram@vim.org>
parents:
26496
diff
changeset
|
1953 return 123 |
7821550ba3a8
patch 8.2.3782: Vim9: no error if a function shadows a script variable
Bram Moolenaar <Bram@vim.org>
parents:
26496
diff
changeset
|
1954 enddef |
7821550ba3a8
patch 8.2.3782: Vim9: no error if a function shadows a script variable
Bram Moolenaar <Bram@vim.org>
parents:
26496
diff
changeset
|
1955 END |
7821550ba3a8
patch 8.2.3782: Vim9: no error if a function shadows a script variable
Bram Moolenaar <Bram@vim.org>
parents:
26496
diff
changeset
|
1956 CheckScriptFailure(lines, 'E1041:', 3) |
7821550ba3a8
patch 8.2.3782: Vim9: no error if a function shadows a script variable
Bram Moolenaar <Bram@vim.org>
parents:
26496
diff
changeset
|
1957 enddef |
7821550ba3a8
patch 8.2.3782: Vim9: no error if a function shadows a script variable
Bram Moolenaar <Bram@vim.org>
parents:
26496
diff
changeset
|
1958 |
25202
e5d85e83a887
patch 8.2.3137: Vim9: no error when a line only has a variable name
Bram Moolenaar <Bram@vim.org>
parents:
25188
diff
changeset
|
1959 def Test_script_var_shadows_command() |
e5d85e83a887
patch 8.2.3137: Vim9: no error when a line only has a variable name
Bram Moolenaar <Bram@vim.org>
parents:
25188
diff
changeset
|
1960 var lines =<< trim END |
e5d85e83a887
patch 8.2.3137: Vim9: no error when a line only has a variable name
Bram Moolenaar <Bram@vim.org>
parents:
25188
diff
changeset
|
1961 var undo = 1 |
e5d85e83a887
patch 8.2.3137: Vim9: no error when a line only has a variable name
Bram Moolenaar <Bram@vim.org>
parents:
25188
diff
changeset
|
1962 undo = 2 |
e5d85e83a887
patch 8.2.3137: Vim9: no error when a line only has a variable name
Bram Moolenaar <Bram@vim.org>
parents:
25188
diff
changeset
|
1963 assert_equal(2, undo) |
e5d85e83a887
patch 8.2.3137: Vim9: no error when a line only has a variable name
Bram Moolenaar <Bram@vim.org>
parents:
25188
diff
changeset
|
1964 END |
e5d85e83a887
patch 8.2.3137: Vim9: no error when a line only has a variable name
Bram Moolenaar <Bram@vim.org>
parents:
25188
diff
changeset
|
1965 CheckDefAndScriptSuccess(lines) |
e5d85e83a887
patch 8.2.3137: Vim9: no error when a line only has a variable name
Bram Moolenaar <Bram@vim.org>
parents:
25188
diff
changeset
|
1966 |
e5d85e83a887
patch 8.2.3137: Vim9: no error when a line only has a variable name
Bram Moolenaar <Bram@vim.org>
parents:
25188
diff
changeset
|
1967 lines =<< trim END |
e5d85e83a887
patch 8.2.3137: Vim9: no error when a line only has a variable name
Bram Moolenaar <Bram@vim.org>
parents:
25188
diff
changeset
|
1968 var undo = 1 |
e5d85e83a887
patch 8.2.3137: Vim9: no error when a line only has a variable name
Bram Moolenaar <Bram@vim.org>
parents:
25188
diff
changeset
|
1969 undo |
e5d85e83a887
patch 8.2.3137: Vim9: no error when a line only has a variable name
Bram Moolenaar <Bram@vim.org>
parents:
25188
diff
changeset
|
1970 END |
e5d85e83a887
patch 8.2.3137: Vim9: no error when a line only has a variable name
Bram Moolenaar <Bram@vim.org>
parents:
25188
diff
changeset
|
1971 CheckDefAndScriptFailure(lines, 'E1207:', 2) |
e5d85e83a887
patch 8.2.3137: Vim9: no error when a line only has a variable name
Bram Moolenaar <Bram@vim.org>
parents:
25188
diff
changeset
|
1972 enddef |
e5d85e83a887
patch 8.2.3137: Vim9: no error when a line only has a variable name
Bram Moolenaar <Bram@vim.org>
parents:
25188
diff
changeset
|
1973 |
26506
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26504
diff
changeset
|
1974 def Test_vim9script_call_wrong_type() |
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26504
diff
changeset
|
1975 var lines =<< trim END |
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26504
diff
changeset
|
1976 vim9script |
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26504
diff
changeset
|
1977 var Time = 'localtime' |
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26504
diff
changeset
|
1978 Time() |
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26504
diff
changeset
|
1979 END |
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26504
diff
changeset
|
1980 CheckScriptFailure(lines, 'E1085:') |
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26504
diff
changeset
|
1981 enddef |
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26504
diff
changeset
|
1982 |
21983
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21979
diff
changeset
|
1983 def s:RetSome(): string |
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21979
diff
changeset
|
1984 return 'some' |
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21979
diff
changeset
|
1985 enddef |
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21979
diff
changeset
|
1986 |
21202
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1987 " Not exported function that is referenced needs to be accessed by the |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1988 " script-local name. |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1989 def Test_vim9script_funcref() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
1990 var sortlines =<< trim END |
21202
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1991 vim9script |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1992 def Compare(i1: number, i2: number): number |
21204
3c91581cef33
patch 8.2.1153: Vim9: script test fails on some systems
Bram Moolenaar <Bram@vim.org>
parents:
21202
diff
changeset
|
1993 return i2 - i1 |
21202
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1994 enddef |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1995 |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1996 export def FastSort(): list<number> |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1997 return range(5)->sort(Compare) |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1998 enddef |
24283
bcfff560e089
patch 8.2.2682: Vim9: cannot find Name.Func from "import * as Name"
Bram Moolenaar <Bram@vim.org>
parents:
24279
diff
changeset
|
1999 |
bcfff560e089
patch 8.2.2682: Vim9: cannot find Name.Func from "import * as Name"
Bram Moolenaar <Bram@vim.org>
parents:
24279
diff
changeset
|
2000 export def GetString(arg: string): string |
bcfff560e089
patch 8.2.2682: Vim9: cannot find Name.Func from "import * as Name"
Bram Moolenaar <Bram@vim.org>
parents:
24279
diff
changeset
|
2001 return arg |
bcfff560e089
patch 8.2.2682: Vim9: cannot find Name.Func from "import * as Name"
Bram Moolenaar <Bram@vim.org>
parents:
24279
diff
changeset
|
2002 enddef |
21202
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
2003 END |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
2004 writefile(sortlines, 'Xsort.vim') |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
2005 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2006 var lines =<< trim END |
21202
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
2007 vim9script |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
2008 import FastSort from './Xsort.vim' |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
2009 def Test() |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
2010 g:result = FastSort() |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
2011 enddef |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
2012 Test() |
24283
bcfff560e089
patch 8.2.2682: Vim9: cannot find Name.Func from "import * as Name"
Bram Moolenaar <Bram@vim.org>
parents:
24279
diff
changeset
|
2013 |
bcfff560e089
patch 8.2.2682: Vim9: cannot find Name.Func from "import * as Name"
Bram Moolenaar <Bram@vim.org>
parents:
24279
diff
changeset
|
2014 # using a function imported with "as" |
bcfff560e089
patch 8.2.2682: Vim9: cannot find Name.Func from "import * as Name"
Bram Moolenaar <Bram@vim.org>
parents:
24279
diff
changeset
|
2015 import * as anAlias from './Xsort.vim' |
bcfff560e089
patch 8.2.2682: Vim9: cannot find Name.Func from "import * as Name"
Bram Moolenaar <Bram@vim.org>
parents:
24279
diff
changeset
|
2016 assert_equal('yes', anAlias.GetString('yes')) |
bcfff560e089
patch 8.2.2682: Vim9: cannot find Name.Func from "import * as Name"
Bram Moolenaar <Bram@vim.org>
parents:
24279
diff
changeset
|
2017 |
bcfff560e089
patch 8.2.2682: Vim9: cannot find Name.Func from "import * as Name"
Bram Moolenaar <Bram@vim.org>
parents:
24279
diff
changeset
|
2018 # using the function from a compiled function |
bcfff560e089
patch 8.2.2682: Vim9: cannot find Name.Func from "import * as Name"
Bram Moolenaar <Bram@vim.org>
parents:
24279
diff
changeset
|
2019 def TestMore(): string |
24295
7f634eae21fe
patch 8.2.2688: Vim9: crash when using s: for script variable
Bram Moolenaar <Bram@vim.org>
parents:
24283
diff
changeset
|
2020 var s = s:anAlias.GetString('foo') |
7f634eae21fe
patch 8.2.2688: Vim9: crash when using s: for script variable
Bram Moolenaar <Bram@vim.org>
parents:
24283
diff
changeset
|
2021 return s .. anAlias.GetString('bar') |
24283
bcfff560e089
patch 8.2.2682: Vim9: cannot find Name.Func from "import * as Name"
Bram Moolenaar <Bram@vim.org>
parents:
24279
diff
changeset
|
2022 enddef |
24295
7f634eae21fe
patch 8.2.2688: Vim9: crash when using s: for script variable
Bram Moolenaar <Bram@vim.org>
parents:
24283
diff
changeset
|
2023 assert_equal('foobar', TestMore()) |
24283
bcfff560e089
patch 8.2.2682: Vim9: cannot find Name.Func from "import * as Name"
Bram Moolenaar <Bram@vim.org>
parents:
24279
diff
changeset
|
2024 |
bcfff560e089
patch 8.2.2682: Vim9: cannot find Name.Func from "import * as Name"
Bram Moolenaar <Bram@vim.org>
parents:
24279
diff
changeset
|
2025 # error when using a function that isn't exported |
bcfff560e089
patch 8.2.2682: Vim9: cannot find Name.Func from "import * as Name"
Bram Moolenaar <Bram@vim.org>
parents:
24279
diff
changeset
|
2026 assert_fails('anAlias.Compare(1, 2)', 'E1049:') |
21202
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
2027 END |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
2028 writefile(lines, 'Xscript.vim') |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
2029 |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
2030 source Xscript.vim |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
2031 assert_equal([4, 3, 2, 1, 0], g:result) |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
2032 |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
2033 unlet g:result |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
2034 delete('Xsort.vim') |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
2035 delete('Xscript.vim') |
21983
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21979
diff
changeset
|
2036 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2037 var Funcref = function('s:RetSome') |
21983
3fe594c72d8c
patch 8.2.1541: Vim9: cannot find function reference for s:Func
Bram Moolenaar <Bram@vim.org>
parents:
21979
diff
changeset
|
2038 assert_equal('some', Funcref()) |
21202
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
2039 enddef |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
2040 |
21955
3991a6df522e
patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents:
21939
diff
changeset
|
2041 " Check that when searching for "FilterFunc" it finds the import in the |
3991a6df522e
patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents:
21939
diff
changeset
|
2042 " script where FastFilter() is called from, both as a string and as a direct |
3991a6df522e
patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents:
21939
diff
changeset
|
2043 " function reference. |
21206
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
2044 def Test_vim9script_funcref_other_script() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2045 var filterLines =<< trim END |
21206
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
2046 vim9script |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
2047 export def FilterFunc(idx: number, val: number): bool |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
2048 return idx % 2 == 1 |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
2049 enddef |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
2050 export def FastFilter(): list<number> |
26737
10d3105030ab
patch 8.2.3897: Vim9: second argument of map() and filter() not checked
Bram Moolenaar <Bram@vim.org>
parents:
26698
diff
changeset
|
2051 return range(10)->filter('FilterFunc(v:key, v:val)') |
21206
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
2052 enddef |
21955
3991a6df522e
patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents:
21939
diff
changeset
|
2053 export def FastFilterDirect(): list<number> |
3991a6df522e
patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents:
21939
diff
changeset
|
2054 return range(10)->filter(FilterFunc) |
3991a6df522e
patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents:
21939
diff
changeset
|
2055 enddef |
21206
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
2056 END |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
2057 writefile(filterLines, 'Xfilter.vim') |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
2058 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2059 var lines =<< trim END |
21206
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
2060 vim9script |
21955
3991a6df522e
patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents:
21939
diff
changeset
|
2061 import {FilterFunc, FastFilter, FastFilterDirect} from './Xfilter.vim' |
21206
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
2062 def Test() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2063 var x: list<number> = FastFilter() |
21206
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
2064 enddef |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
2065 Test() |
21955
3991a6df522e
patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents:
21939
diff
changeset
|
2066 def TestDirect() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2067 var x: list<number> = FastFilterDirect() |
21955
3991a6df522e
patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents:
21939
diff
changeset
|
2068 enddef |
3991a6df522e
patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents:
21939
diff
changeset
|
2069 TestDirect() |
21206
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
2070 END |
21955
3991a6df522e
patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents:
21939
diff
changeset
|
2071 CheckScriptSuccess(lines) |
21206
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
2072 delete('Xfilter.vim') |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
2073 enddef |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
2074 |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2075 def Test_vim9script_reload_delfunc() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2076 var first_lines =<< trim END |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2077 vim9script |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2078 def FuncYes(): string |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2079 return 'yes' |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2080 enddef |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2081 END |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2082 var withno_lines =<< trim END |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2083 def FuncNo(): string |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2084 return 'no' |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2085 enddef |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2086 def g:DoCheck(no_exists: bool) |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2087 assert_equal('yes', FuncYes()) |
20195
a2447c58da25
patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
2088 assert_equal('no', FuncNo()) |
a2447c58da25
patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
2089 enddef |
a2447c58da25
patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
2090 END |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2091 var nono_lines =<< trim END |
20195
a2447c58da25
patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
2092 def g:DoCheck(no_exists: bool) |
a2447c58da25
patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
2093 assert_equal('yes', FuncYes()) |
22165
c512e6f57ff2
patch 8.2.1632: not checking the context of test_fails()
Bram Moolenaar <Bram@vim.org>
parents:
22147
diff
changeset
|
2094 assert_fails('FuncNo()', 'E117:', '', 2, 'DoCheck') |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2095 enddef |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2096 END |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2097 |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2098 # FuncNo() is defined |
20195
a2447c58da25
patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
2099 writefile(first_lines + withno_lines, 'Xreloaded.vim') |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2100 source Xreloaded.vim |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2101 g:DoCheck(true) |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2102 |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2103 # FuncNo() is not redefined |
20195
a2447c58da25
patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
2104 writefile(first_lines + nono_lines, 'Xreloaded.vim') |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2105 source Xreloaded.vim |
23252
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23247
diff
changeset
|
2106 g:DoCheck(false) |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2107 |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2108 # FuncNo() is back |
20195
a2447c58da25
patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
2109 writefile(first_lines + withno_lines, 'Xreloaded.vim') |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2110 source Xreloaded.vim |
23252
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23247
diff
changeset
|
2111 g:DoCheck(false) |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2112 |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2113 delete('Xreloaded.vim') |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2114 enddef |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2115 |
20347
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
2116 def Test_vim9script_reload_delvar() |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
2117 # write the script with a script-local variable |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2118 var lines =<< trim END |
20347
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
2119 vim9script |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2120 var name = 'string' |
20347
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
2121 END |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
2122 writefile(lines, 'XreloadVar.vim') |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
2123 source XreloadVar.vim |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
2124 |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
2125 # now write the script using the same variable locally - works |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
2126 lines =<< trim END |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
2127 vim9script |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
2128 def Func() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2129 var name = 'string' |
20347
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
2130 enddef |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
2131 END |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
2132 writefile(lines, 'XreloadVar.vim') |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
2133 source XreloadVar.vim |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
2134 |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
2135 delete('XreloadVar.vim') |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
2136 enddef |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
2137 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2138 def Test_import_absolute() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2139 var import_lines = [ |
20011
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
2140 'vim9script', |
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
2141 'import exported from "' .. escape(getcwd(), '\') .. '/Xexport_abs.vim"', |
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
2142 'def UseExported()', |
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
2143 ' g:imported_abs = exported', |
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
2144 ' exported = 8888', |
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
2145 ' g:imported_after = exported', |
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
2146 'enddef', |
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
2147 'UseExported()', |
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
2148 'g:import_disassembled = execute("disass UseExported")', |
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
2149 ] |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2150 writefile(import_lines, 'Ximport_abs.vim') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2151 writefile(s:export_script_lines, 'Xexport_abs.vim') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2152 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2153 source Ximport_abs.vim |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2154 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2155 assert_equal(9876, g:imported_abs) |
19285
86665583dc83
patch 8.2.0201: cannot assign to an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
19283
diff
changeset
|
2156 assert_equal(8888, g:imported_after) |
22596
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
2157 assert_match('<SNR>\d\+_UseExported\_s*' .. |
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
2158 'g:imported_abs = exported\_s*' .. |
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
2159 '0 LOADSCRIPT exported-2 from .*Xexport_abs.vim\_s*' .. |
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
2160 '1 STOREG g:imported_abs\_s*' .. |
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
2161 'exported = 8888\_s*' .. |
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
2162 '2 PUSHNR 8888\_s*' .. |
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
2163 '3 STORESCRIPT exported-2 in .*Xexport_abs.vim\_s*' .. |
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
2164 'g:imported_after = exported\_s*' .. |
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
2165 '4 LOADSCRIPT exported-2 from .*Xexport_abs.vim\_s*' .. |
107eae953b87
patch 8.2.1846: Vim9: block variables are not found in compiled function
Bram Moolenaar <Bram@vim.org>
parents:
22555
diff
changeset
|
2166 '5 STOREG g:imported_after', |
20011
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
2167 g:import_disassembled) |
21709
16d6b626aa8f
patch 8.2.1404: Vim9: script test fails in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
21707
diff
changeset
|
2168 |
16d6b626aa8f
patch 8.2.1404: Vim9: script test fails in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
21707
diff
changeset
|
2169 Undo_export_script_lines() |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2170 unlet g:imported_abs |
19285
86665583dc83
patch 8.2.0201: cannot assign to an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
19283
diff
changeset
|
2171 unlet g:import_disassembled |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2172 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2173 delete('Ximport_abs.vim') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2174 delete('Xexport_abs.vim') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2175 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2176 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2177 def Test_import_rtp() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2178 var import_lines = [ |
20011
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
2179 'vim9script', |
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
2180 'import exported from "Xexport_rtp.vim"', |
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
2181 'g:imported_rtp = exported', |
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
2182 ] |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2183 writefile(import_lines, 'Ximport_rtp.vim') |
25188
8998dff30044
patch 8.2.3130: Vim9: import test fails
Bram Moolenaar <Bram@vim.org>
parents:
25186
diff
changeset
|
2184 mkdir('import', 'p') |
8998dff30044
patch 8.2.3130: Vim9: import test fails
Bram Moolenaar <Bram@vim.org>
parents:
25186
diff
changeset
|
2185 writefile(s:export_script_lines, 'import/Xexport_rtp.vim') |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2186 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2187 var save_rtp = &rtp |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2188 &rtp = getcwd() |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2189 source Ximport_rtp.vim |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2190 &rtp = save_rtp |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2191 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2192 assert_equal(9876, g:imported_rtp) |
21709
16d6b626aa8f
patch 8.2.1404: Vim9: script test fails in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
21707
diff
changeset
|
2193 |
16d6b626aa8f
patch 8.2.1404: Vim9: script test fails in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
21707
diff
changeset
|
2194 Undo_export_script_lines() |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2195 unlet g:imported_rtp |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2196 delete('Ximport_rtp.vim') |
25188
8998dff30044
patch 8.2.3130: Vim9: import test fails
Bram Moolenaar <Bram@vim.org>
parents:
25186
diff
changeset
|
2197 delete('import', 'rf') |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2198 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2199 |
20538
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2200 def Test_import_compile_error() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2201 var export_lines = [ |
20538
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2202 'vim9script', |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2203 'export def ExpFunc(): string', |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2204 ' return notDefined', |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2205 'enddef', |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2206 ] |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2207 writefile(export_lines, 'Xexported.vim') |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2208 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2209 var import_lines = [ |
20538
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2210 'vim9script', |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2211 'import ExpFunc from "./Xexported.vim"', |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2212 'def ImpFunc()', |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2213 ' echo ExpFunc()', |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2214 'enddef', |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2215 'defcompile', |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2216 ] |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2217 writefile(import_lines, 'Ximport.vim') |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2218 |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2219 try |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2220 source Ximport.vim |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2221 catch /E1001/ |
26211
485c7c4afeb7
patch 8.2.3637: typos in test files
Bram Moolenaar <Bram@vim.org>
parents:
26048
diff
changeset
|
2222 # Error should be before the Xexported.vim file. |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
2223 assert_match('E1001: Variable not found: notDefined', v:exception) |
20538
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2224 assert_match('function <SNR>\d\+_ImpFunc\[1\]..<SNR>\d\+_ExpFunc, line 1', v:throwpoint) |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2225 endtry |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2226 |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2227 delete('Xexported.vim') |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2228 delete('Ximport.vim') |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2229 enddef |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
2230 |
21791
d504fcd3d2c0
patch 8.2.1445: Vim9: function expanded name is cleared when sourcing again
Bram Moolenaar <Bram@vim.org>
parents:
21775
diff
changeset
|
2231 def Test_func_redefine_error() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2232 var lines = [ |
21791
d504fcd3d2c0
patch 8.2.1445: Vim9: function expanded name is cleared when sourcing again
Bram Moolenaar <Bram@vim.org>
parents:
21775
diff
changeset
|
2233 'vim9script', |
d504fcd3d2c0
patch 8.2.1445: Vim9: function expanded name is cleared when sourcing again
Bram Moolenaar <Bram@vim.org>
parents:
21775
diff
changeset
|
2234 'def Func()', |
d504fcd3d2c0
patch 8.2.1445: Vim9: function expanded name is cleared when sourcing again
Bram Moolenaar <Bram@vim.org>
parents:
21775
diff
changeset
|
2235 ' eval [][0]', |
d504fcd3d2c0
patch 8.2.1445: Vim9: function expanded name is cleared when sourcing again
Bram Moolenaar <Bram@vim.org>
parents:
21775
diff
changeset
|
2236 'enddef', |
d504fcd3d2c0
patch 8.2.1445: Vim9: function expanded name is cleared when sourcing again
Bram Moolenaar <Bram@vim.org>
parents:
21775
diff
changeset
|
2237 'Func()', |
d504fcd3d2c0
patch 8.2.1445: Vim9: function expanded name is cleared when sourcing again
Bram Moolenaar <Bram@vim.org>
parents:
21775
diff
changeset
|
2238 ] |
d504fcd3d2c0
patch 8.2.1445: Vim9: function expanded name is cleared when sourcing again
Bram Moolenaar <Bram@vim.org>
parents:
21775
diff
changeset
|
2239 writefile(lines, 'Xtestscript.vim') |
d504fcd3d2c0
patch 8.2.1445: Vim9: function expanded name is cleared when sourcing again
Bram Moolenaar <Bram@vim.org>
parents:
21775
diff
changeset
|
2240 |
d504fcd3d2c0
patch 8.2.1445: Vim9: function expanded name is cleared when sourcing again
Bram Moolenaar <Bram@vim.org>
parents:
21775
diff
changeset
|
2241 for count in range(3) |
d504fcd3d2c0
patch 8.2.1445: Vim9: function expanded name is cleared when sourcing again
Bram Moolenaar <Bram@vim.org>
parents:
21775
diff
changeset
|
2242 try |
d504fcd3d2c0
patch 8.2.1445: Vim9: function expanded name is cleared when sourcing again
Bram Moolenaar <Bram@vim.org>
parents:
21775
diff
changeset
|
2243 source Xtestscript.vim |
d504fcd3d2c0
patch 8.2.1445: Vim9: function expanded name is cleared when sourcing again
Bram Moolenaar <Bram@vim.org>
parents:
21775
diff
changeset
|
2244 catch /E684/ |
d504fcd3d2c0
patch 8.2.1445: Vim9: function expanded name is cleared when sourcing again
Bram Moolenaar <Bram@vim.org>
parents:
21775
diff
changeset
|
2245 # function name should contain <SNR> every time |
d504fcd3d2c0
patch 8.2.1445: Vim9: function expanded name is cleared when sourcing again
Bram Moolenaar <Bram@vim.org>
parents:
21775
diff
changeset
|
2246 assert_match('E684: list index out of range', v:exception) |
d504fcd3d2c0
patch 8.2.1445: Vim9: function expanded name is cleared when sourcing again
Bram Moolenaar <Bram@vim.org>
parents:
21775
diff
changeset
|
2247 assert_match('function <SNR>\d\+_Func, line 1', v:throwpoint) |
d504fcd3d2c0
patch 8.2.1445: Vim9: function expanded name is cleared when sourcing again
Bram Moolenaar <Bram@vim.org>
parents:
21775
diff
changeset
|
2248 endtry |
d504fcd3d2c0
patch 8.2.1445: Vim9: function expanded name is cleared when sourcing again
Bram Moolenaar <Bram@vim.org>
parents:
21775
diff
changeset
|
2249 endfor |
d504fcd3d2c0
patch 8.2.1445: Vim9: function expanded name is cleared when sourcing again
Bram Moolenaar <Bram@vim.org>
parents:
21775
diff
changeset
|
2250 |
d504fcd3d2c0
patch 8.2.1445: Vim9: function expanded name is cleared when sourcing again
Bram Moolenaar <Bram@vim.org>
parents:
21775
diff
changeset
|
2251 delete('Xtestscript.vim') |
d504fcd3d2c0
patch 8.2.1445: Vim9: function expanded name is cleared when sourcing again
Bram Moolenaar <Bram@vim.org>
parents:
21775
diff
changeset
|
2252 enddef |
d504fcd3d2c0
patch 8.2.1445: Vim9: function expanded name is cleared when sourcing again
Bram Moolenaar <Bram@vim.org>
parents:
21775
diff
changeset
|
2253 |
21598
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2254 def Test_func_overrules_import_fails() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2255 var export_lines =<< trim END |
21598
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2256 vim9script |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2257 export def Func() |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2258 echo 'imported' |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2259 enddef |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2260 END |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2261 writefile(export_lines, 'XexportedFunc.vim') |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2262 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2263 var lines =<< trim END |
21598
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2264 vim9script |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2265 import Func from './XexportedFunc.vim' |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2266 def Func() |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2267 echo 'local to function' |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2268 enddef |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2269 END |
26504
7821550ba3a8
patch 8.2.3782: Vim9: no error if a function shadows a script variable
Bram Moolenaar <Bram@vim.org>
parents:
26496
diff
changeset
|
2270 CheckScriptFailure(lines, 'E1041:') |
21598
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2271 |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2272 lines =<< trim END |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2273 vim9script |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2274 import Func from './XexportedFunc.vim' |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2275 def Outer() |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2276 def Func() |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2277 echo 'local to function' |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2278 enddef |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2279 enddef |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2280 defcompile |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2281 END |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2282 CheckScriptFailure(lines, 'E1073:') |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2283 |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2284 delete('XexportedFunc.vim') |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2285 enddef |
7b5b9558500a
patch 8.2.1349: Vim9: can define a function with the name of an import
Bram Moolenaar <Bram@vim.org>
parents:
21584
diff
changeset
|
2286 |
21600
622021f43db1
patch 8.2.1350: Vim9: no test for error message when redefining function
Bram Moolenaar <Bram@vim.org>
parents:
21598
diff
changeset
|
2287 def Test_func_redefine_fails() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2288 var lines =<< trim END |
21600
622021f43db1
patch 8.2.1350: Vim9: no test for error message when redefining function
Bram Moolenaar <Bram@vim.org>
parents:
21598
diff
changeset
|
2289 vim9script |
622021f43db1
patch 8.2.1350: Vim9: no test for error message when redefining function
Bram Moolenaar <Bram@vim.org>
parents:
21598
diff
changeset
|
2290 def Func() |
622021f43db1
patch 8.2.1350: Vim9: no test for error message when redefining function
Bram Moolenaar <Bram@vim.org>
parents:
21598
diff
changeset
|
2291 echo 'one' |
622021f43db1
patch 8.2.1350: Vim9: no test for error message when redefining function
Bram Moolenaar <Bram@vim.org>
parents:
21598
diff
changeset
|
2292 enddef |
622021f43db1
patch 8.2.1350: Vim9: no test for error message when redefining function
Bram Moolenaar <Bram@vim.org>
parents:
21598
diff
changeset
|
2293 def Func() |
622021f43db1
patch 8.2.1350: Vim9: no test for error message when redefining function
Bram Moolenaar <Bram@vim.org>
parents:
21598
diff
changeset
|
2294 echo 'two' |
622021f43db1
patch 8.2.1350: Vim9: no test for error message when redefining function
Bram Moolenaar <Bram@vim.org>
parents:
21598
diff
changeset
|
2295 enddef |
622021f43db1
patch 8.2.1350: Vim9: no test for error message when redefining function
Bram Moolenaar <Bram@vim.org>
parents:
21598
diff
changeset
|
2296 END |
622021f43db1
patch 8.2.1350: Vim9: no test for error message when redefining function
Bram Moolenaar <Bram@vim.org>
parents:
21598
diff
changeset
|
2297 CheckScriptFailure(lines, 'E1073:') |
21683
bb4f55d20951
patch 8.2.1391: Vim9: no error for shadowing a script function
Bram Moolenaar <Bram@vim.org>
parents:
21681
diff
changeset
|
2298 |
bb4f55d20951
patch 8.2.1391: Vim9: no error for shadowing a script function
Bram Moolenaar <Bram@vim.org>
parents:
21681
diff
changeset
|
2299 lines =<< trim END |
bb4f55d20951
patch 8.2.1391: Vim9: no error for shadowing a script function
Bram Moolenaar <Bram@vim.org>
parents:
21681
diff
changeset
|
2300 vim9script |
bb4f55d20951
patch 8.2.1391: Vim9: no error for shadowing a script function
Bram Moolenaar <Bram@vim.org>
parents:
21681
diff
changeset
|
2301 def Foo(): string |
bb4f55d20951
patch 8.2.1391: Vim9: no error for shadowing a script function
Bram Moolenaar <Bram@vim.org>
parents:
21681
diff
changeset
|
2302 return 'foo' |
26504
7821550ba3a8
patch 8.2.3782: Vim9: no error if a function shadows a script variable
Bram Moolenaar <Bram@vim.org>
parents:
26496
diff
changeset
|
2303 enddef |
21683
bb4f55d20951
patch 8.2.1391: Vim9: no error for shadowing a script function
Bram Moolenaar <Bram@vim.org>
parents:
21681
diff
changeset
|
2304 def Func() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2305 var Foo = {-> 'lambda'} |
21683
bb4f55d20951
patch 8.2.1391: Vim9: no error for shadowing a script function
Bram Moolenaar <Bram@vim.org>
parents:
21681
diff
changeset
|
2306 enddef |
bb4f55d20951
patch 8.2.1391: Vim9: no error for shadowing a script function
Bram Moolenaar <Bram@vim.org>
parents:
21681
diff
changeset
|
2307 defcompile |
bb4f55d20951
patch 8.2.1391: Vim9: no error for shadowing a script function
Bram Moolenaar <Bram@vim.org>
parents:
21681
diff
changeset
|
2308 END |
bb4f55d20951
patch 8.2.1391: Vim9: no error for shadowing a script function
Bram Moolenaar <Bram@vim.org>
parents:
21681
diff
changeset
|
2309 CheckScriptFailure(lines, 'E1073:') |
21600
622021f43db1
patch 8.2.1350: Vim9: no test for error message when redefining function
Bram Moolenaar <Bram@vim.org>
parents:
21598
diff
changeset
|
2310 enddef |
622021f43db1
patch 8.2.1350: Vim9: no test for error message when redefining function
Bram Moolenaar <Bram@vim.org>
parents:
21598
diff
changeset
|
2311 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2312 def Test_fixed_size_list() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2313 # will be allocated as one piece of memory, check that changes work |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2314 var l = [1, 2, 3, 4] |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2315 l->remove(0) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2316 l->add(5) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2317 l->insert(99, 1) |
19281
9fcdeaa18bd1
patch 8.2.0199: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19253
diff
changeset
|
2318 assert_equal([2, 99, 3, 4, 5], l) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2319 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2320 |
21516
c7b2ce90c2de
patch 8.2.1308: Vim9: accidentally using "x" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
21485
diff
changeset
|
2321 def Test_no_insert_xit() |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2322 CheckDefExecFailure(['a = 1'], 'E1100:') |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2323 CheckDefExecFailure(['c = 1'], 'E1100:') |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2324 CheckDefExecFailure(['i = 1'], 'E1100:') |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2325 CheckDefExecFailure(['t = 1'], 'E1100:') |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2326 CheckDefExecFailure(['x = 1'], 'E1100:') |
21516
c7b2ce90c2de
patch 8.2.1308: Vim9: accidentally using "x" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
21485
diff
changeset
|
2327 |
c7b2ce90c2de
patch 8.2.1308: Vim9: accidentally using "x" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
21485
diff
changeset
|
2328 CheckScriptFailure(['vim9script', 'a = 1'], 'E488:') |
c7b2ce90c2de
patch 8.2.1308: Vim9: accidentally using "x" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
21485
diff
changeset
|
2329 CheckScriptFailure(['vim9script', 'a'], 'E1100:') |
21584
d0c76ce48326
patch 8.2.1342: Vim9: accidentally using "t" gives a confusing error
Bram Moolenaar <Bram@vim.org>
parents:
21578
diff
changeset
|
2330 CheckScriptFailure(['vim9script', 'c = 1'], 'E488:') |
d0c76ce48326
patch 8.2.1342: Vim9: accidentally using "t" gives a confusing error
Bram Moolenaar <Bram@vim.org>
parents:
21578
diff
changeset
|
2331 CheckScriptFailure(['vim9script', 'c'], 'E1100:') |
21516
c7b2ce90c2de
patch 8.2.1308: Vim9: accidentally using "x" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
21485
diff
changeset
|
2332 CheckScriptFailure(['vim9script', 'i = 1'], 'E488:') |
c7b2ce90c2de
patch 8.2.1308: Vim9: accidentally using "x" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
21485
diff
changeset
|
2333 CheckScriptFailure(['vim9script', 'i'], 'E1100:') |
24114
291c57cf4731
patch 8.2.2598: Vim9: :open does not need to be supported
Bram Moolenaar <Bram@vim.org>
parents:
24112
diff
changeset
|
2334 CheckScriptFailure(['vim9script', 'o = 1'], 'E1100:') |
291c57cf4731
patch 8.2.2598: Vim9: :open does not need to be supported
Bram Moolenaar <Bram@vim.org>
parents:
24112
diff
changeset
|
2335 CheckScriptFailure(['vim9script', 'o'], 'E1100:') |
21584
d0c76ce48326
patch 8.2.1342: Vim9: accidentally using "t" gives a confusing error
Bram Moolenaar <Bram@vim.org>
parents:
21578
diff
changeset
|
2336 CheckScriptFailure(['vim9script', 't'], 'E1100:') |
d0c76ce48326
patch 8.2.1342: Vim9: accidentally using "t" gives a confusing error
Bram Moolenaar <Bram@vim.org>
parents:
21578
diff
changeset
|
2337 CheckScriptFailure(['vim9script', 't = 1'], 'E1100:') |
d0c76ce48326
patch 8.2.1342: Vim9: accidentally using "t" gives a confusing error
Bram Moolenaar <Bram@vim.org>
parents:
21578
diff
changeset
|
2338 CheckScriptFailure(['vim9script', 'x = 1'], 'E1100:') |
21516
c7b2ce90c2de
patch 8.2.1308: Vim9: accidentally using "x" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
21485
diff
changeset
|
2339 enddef |
c7b2ce90c2de
patch 8.2.1308: Vim9: accidentally using "x" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
21485
diff
changeset
|
2340 |
19332
d6e8a9e80be4
patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19330
diff
changeset
|
2341 def IfElse(what: number): string |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2342 var res = '' |
19332
d6e8a9e80be4
patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19330
diff
changeset
|
2343 if what == 1 |
d6e8a9e80be4
patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19330
diff
changeset
|
2344 res = "one" |
d6e8a9e80be4
patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19330
diff
changeset
|
2345 elseif what == 2 |
d6e8a9e80be4
patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19330
diff
changeset
|
2346 res = "two" |
19253
a8d2d3c8f0b3
patch 8.2.0185: Vim9 script: cannot use "if has()" to skip lines
Bram Moolenaar <Bram@vim.org>
parents:
19185
diff
changeset
|
2347 else |
19332
d6e8a9e80be4
patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19330
diff
changeset
|
2348 res = "three" |
19253
a8d2d3c8f0b3
patch 8.2.0185: Vim9 script: cannot use "if has()" to skip lines
Bram Moolenaar <Bram@vim.org>
parents:
19185
diff
changeset
|
2349 endif |
19332
d6e8a9e80be4
patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19330
diff
changeset
|
2350 return res |
19253
a8d2d3c8f0b3
patch 8.2.0185: Vim9 script: cannot use "if has()" to skip lines
Bram Moolenaar <Bram@vim.org>
parents:
19185
diff
changeset
|
2351 enddef |
a8d2d3c8f0b3
patch 8.2.0185: Vim9 script: cannot use "if has()" to skip lines
Bram Moolenaar <Bram@vim.org>
parents:
19185
diff
changeset
|
2352 |
19332
d6e8a9e80be4
patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19330
diff
changeset
|
2353 def Test_if_elseif_else() |
d6e8a9e80be4
patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19330
diff
changeset
|
2354 assert_equal('one', IfElse(1)) |
d6e8a9e80be4
patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19330
diff
changeset
|
2355 assert_equal('two', IfElse(2)) |
d6e8a9e80be4
patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19330
diff
changeset
|
2356 assert_equal('three', IfElse(3)) |
19281
9fcdeaa18bd1
patch 8.2.0199: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19253
diff
changeset
|
2357 enddef |
9fcdeaa18bd1
patch 8.2.0199: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19253
diff
changeset
|
2358 |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
2359 def Test_if_elseif_else_fails() |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2360 CheckDefFailure(['elseif true'], 'E582:') |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2361 CheckDefFailure(['else'], 'E581:') |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2362 CheckDefFailure(['endif'], 'E580:') |
23723
14e92f4c98c9
patch 8.2.2403: Vim9: profiling if/elseif/endif not correct
Bram Moolenaar <Bram@vim.org>
parents:
23703
diff
changeset
|
2363 CheckDefFailure(['if g:abool', 'elseif xxx'], 'E1001:') |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2364 CheckDefFailure(['if true', 'echo 1'], 'E171:') |
23882
a4df35126d9c
patch 8.2.2483: Vim9: type error for misformed expression
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
2365 |
a4df35126d9c
patch 8.2.2483: Vim9: type error for misformed expression
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
2366 var lines =<< trim END |
a4df35126d9c
patch 8.2.2483: Vim9: type error for misformed expression
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
2367 var s = '' |
a4df35126d9c
patch 8.2.2483: Vim9: type error for misformed expression
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
2368 if s = '' |
a4df35126d9c
patch 8.2.2483: Vim9: type error for misformed expression
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
2369 endif |
a4df35126d9c
patch 8.2.2483: Vim9: type error for misformed expression
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
2370 END |
a4df35126d9c
patch 8.2.2483: Vim9: type error for misformed expression
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
2371 CheckDefFailure(lines, 'E488:') |
a4df35126d9c
patch 8.2.2483: Vim9: type error for misformed expression
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
2372 |
a4df35126d9c
patch 8.2.2483: Vim9: type error for misformed expression
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
2373 lines =<< trim END |
a4df35126d9c
patch 8.2.2483: Vim9: type error for misformed expression
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
2374 var s = '' |
a4df35126d9c
patch 8.2.2483: Vim9: type error for misformed expression
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
2375 if s == '' |
a4df35126d9c
patch 8.2.2483: Vim9: type error for misformed expression
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
2376 elseif s = '' |
a4df35126d9c
patch 8.2.2483: Vim9: type error for misformed expression
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
2377 endif |
a4df35126d9c
patch 8.2.2483: Vim9: type error for misformed expression
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
2378 END |
a4df35126d9c
patch 8.2.2483: Vim9: type error for misformed expression
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
2379 CheckDefFailure(lines, 'E488:') |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
2380 enddef |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
2381 |
19585
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2382 let g:bool_true = v:true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2383 let g:bool_false = v:false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2384 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2385 def Test_if_const_expr() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2386 var res = false |
19585
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2387 if true ? true : false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2388 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2389 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2390 assert_equal(true, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2391 |
19894
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2392 g:glob = 2 |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2393 if false |
20945
0653b9b72091
patch 8.2.1024: Vim9: no error for using "let g:var = val"
Bram Moolenaar <Bram@vim.org>
parents:
20921
diff
changeset
|
2394 execute('g:glob = 3') |
19894
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2395 endif |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2396 assert_equal(2, g:glob) |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2397 if true |
20945
0653b9b72091
patch 8.2.1024: Vim9: no error for using "let g:var = val"
Bram Moolenaar <Bram@vim.org>
parents:
20921
diff
changeset
|
2398 execute('g:glob = 3') |
19894
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2399 endif |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2400 assert_equal(3, g:glob) |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2401 |
19585
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2402 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2403 if g:bool_true ? true : false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2404 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2405 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2406 assert_equal(true, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2407 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2408 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2409 if true ? g:bool_true : false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2410 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2411 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2412 assert_equal(true, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2413 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2414 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2415 if true ? true : g:bool_false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2416 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2417 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2418 assert_equal(true, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2419 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2420 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2421 if true ? false : true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2422 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2423 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2424 assert_equal(false, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2425 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2426 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2427 if false ? false : true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2428 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2429 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2430 assert_equal(true, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2431 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2432 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2433 if false ? true : false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2434 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2435 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2436 assert_equal(false, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2437 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2438 res = false |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
2439 if has('xyz') ? true : false |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
2440 res = true |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
2441 endif |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
2442 assert_equal(false, res) |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
2443 |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
2444 res = false |
19585
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2445 if true && true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2446 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2447 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2448 assert_equal(true, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2449 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2450 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2451 if true && false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2452 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2453 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2454 assert_equal(false, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2455 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2456 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2457 if g:bool_true && false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2458 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2459 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2460 assert_equal(false, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2461 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2462 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2463 if true && g:bool_false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2464 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2465 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2466 assert_equal(false, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2467 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2468 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2469 if false && false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2470 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2471 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2472 assert_equal(false, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2473 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2474 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2475 if true || false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2476 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2477 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2478 assert_equal(true, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2479 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2480 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2481 if g:bool_true || false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2482 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2483 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2484 assert_equal(true, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2485 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2486 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2487 if true || g:bool_false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2488 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2489 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2490 assert_equal(true, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2491 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2492 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2493 if false || false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2494 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2495 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2496 assert_equal(false, res) |
21957
4343657b49fa
patch 8.2.1528: Vim9: :endif not found after "if false"
Bram Moolenaar <Bram@vim.org>
parents:
21955
diff
changeset
|
2497 |
4343657b49fa
patch 8.2.1528: Vim9: :endif not found after "if false"
Bram Moolenaar <Bram@vim.org>
parents:
21955
diff
changeset
|
2498 # with constant "false" expression may be invalid so long as the syntax is OK |
25202
e5d85e83a887
patch 8.2.3137: Vim9: no error when a line only has a variable name
Bram Moolenaar <Bram@vim.org>
parents:
25188
diff
changeset
|
2499 if false | eval 1 + 2 | endif |
21957
4343657b49fa
patch 8.2.1528: Vim9: :endif not found after "if false"
Bram Moolenaar <Bram@vim.org>
parents:
21955
diff
changeset
|
2500 if false | eval burp + 234 | endif |
4343657b49fa
patch 8.2.1528: Vim9: :endif not found after "if false"
Bram Moolenaar <Bram@vim.org>
parents:
21955
diff
changeset
|
2501 if false | echo burp 234 'asd' | endif |
4343657b49fa
patch 8.2.1528: Vim9: :endif not found after "if false"
Bram Moolenaar <Bram@vim.org>
parents:
21955
diff
changeset
|
2502 if false |
4343657b49fa
patch 8.2.1528: Vim9: :endif not found after "if false"
Bram Moolenaar <Bram@vim.org>
parents:
21955
diff
changeset
|
2503 burp |
4343657b49fa
patch 8.2.1528: Vim9: :endif not found after "if false"
Bram Moolenaar <Bram@vim.org>
parents:
21955
diff
changeset
|
2504 endif |
25551
5ab75ca75d21
patch 8.2.3312: Vim9: after "if false" line breaks in expression not skipped
Bram Moolenaar <Bram@vim.org>
parents:
25541
diff
changeset
|
2505 |
5ab75ca75d21
patch 8.2.3312: Vim9: after "if false" line breaks in expression not skipped
Bram Moolenaar <Bram@vim.org>
parents:
25541
diff
changeset
|
2506 # expression with line breaks skipped |
5ab75ca75d21
patch 8.2.3312: Vim9: after "if false" line breaks in expression not skipped
Bram Moolenaar <Bram@vim.org>
parents:
25541
diff
changeset
|
2507 if false |
5ab75ca75d21
patch 8.2.3312: Vim9: after "if false" line breaks in expression not skipped
Bram Moolenaar <Bram@vim.org>
parents:
25541
diff
changeset
|
2508 ('aaa' |
5ab75ca75d21
patch 8.2.3312: Vim9: after "if false" line breaks in expression not skipped
Bram Moolenaar <Bram@vim.org>
parents:
25541
diff
changeset
|
2509 .. 'bbb' |
5ab75ca75d21
patch 8.2.3312: Vim9: after "if false" line breaks in expression not skipped
Bram Moolenaar <Bram@vim.org>
parents:
25541
diff
changeset
|
2510 .. 'ccc' |
5ab75ca75d21
patch 8.2.3312: Vim9: after "if false" line breaks in expression not skipped
Bram Moolenaar <Bram@vim.org>
parents:
25541
diff
changeset
|
2511 )->setline(1) |
5ab75ca75d21
patch 8.2.3312: Vim9: after "if false" line breaks in expression not skipped
Bram Moolenaar <Bram@vim.org>
parents:
25541
diff
changeset
|
2512 endif |
19878
dd3c80122a0e
patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19874
diff
changeset
|
2513 enddef |
19585
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2514 |
19878
dd3c80122a0e
patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19874
diff
changeset
|
2515 def Test_if_const_expr_fails() |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2516 CheckDefFailure(['if "aaa" == "bbb'], 'E114:') |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2517 CheckDefFailure(["if 'aaa' == 'bbb"], 'E115:') |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2518 CheckDefFailure(["if has('aaa'"], 'E110:') |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2519 CheckDefFailure(["if has('aaa') ? true false"], 'E109:') |
19585
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2520 enddef |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2521 |
20899
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
2522 def RunNested(i: number): number |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2523 var x: number = 0 |
20899
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
2524 if i % 2 |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
2525 if 1 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2526 # comment |
20899
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
2527 else |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2528 # comment |
20899
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
2529 endif |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
2530 x += 1 |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
2531 else |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
2532 x += 1000 |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
2533 endif |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
2534 return x |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
2535 enddef |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
2536 |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
2537 def Test_nested_if() |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
2538 assert_equal(1, RunNested(1)) |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
2539 assert_equal(1000, RunNested(2)) |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
2540 enddef |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
2541 |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
2542 def Test_execute_cmd() |
23183
4d5d12138b36
patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents:
23179
diff
changeset
|
2543 # missing argument is ignored |
4d5d12138b36
patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents:
23179
diff
changeset
|
2544 execute |
4d5d12138b36
patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents:
23179
diff
changeset
|
2545 execute # comment |
4d5d12138b36
patch 8.2.2137: Vim9: :echo and :execute give error for empty argument
Bram Moolenaar <Bram@vim.org>
parents:
23179
diff
changeset
|
2546 |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
2547 new |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
2548 setline(1, 'default') |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2549 execute 'setline(1, "execute-string")' |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
2550 assert_equal('execute-string', getline(1)) |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2551 |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2552 execute "setline(1, 'execute-string')" |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2553 assert_equal('execute-string', getline(1)) |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2554 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2555 var cmd1 = 'setline(1,' |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2556 var cmd2 = '"execute-var")' |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2557 execute cmd1 cmd2 # comment |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
2558 assert_equal('execute-var', getline(1)) |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2559 |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2560 execute cmd1 cmd2 '|setline(1, "execute-var-string")' |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
2561 assert_equal('execute-var-string', getline(1)) |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2562 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2563 var cmd_first = 'call ' |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2564 var cmd_last = 'setline(1, "execute-var-var")' |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
2565 execute cmd_first .. cmd_last |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
2566 assert_equal('execute-var-var', getline(1)) |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
2567 bwipe! |
19894
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2568 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2569 var n = true |
21485
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2570 execute 'echomsg' (n ? '"true"' : '"no"') |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2571 assert_match('^true$', Screenline(&lines)) |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2572 |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23068
diff
changeset
|
2573 echomsg [1, 2, 3] {a: 1, b: 2} |
21835
b530ead4265a
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
2574 assert_match('^\[1, 2, 3\] {''a'': 1, ''b'': 2}$', Screenline(&lines)) |
b530ead4265a
patch 8.2.1467: Vim9: :echomsg doesn't like a dict argument
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
2575 |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2576 CheckDefFailure(['execute xxx'], 'E1001:', 1) |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2577 CheckDefExecFailure(['execute "tabnext " .. 8'], 'E475:', 1) |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2578 CheckDefFailure(['execute "cmd"# comment'], 'E488:', 1) |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
2579 enddef |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
2580 |
21098
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2581 def Test_execute_cmd_vimscript() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2582 # only checks line continuation |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2583 var lines =<< trim END |
21098
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2584 vim9script |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2585 execute 'g:someVar' |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2586 .. ' = ' .. |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2587 '28' |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2588 assert_equal(28, g:someVar) |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2589 unlet g:someVar |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2590 END |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2591 CheckScriptSuccess(lines) |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2592 enddef |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2593 |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
2594 def Test_echo_cmd() |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2595 echo 'some' # comment |
19894
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2596 echon 'thing' |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
2597 assert_match('^something$', Screenline(&lines)) |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
2598 |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2599 echo "some" # comment |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2600 echon "thing" |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2601 assert_match('^something$', Screenline(&lines)) |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2602 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2603 var str1 = 'some' |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2604 var str2 = 'more' |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
2605 echo str1 str2 |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
2606 assert_match('^some more$', Screenline(&lines)) |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2607 |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2608 CheckDefFailure(['echo "xxx"# comment'], 'E488:') |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
2609 enddef |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
2610 |
20142
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20138
diff
changeset
|
2611 def Test_echomsg_cmd() |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20138
diff
changeset
|
2612 echomsg 'some' 'more' # comment |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20138
diff
changeset
|
2613 assert_match('^some more$', Screenline(&lines)) |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20138
diff
changeset
|
2614 echo 'clear' |
20982
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
2615 :1messages |
20142
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20138
diff
changeset
|
2616 assert_match('^some more$', Screenline(&lines)) |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20138
diff
changeset
|
2617 |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2618 CheckDefFailure(['echomsg "xxx"# comment'], 'E488:') |
20142
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20138
diff
changeset
|
2619 enddef |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20138
diff
changeset
|
2620 |
21098
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2621 def Test_echomsg_cmd_vimscript() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2622 # only checks line continuation |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2623 var lines =<< trim END |
21098
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2624 vim9script |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2625 echomsg 'here' |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2626 .. ' is ' .. |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2627 'a message' |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2628 assert_match('^here is a message$', Screenline(&lines)) |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2629 END |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2630 CheckScriptSuccess(lines) |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2631 enddef |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2632 |
20142
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20138
diff
changeset
|
2633 def Test_echoerr_cmd() |
25541
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25537
diff
changeset
|
2634 var local = 'local' |
20289
208b38bddc36
patch 8.2.0700: Vim9: converting error message to exception not tested
Bram Moolenaar <Bram@vim.org>
parents:
20203
diff
changeset
|
2635 try |
25541
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25537
diff
changeset
|
2636 echoerr 'something' local 'wrong' # comment |
20289
208b38bddc36
patch 8.2.0700: Vim9: converting error message to exception not tested
Bram Moolenaar <Bram@vim.org>
parents:
20203
diff
changeset
|
2637 catch |
25541
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25537
diff
changeset
|
2638 assert_match('something local wrong', v:exception) |
20289
208b38bddc36
patch 8.2.0700: Vim9: converting error message to exception not tested
Bram Moolenaar <Bram@vim.org>
parents:
20203
diff
changeset
|
2639 endtry |
20142
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20138
diff
changeset
|
2640 enddef |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20138
diff
changeset
|
2641 |
21098
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2642 def Test_echoerr_cmd_vimscript() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2643 # only checks line continuation |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2644 var lines =<< trim END |
21098
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2645 vim9script |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2646 try |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2647 echoerr 'this' |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2648 .. ' is ' .. |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2649 'wrong' |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2650 catch |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2651 assert_match('this is wrong', v:exception) |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2652 endtry |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2653 END |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2654 CheckScriptSuccess(lines) |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2655 enddef |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
2656 |
25541
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25537
diff
changeset
|
2657 def Test_echoconsole_cmd() |
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25537
diff
changeset
|
2658 var local = 'local' |
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25537
diff
changeset
|
2659 echoconsole 'something' local # comment |
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25537
diff
changeset
|
2660 # output goes anywhere |
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25537
diff
changeset
|
2661 enddef |
2ae1d5a4ae5c
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Bram Moolenaar <Bram@vim.org>
parents:
25537
diff
changeset
|
2662 |
19568
c0749ad6c699
patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents:
19566
diff
changeset
|
2663 def Test_for_outside_of_function() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
2664 var lines =<< trim END |
19568
c0749ad6c699
patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents:
19566
diff
changeset
|
2665 vim9script |
c0749ad6c699
patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents:
19566
diff
changeset
|
2666 new |
c0749ad6c699
patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents:
19566
diff
changeset
|
2667 for var in range(0, 3) |
c0749ad6c699
patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents:
19566
diff
changeset
|
2668 append(line('$'), var) |
c0749ad6c699
patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents:
19566
diff
changeset
|
2669 endfor |
c0749ad6c699
patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents:
19566
diff
changeset
|
2670 assert_equal(['', '0', '1', '2', '3'], getline(1, '$')) |
c0749ad6c699
patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents:
19566
diff
changeset
|
2671 bwipe! |
24232
3058ed6db36f
patch 8.2.2657: Vim9: error message for declaring variable in for loop
Bram Moolenaar <Bram@vim.org>
parents:
24158
diff
changeset
|
2672 |
3058ed6db36f
patch 8.2.2657: Vim9: error message for declaring variable in for loop
Bram Moolenaar <Bram@vim.org>
parents:
24158
diff
changeset
|
2673 var result = '' |
3058ed6db36f
patch 8.2.2657: Vim9: error message for declaring variable in for loop
Bram Moolenaar <Bram@vim.org>
parents:
24158
diff
changeset
|
2674 for i in [1, 2, 3] |
3058ed6db36f
patch 8.2.2657: Vim9: error message for declaring variable in for loop
Bram Moolenaar <Bram@vim.org>
parents:
24158
diff
changeset
|
2675 var loop = ' loop ' .. i |
3058ed6db36f
patch 8.2.2657: Vim9: error message for declaring variable in for loop
Bram Moolenaar <Bram@vim.org>
parents:
24158
diff
changeset
|
2676 result ..= loop |
3058ed6db36f
patch 8.2.2657: Vim9: error message for declaring variable in for loop
Bram Moolenaar <Bram@vim.org>
parents:
24158
diff
changeset
|
2677 endfor |
3058ed6db36f
patch 8.2.2657: Vim9: error message for declaring variable in for loop
Bram Moolenaar <Bram@vim.org>
parents:
24158
diff
changeset
|
2678 assert_equal(' loop 1 loop 2 loop 3', result) |
19568
c0749ad6c699
patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents:
19566
diff
changeset
|
2679 END |
c0749ad6c699
patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents:
19566
diff
changeset
|
2680 writefile(lines, 'Xvim9for.vim') |
c0749ad6c699
patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents:
19566
diff
changeset
|
2681 source Xvim9for.vim |
c0749ad6c699
patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents:
19566
diff
changeset
|
2682 delete('Xvim9for.vim') |
c0749ad6c699
patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents:
19566
diff
changeset
|
2683 enddef |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2684 |
25656
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2685 def Test_for_skipped_block() |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2686 # test skipped blocks at outside of function |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2687 var lines =<< trim END |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2688 var result = [] |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2689 if true |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2690 for n in [1, 2] |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2691 result += [n] |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2692 endfor |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2693 else |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2694 for n in [3, 4] |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2695 result += [n] |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2696 endfor |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2697 endif |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2698 assert_equal([1, 2], result) |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2699 |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2700 result = [] |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2701 if false |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2702 for n in [1, 2] |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2703 result += [n] |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2704 endfor |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2705 else |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2706 for n in [3, 4] |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2707 result += [n] |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2708 endfor |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2709 endif |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2710 assert_equal([3, 4], result) |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2711 END |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2712 CheckDefAndScriptSuccess(lines) |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2713 |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2714 # test skipped blocks at inside of function |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2715 lines =<< trim END |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2716 def DefTrue() |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2717 var result = [] |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2718 if true |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2719 for n in [1, 2] |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2720 result += [n] |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2721 endfor |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2722 else |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2723 for n in [3, 4] |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2724 result += [n] |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2725 endfor |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2726 endif |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2727 assert_equal([1, 2], result) |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2728 enddef |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2729 DefTrue() |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2730 |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2731 def DefFalse() |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2732 var result = [] |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2733 if false |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2734 for n in [1, 2] |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2735 result += [n] |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2736 endfor |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2737 else |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2738 for n in [3, 4] |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2739 result += [n] |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2740 endfor |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2741 endif |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2742 assert_equal([3, 4], result) |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2743 enddef |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2744 DefFalse() |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2745 END |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2746 CheckDefAndScriptSuccess(lines) |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2747 enddef |
fe7f45e2895e
patch 8.2.3364: Vim9: crash when :for is skipped
Bram Moolenaar <Bram@vim.org>
parents:
25654
diff
changeset
|
2748 |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
2749 def Test_for_loop() |
24438
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2750 var lines =<< trim END |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2751 var result = '' |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2752 for cnt in range(7) |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2753 if cnt == 4 |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2754 break |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2755 endif |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2756 if cnt == 2 |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2757 continue |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2758 endif |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2759 result ..= cnt .. '_' |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2760 endfor |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2761 assert_equal('0_1_3_', result) |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2762 |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2763 var concat = '' |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2764 for str in eval('["one", "two"]') |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2765 concat ..= str |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2766 endfor |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2767 assert_equal('onetwo', concat) |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2768 |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2769 var total = 0 |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2770 for nr in |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2771 [1, 2, 3] |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2772 total += nr |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2773 endfor |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2774 assert_equal(6, total) |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2775 |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2776 total = 0 |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2777 for nr |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2778 in [1, 2, 3] |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2779 total += nr |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2780 endfor |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2781 assert_equal(6, total) |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2782 |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2783 total = 0 |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2784 for nr |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2785 in |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2786 [1, 2, 3] |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2787 total += nr |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2788 endfor |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2789 assert_equal(6, total) |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2790 |
24446
f388a033e568
patch 8.2.2763: Vim9: cannot use type in for loop unpack at script level
Bram Moolenaar <Bram@vim.org>
parents:
24440
diff
changeset
|
2791 # with type |
f388a033e568
patch 8.2.2763: Vim9: cannot use type in for loop unpack at script level
Bram Moolenaar <Bram@vim.org>
parents:
24440
diff
changeset
|
2792 total = 0 |
f388a033e568
patch 8.2.2763: Vim9: cannot use type in for loop unpack at script level
Bram Moolenaar <Bram@vim.org>
parents:
24440
diff
changeset
|
2793 for n: number in [1, 2, 3] |
f388a033e568
patch 8.2.2763: Vim9: cannot use type in for loop unpack at script level
Bram Moolenaar <Bram@vim.org>
parents:
24440
diff
changeset
|
2794 total += n |
f388a033e568
patch 8.2.2763: Vim9: cannot use type in for loop unpack at script level
Bram Moolenaar <Bram@vim.org>
parents:
24440
diff
changeset
|
2795 endfor |
f388a033e568
patch 8.2.2763: Vim9: cannot use type in for loop unpack at script level
Bram Moolenaar <Bram@vim.org>
parents:
24440
diff
changeset
|
2796 assert_equal(6, total) |
f388a033e568
patch 8.2.2763: Vim9: cannot use type in for loop unpack at script level
Bram Moolenaar <Bram@vim.org>
parents:
24440
diff
changeset
|
2797 |
24460
f0a3adf16f01
patch 8.2.2770: Vim9: type of loop variable is not used
Bram Moolenaar <Bram@vim.org>
parents:
24446
diff
changeset
|
2798 var chars = '' |
f0a3adf16f01
patch 8.2.2770: Vim9: type of loop variable is not used
Bram Moolenaar <Bram@vim.org>
parents:
24446
diff
changeset
|
2799 for s: string in 'foobar' |
f0a3adf16f01
patch 8.2.2770: Vim9: type of loop variable is not used
Bram Moolenaar <Bram@vim.org>
parents:
24446
diff
changeset
|
2800 chars ..= s |
f0a3adf16f01
patch 8.2.2770: Vim9: type of loop variable is not used
Bram Moolenaar <Bram@vim.org>
parents:
24446
diff
changeset
|
2801 endfor |
f0a3adf16f01
patch 8.2.2770: Vim9: type of loop variable is not used
Bram Moolenaar <Bram@vim.org>
parents:
24446
diff
changeset
|
2802 assert_equal('foobar', chars) |
f0a3adf16f01
patch 8.2.2770: Vim9: type of loop variable is not used
Bram Moolenaar <Bram@vim.org>
parents:
24446
diff
changeset
|
2803 |
25164
0e08e34fa0b8
patch 8.2.3118: Vim9: "any" type not handled correctly in for loop
Bram Moolenaar <Bram@vim.org>
parents:
25162
diff
changeset
|
2804 chars = '' |
0e08e34fa0b8
patch 8.2.3118: Vim9: "any" type not handled correctly in for loop
Bram Moolenaar <Bram@vim.org>
parents:
25162
diff
changeset
|
2805 for x: string in {a: 'a', b: 'b'}->values() |
0e08e34fa0b8
patch 8.2.3118: Vim9: "any" type not handled correctly in for loop
Bram Moolenaar <Bram@vim.org>
parents:
25162
diff
changeset
|
2806 chars ..= x |
0e08e34fa0b8
patch 8.2.3118: Vim9: "any" type not handled correctly in for loop
Bram Moolenaar <Bram@vim.org>
parents:
25162
diff
changeset
|
2807 endfor |
0e08e34fa0b8
patch 8.2.3118: Vim9: "any" type not handled correctly in for loop
Bram Moolenaar <Bram@vim.org>
parents:
25162
diff
changeset
|
2808 assert_equal('ab', chars) |
0e08e34fa0b8
patch 8.2.3118: Vim9: "any" type not handled correctly in for loop
Bram Moolenaar <Bram@vim.org>
parents:
25162
diff
changeset
|
2809 |
24446
f388a033e568
patch 8.2.2763: Vim9: cannot use type in for loop unpack at script level
Bram Moolenaar <Bram@vim.org>
parents:
24440
diff
changeset
|
2810 # unpack with type |
f388a033e568
patch 8.2.2763: Vim9: cannot use type in for loop unpack at script level
Bram Moolenaar <Bram@vim.org>
parents:
24440
diff
changeset
|
2811 var res = '' |
f388a033e568
patch 8.2.2763: Vim9: cannot use type in for loop unpack at script level
Bram Moolenaar <Bram@vim.org>
parents:
24440
diff
changeset
|
2812 for [n: number, s: string] in [[1, 'a'], [2, 'b']] |
f388a033e568
patch 8.2.2763: Vim9: cannot use type in for loop unpack at script level
Bram Moolenaar <Bram@vim.org>
parents:
24440
diff
changeset
|
2813 res ..= n .. s |
f388a033e568
patch 8.2.2763: Vim9: cannot use type in for loop unpack at script level
Bram Moolenaar <Bram@vim.org>
parents:
24440
diff
changeset
|
2814 endfor |
f388a033e568
patch 8.2.2763: Vim9: cannot use type in for loop unpack at script level
Bram Moolenaar <Bram@vim.org>
parents:
24440
diff
changeset
|
2815 assert_equal('1a2b', res) |
f388a033e568
patch 8.2.2763: Vim9: cannot use type in for loop unpack at script level
Bram Moolenaar <Bram@vim.org>
parents:
24440
diff
changeset
|
2816 |
25028
faa3de7aed8b
patch 8.2.3051: Vim9: for loop with one list variable does not work
Bram Moolenaar <Bram@vim.org>
parents:
24968
diff
changeset
|
2817 # unpack with one var |
faa3de7aed8b
patch 8.2.3051: Vim9: for loop with one list variable does not work
Bram Moolenaar <Bram@vim.org>
parents:
24968
diff
changeset
|
2818 var reslist = [] |
faa3de7aed8b
patch 8.2.3051: Vim9: for loop with one list variable does not work
Bram Moolenaar <Bram@vim.org>
parents:
24968
diff
changeset
|
2819 for [x] in [['aaa'], ['bbb']] |
faa3de7aed8b
patch 8.2.3051: Vim9: for loop with one list variable does not work
Bram Moolenaar <Bram@vim.org>
parents:
24968
diff
changeset
|
2820 reslist->add(x) |
faa3de7aed8b
patch 8.2.3051: Vim9: for loop with one list variable does not work
Bram Moolenaar <Bram@vim.org>
parents:
24968
diff
changeset
|
2821 endfor |
faa3de7aed8b
patch 8.2.3051: Vim9: for loop with one list variable does not work
Bram Moolenaar <Bram@vim.org>
parents:
24968
diff
changeset
|
2822 assert_equal(['aaa', 'bbb'], reslist) |
faa3de7aed8b
patch 8.2.3051: Vim9: for loop with one list variable does not work
Bram Moolenaar <Bram@vim.org>
parents:
24968
diff
changeset
|
2823 |
24438
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2824 # loop over string |
24446
f388a033e568
patch 8.2.2763: Vim9: cannot use type in for loop unpack at script level
Bram Moolenaar <Bram@vim.org>
parents:
24440
diff
changeset
|
2825 res = '' |
24438
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2826 for c in 'aéc̀d' |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2827 res ..= c .. '-' |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2828 endfor |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2829 assert_equal('a-é-c̀-d-', res) |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2830 |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2831 res = '' |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2832 for c in '' |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2833 res ..= c .. '-' |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2834 endfor |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2835 assert_equal('', res) |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2836 |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2837 res = '' |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2838 for c in test_null_string() |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2839 res ..= c .. '-' |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2840 endfor |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2841 assert_equal('', res) |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2842 |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2843 var foo: list<dict<any>> = [ |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2844 {a: 'Cat'} |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2845 ] |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2846 for dd in foo |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2847 dd.counter = 12 |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2848 endfor |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2849 assert_equal([{a: 'Cat', counter: 12}], foo) |
25280
ca7a8ea2eb5f
patch 8.2.3177: Vim9: can not use "for _ in expr" at script level
Bram Moolenaar <Bram@vim.org>
parents:
25260
diff
changeset
|
2850 |
ca7a8ea2eb5f
patch 8.2.3177: Vim9: can not use "for _ in expr" at script level
Bram Moolenaar <Bram@vim.org>
parents:
25260
diff
changeset
|
2851 reslist = [] |
ca7a8ea2eb5f
patch 8.2.3177: Vim9: can not use "for _ in expr" at script level
Bram Moolenaar <Bram@vim.org>
parents:
25260
diff
changeset
|
2852 for _ in range(3) |
ca7a8ea2eb5f
patch 8.2.3177: Vim9: can not use "for _ in expr" at script level
Bram Moolenaar <Bram@vim.org>
parents:
25260
diff
changeset
|
2853 reslist->add('x') |
ca7a8ea2eb5f
patch 8.2.3177: Vim9: can not use "for _ in expr" at script level
Bram Moolenaar <Bram@vim.org>
parents:
25260
diff
changeset
|
2854 endfor |
ca7a8ea2eb5f
patch 8.2.3177: Vim9: can not use "for _ in expr" at script level
Bram Moolenaar <Bram@vim.org>
parents:
25260
diff
changeset
|
2855 assert_equal(['x', 'x', 'x'], reslist) |
24438
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2856 END |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
2857 CheckDefAndScriptSuccess(lines) |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
2858 enddef |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
2859 |
25358
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2860 def Test_for_loop_with_closure() |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2861 var lines =<< trim END |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2862 var flist: list<func> |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2863 for i in range(5) |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2864 var inloop = i |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2865 flist[i] = () => inloop |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2866 endfor |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2867 for i in range(5) |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2868 assert_equal(4, flist[i]()) |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2869 endfor |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2870 END |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2871 CheckDefAndScriptSuccess(lines) |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2872 |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2873 lines =<< trim END |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2874 var flist: list<func> |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2875 for i in range(5) |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2876 var inloop = i |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2877 flist[i] = () => { |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2878 return inloop |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2879 } |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2880 endfor |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2881 for i in range(5) |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2882 assert_equal(4, flist[i]()) |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2883 endfor |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2884 END |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2885 CheckDefAndScriptSuccess(lines) |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2886 enddef |
f03271631eb5
patch 8.2.3216: Vim9: crash when using variable in a loop at script level
Bram Moolenaar <Bram@vim.org>
parents:
25304
diff
changeset
|
2887 |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
2888 def Test_for_loop_fails() |
26650
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
26556
diff
changeset
|
2889 CheckDefAndScriptFailure(['for '], ['E1097:', 'E690:']) |
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
26556
diff
changeset
|
2890 CheckDefAndScriptFailure(['for x'], ['E1097:', 'E690:']) |
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
26556
diff
changeset
|
2891 CheckDefAndScriptFailure(['for x in'], ['E1097:', 'E15:']) |
25153
610e15e8778d
patch 8.2.3113: no error when for loop variable shadows script variable
Bram Moolenaar <Bram@vim.org>
parents:
25149
diff
changeset
|
2892 CheckDefAndScriptFailure(['for # in range(5)'], 'E690:') |
610e15e8778d
patch 8.2.3113: no error when for loop variable shadows script variable
Bram Moolenaar <Bram@vim.org>
parents:
25149
diff
changeset
|
2893 CheckDefAndScriptFailure(['for i In range(5)'], 'E690:') |
26650
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
26556
diff
changeset
|
2894 CheckDefAndScriptFailure(['var x = 5', 'for x in range(5)', 'endfor'], ['E1017:', 'E1041:']) |
25180
6523cd41fa54
patch 8.2.3126: Vim9: for loop error reports wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
25176
diff
changeset
|
2895 CheckScriptFailure(['vim9script', 'var x = 5', 'for x in range(5)', '# comment', 'endfor'], 'E1041:', 3) |
20528
489cb75c76b6
patch 8.2.0818: Vim9: using a discovery phase doesn't work well
Bram Moolenaar <Bram@vim.org>
parents:
20504
diff
changeset
|
2896 CheckScriptFailure(['def Func(arg: any)', 'for arg in range(5)', 'enddef', 'defcompile'], 'E1006:') |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
23084
diff
changeset
|
2897 delfunc! g:Func |
20019
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
2898 CheckDefFailure(['for i in xxx'], 'E1001:') |
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
2899 CheckDefFailure(['endfor'], 'E588:') |
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
2900 CheckDefFailure(['for i in range(3)', 'echo 3'], 'E170:') |
24234
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24232
diff
changeset
|
2901 |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24232
diff
changeset
|
2902 # wrong type detected at compile time |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24232
diff
changeset
|
2903 CheckDefFailure(['for i in {a: 1}', 'echo 3', 'endfor'], 'E1177: For loop on dict not supported') |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24232
diff
changeset
|
2904 |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24232
diff
changeset
|
2905 # wrong type detected at runtime |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24232
diff
changeset
|
2906 g:adict = {a: 1} |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24232
diff
changeset
|
2907 CheckDefExecFailure(['for i in g:adict', 'echo 3', 'endfor'], 'E1177: For loop on dict not supported') |
7ffc795288dd
patch 8.2.2658: :for cannot loop over a string
Bram Moolenaar <Bram@vim.org>
parents:
24232
diff
changeset
|
2908 unlet g:adict |
24440
d2f9bdd938fa
patch 8.2.2760: Vim9: no error for changing a for loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24438
diff
changeset
|
2909 |
d2f9bdd938fa
patch 8.2.2760: Vim9: no error for changing a for loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24438
diff
changeset
|
2910 var lines =<< trim END |
d2f9bdd938fa
patch 8.2.2760: Vim9: no error for changing a for loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24438
diff
changeset
|
2911 var d: list<dict<any>> = [{a: 0}] |
d2f9bdd938fa
patch 8.2.2760: Vim9: no error for changing a for loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24438
diff
changeset
|
2912 for e in d |
d2f9bdd938fa
patch 8.2.2760: Vim9: no error for changing a for loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24438
diff
changeset
|
2913 e = {a: 0, b: ''} |
d2f9bdd938fa
patch 8.2.2760: Vim9: no error for changing a for loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24438
diff
changeset
|
2914 endfor |
d2f9bdd938fa
patch 8.2.2760: Vim9: no error for changing a for loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24438
diff
changeset
|
2915 END |
26650
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
26556
diff
changeset
|
2916 CheckDefAndScriptFailure(lines, ['E1018:', 'E46:'], 3) |
24460
f0a3adf16f01
patch 8.2.2770: Vim9: type of loop variable is not used
Bram Moolenaar <Bram@vim.org>
parents:
24446
diff
changeset
|
2917 |
f0a3adf16f01
patch 8.2.2770: Vim9: type of loop variable is not used
Bram Moolenaar <Bram@vim.org>
parents:
24446
diff
changeset
|
2918 lines =<< trim END |
f0a3adf16f01
patch 8.2.2770: Vim9: type of loop variable is not used
Bram Moolenaar <Bram@vim.org>
parents:
24446
diff
changeset
|
2919 for nr: number in ['foo'] |
f0a3adf16f01
patch 8.2.2770: Vim9: type of loop variable is not used
Bram Moolenaar <Bram@vim.org>
parents:
24446
diff
changeset
|
2920 endfor |
f0a3adf16f01
patch 8.2.2770: Vim9: type of loop variable is not used
Bram Moolenaar <Bram@vim.org>
parents:
24446
diff
changeset
|
2921 END |
f0a3adf16f01
patch 8.2.2770: Vim9: type of loop variable is not used
Bram Moolenaar <Bram@vim.org>
parents:
24446
diff
changeset
|
2922 CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected number but got string', 1) |
25149
18b31f0a4bb5
patch 8.2.3111: Vim9: confusing error with extra whitespace before colon
Bram Moolenaar <Bram@vim.org>
parents:
25124
diff
changeset
|
2923 |
18b31f0a4bb5
patch 8.2.3111: Vim9: confusing error with extra whitespace before colon
Bram Moolenaar <Bram@vim.org>
parents:
25124
diff
changeset
|
2924 lines =<< trim END |
18b31f0a4bb5
patch 8.2.3111: Vim9: confusing error with extra whitespace before colon
Bram Moolenaar <Bram@vim.org>
parents:
25124
diff
changeset
|
2925 for n : number in [1, 2] |
18b31f0a4bb5
patch 8.2.3111: Vim9: confusing error with extra whitespace before colon
Bram Moolenaar <Bram@vim.org>
parents:
25124
diff
changeset
|
2926 echo n |
18b31f0a4bb5
patch 8.2.3111: Vim9: confusing error with extra whitespace before colon
Bram Moolenaar <Bram@vim.org>
parents:
25124
diff
changeset
|
2927 endfor |
18b31f0a4bb5
patch 8.2.3111: Vim9: confusing error with extra whitespace before colon
Bram Moolenaar <Bram@vim.org>
parents:
25124
diff
changeset
|
2928 END |
18b31f0a4bb5
patch 8.2.3111: Vim9: confusing error with extra whitespace before colon
Bram Moolenaar <Bram@vim.org>
parents:
25124
diff
changeset
|
2929 CheckDefAndScriptFailure(lines, 'E1059:', 1) |
25162
c44d6ac81c42
patch 8.2.3117: Vim9: type not properly checked in for loop
Bram Moolenaar <Bram@vim.org>
parents:
25153
diff
changeset
|
2930 |
c44d6ac81c42
patch 8.2.3117: Vim9: type not properly checked in for loop
Bram Moolenaar <Bram@vim.org>
parents:
25153
diff
changeset
|
2931 lines =<< trim END |
c44d6ac81c42
patch 8.2.3117: Vim9: type not properly checked in for loop
Bram Moolenaar <Bram@vim.org>
parents:
25153
diff
changeset
|
2932 var d: dict<number> = {a: 1, b: 2} |
c44d6ac81c42
patch 8.2.3117: Vim9: type not properly checked in for loop
Bram Moolenaar <Bram@vim.org>
parents:
25153
diff
changeset
|
2933 for [k: job, v: job] in d->items() |
c44d6ac81c42
patch 8.2.3117: Vim9: type not properly checked in for loop
Bram Moolenaar <Bram@vim.org>
parents:
25153
diff
changeset
|
2934 echo k v |
c44d6ac81c42
patch 8.2.3117: Vim9: type not properly checked in for loop
Bram Moolenaar <Bram@vim.org>
parents:
25153
diff
changeset
|
2935 endfor |
c44d6ac81c42
patch 8.2.3117: Vim9: type not properly checked in for loop
Bram Moolenaar <Bram@vim.org>
parents:
25153
diff
changeset
|
2936 END |
c44d6ac81c42
patch 8.2.3117: Vim9: type not properly checked in for loop
Bram Moolenaar <Bram@vim.org>
parents:
25153
diff
changeset
|
2937 CheckDefExecAndScriptFailure(lines, 'E1012: Type mismatch; expected job but got string', 2) |
26238
14b4c778b61e
patch 8.2.3650: Vim9: for loop variable can be a list member
Bram Moolenaar <Bram@vim.org>
parents:
26236
diff
changeset
|
2938 |
14b4c778b61e
patch 8.2.3650: Vim9: for loop variable can be a list member
Bram Moolenaar <Bram@vim.org>
parents:
26236
diff
changeset
|
2939 lines =<< trim END |
14b4c778b61e
patch 8.2.3650: Vim9: for loop variable can be a list member
Bram Moolenaar <Bram@vim.org>
parents:
26236
diff
changeset
|
2940 var i = 0 |
14b4c778b61e
patch 8.2.3650: Vim9: for loop variable can be a list member
Bram Moolenaar <Bram@vim.org>
parents:
26236
diff
changeset
|
2941 for i in [1, 2, 3] |
14b4c778b61e
patch 8.2.3650: Vim9: for loop variable can be a list member
Bram Moolenaar <Bram@vim.org>
parents:
26236
diff
changeset
|
2942 echo i |
14b4c778b61e
patch 8.2.3650: Vim9: for loop variable can be a list member
Bram Moolenaar <Bram@vim.org>
parents:
26236
diff
changeset
|
2943 endfor |
14b4c778b61e
patch 8.2.3650: Vim9: for loop variable can be a list member
Bram Moolenaar <Bram@vim.org>
parents:
26236
diff
changeset
|
2944 END |
26650
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
26556
diff
changeset
|
2945 CheckDefExecAndScriptFailure(lines, ['E1017:', 'E1041:']) |
26238
14b4c778b61e
patch 8.2.3650: Vim9: for loop variable can be a list member
Bram Moolenaar <Bram@vim.org>
parents:
26236
diff
changeset
|
2946 |
14b4c778b61e
patch 8.2.3650: Vim9: for loop variable can be a list member
Bram Moolenaar <Bram@vim.org>
parents:
26236
diff
changeset
|
2947 lines =<< trim END |
14b4c778b61e
patch 8.2.3650: Vim9: for loop variable can be a list member
Bram Moolenaar <Bram@vim.org>
parents:
26236
diff
changeset
|
2948 var l = [0] |
14b4c778b61e
patch 8.2.3650: Vim9: for loop variable can be a list member
Bram Moolenaar <Bram@vim.org>
parents:
26236
diff
changeset
|
2949 for l[0] in [1, 2, 3] |
14b4c778b61e
patch 8.2.3650: Vim9: for loop variable can be a list member
Bram Moolenaar <Bram@vim.org>
parents:
26236
diff
changeset
|
2950 echo l[0] |
14b4c778b61e
patch 8.2.3650: Vim9: for loop variable can be a list member
Bram Moolenaar <Bram@vim.org>
parents:
26236
diff
changeset
|
2951 endfor |
14b4c778b61e
patch 8.2.3650: Vim9: for loop variable can be a list member
Bram Moolenaar <Bram@vim.org>
parents:
26236
diff
changeset
|
2952 END |
26650
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
26556
diff
changeset
|
2953 CheckDefExecAndScriptFailure(lines, ['E461:', 'E1017:']) |
26238
14b4c778b61e
patch 8.2.3650: Vim9: for loop variable can be a list member
Bram Moolenaar <Bram@vim.org>
parents:
26236
diff
changeset
|
2954 |
14b4c778b61e
patch 8.2.3650: Vim9: for loop variable can be a list member
Bram Moolenaar <Bram@vim.org>
parents:
26236
diff
changeset
|
2955 lines =<< trim END |
14b4c778b61e
patch 8.2.3650: Vim9: for loop variable can be a list member
Bram Moolenaar <Bram@vim.org>
parents:
26236
diff
changeset
|
2956 var d = {x: 0} |
14b4c778b61e
patch 8.2.3650: Vim9: for loop variable can be a list member
Bram Moolenaar <Bram@vim.org>
parents:
26236
diff
changeset
|
2957 for d.x in [1, 2, 3] |
14b4c778b61e
patch 8.2.3650: Vim9: for loop variable can be a list member
Bram Moolenaar <Bram@vim.org>
parents:
26236
diff
changeset
|
2958 echo d.x |
14b4c778b61e
patch 8.2.3650: Vim9: for loop variable can be a list member
Bram Moolenaar <Bram@vim.org>
parents:
26236
diff
changeset
|
2959 endfor |
14b4c778b61e
patch 8.2.3650: Vim9: for loop variable can be a list member
Bram Moolenaar <Bram@vim.org>
parents:
26236
diff
changeset
|
2960 END |
26650
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
26556
diff
changeset
|
2961 CheckDefExecAndScriptFailure(lines, ['E461:', 'E1017:']) |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
2962 enddef |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
2963 |
23068
2f034cb0a046
patch 8.2.2080: Vim9: no proper error message for using s:var in for loop
Bram Moolenaar <Bram@vim.org>
parents:
23066
diff
changeset
|
2964 def Test_for_loop_script_var() |
2f034cb0a046
patch 8.2.2080: Vim9: no proper error message for using s:var in for loop
Bram Moolenaar <Bram@vim.org>
parents:
23066
diff
changeset
|
2965 # cannot use s:var in a :def function |
26660
2b17f87b7bd1
patch 8.2.3859: Vim9: some code lines not tested
Bram Moolenaar <Bram@vim.org>
parents:
26658
diff
changeset
|
2966 CheckDefFailure(['for s:var in range(3)', 'echo 3'], 'E1254:') |
23068
2f034cb0a046
patch 8.2.2080: Vim9: no proper error message for using s:var in for loop
Bram Moolenaar <Bram@vim.org>
parents:
23066
diff
changeset
|
2967 |
2f034cb0a046
patch 8.2.2080: Vim9: no proper error message for using s:var in for loop
Bram Moolenaar <Bram@vim.org>
parents:
23066
diff
changeset
|
2968 # can use s:var in Vim9 script, with or without s: |
2f034cb0a046
patch 8.2.2080: Vim9: no proper error message for using s:var in for loop
Bram Moolenaar <Bram@vim.org>
parents:
23066
diff
changeset
|
2969 var lines =<< trim END |
2f034cb0a046
patch 8.2.2080: Vim9: no proper error message for using s:var in for loop
Bram Moolenaar <Bram@vim.org>
parents:
23066
diff
changeset
|
2970 vim9script |
2f034cb0a046
patch 8.2.2080: Vim9: no proper error message for using s:var in for loop
Bram Moolenaar <Bram@vim.org>
parents:
23066
diff
changeset
|
2971 var total = 0 |
2f034cb0a046
patch 8.2.2080: Vim9: no proper error message for using s:var in for loop
Bram Moolenaar <Bram@vim.org>
parents:
23066
diff
changeset
|
2972 for s:var in [1, 2, 3] |
2f034cb0a046
patch 8.2.2080: Vim9: no proper error message for using s:var in for loop
Bram Moolenaar <Bram@vim.org>
parents:
23066
diff
changeset
|
2973 total += s:var |
2f034cb0a046
patch 8.2.2080: Vim9: no proper error message for using s:var in for loop
Bram Moolenaar <Bram@vim.org>
parents:
23066
diff
changeset
|
2974 endfor |
2f034cb0a046
patch 8.2.2080: Vim9: no proper error message for using s:var in for loop
Bram Moolenaar <Bram@vim.org>
parents:
23066
diff
changeset
|
2975 assert_equal(6, total) |
2f034cb0a046
patch 8.2.2080: Vim9: no proper error message for using s:var in for loop
Bram Moolenaar <Bram@vim.org>
parents:
23066
diff
changeset
|
2976 |
2f034cb0a046
patch 8.2.2080: Vim9: no proper error message for using s:var in for loop
Bram Moolenaar <Bram@vim.org>
parents:
23066
diff
changeset
|
2977 total = 0 |
2f034cb0a046
patch 8.2.2080: Vim9: no proper error message for using s:var in for loop
Bram Moolenaar <Bram@vim.org>
parents:
23066
diff
changeset
|
2978 for var in [1, 2, 3] |
2f034cb0a046
patch 8.2.2080: Vim9: no proper error message for using s:var in for loop
Bram Moolenaar <Bram@vim.org>
parents:
23066
diff
changeset
|
2979 total += var |
2f034cb0a046
patch 8.2.2080: Vim9: no proper error message for using s:var in for loop
Bram Moolenaar <Bram@vim.org>
parents:
23066
diff
changeset
|
2980 endfor |
2f034cb0a046
patch 8.2.2080: Vim9: no proper error message for using s:var in for loop
Bram Moolenaar <Bram@vim.org>
parents:
23066
diff
changeset
|
2981 assert_equal(6, total) |
2f034cb0a046
patch 8.2.2080: Vim9: no proper error message for using s:var in for loop
Bram Moolenaar <Bram@vim.org>
parents:
23066
diff
changeset
|
2982 END |
2f034cb0a046
patch 8.2.2080: Vim9: no proper error message for using s:var in for loop
Bram Moolenaar <Bram@vim.org>
parents:
23066
diff
changeset
|
2983 enddef |
2f034cb0a046
patch 8.2.2080: Vim9: no proper error message for using s:var in for loop
Bram Moolenaar <Bram@vim.org>
parents:
23066
diff
changeset
|
2984 |
22975
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
2985 def Test_for_loop_unpack() |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
2986 var lines =<< trim END |
23054
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
2987 var result = [] |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
2988 for [v1, v2] in [[1, 2], [3, 4]] |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
2989 result->add(v1) |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
2990 result->add(v2) |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
2991 endfor |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
2992 assert_equal([1, 2, 3, 4], result) |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
2993 |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
2994 result = [] |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
2995 for [v1, v2; v3] in [[1, 2], [3, 4, 5, 6]] |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
2996 result->add(v1) |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
2997 result->add(v2) |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
2998 result->add(v3) |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
2999 endfor |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3000 assert_equal([1, 2, [], 3, 4, [5, 6]], result) |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3001 |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3002 result = [] |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3003 for [&ts, &sw] in [[1, 2], [3, 4]] |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3004 result->add(&ts) |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3005 result->add(&sw) |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3006 endfor |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3007 assert_equal([1, 2, 3, 4], result) |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3008 |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3009 var slist: list<string> |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3010 for [$LOOPVAR, @r, v:errmsg] in [['a', 'b', 'c'], ['d', 'e', 'f']] |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3011 slist->add($LOOPVAR) |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3012 slist->add(@r) |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3013 slist->add(v:errmsg) |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3014 endfor |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3015 assert_equal(['a', 'b', 'c', 'd', 'e', 'f'], slist) |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3016 |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3017 slist = [] |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3018 for [g:globalvar, b:bufvar, w:winvar, t:tabvar] in [['global', 'buf', 'win', 'tab'], ['1', '2', '3', '4']] |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3019 slist->add(g:globalvar) |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3020 slist->add(b:bufvar) |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3021 slist->add(w:winvar) |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3022 slist->add(t:tabvar) |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3023 endfor |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3024 assert_equal(['global', 'buf', 'win', 'tab', '1', '2', '3', '4'], slist) |
23084
49c9aa9e40d4
patch 8.2.2088: Vim9: script test sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
3025 unlet! g:globalvar b:bufvar w:winvar t:tabvar |
24679
80422f66978a
patch 8.2.2878: Vim9: for loop list unpack only allows for one "_"
Bram Moolenaar <Bram@vim.org>
parents:
24555
diff
changeset
|
3026 |
80422f66978a
patch 8.2.2878: Vim9: for loop list unpack only allows for one "_"
Bram Moolenaar <Bram@vim.org>
parents:
24555
diff
changeset
|
3027 var res = [] |
80422f66978a
patch 8.2.2878: Vim9: for loop list unpack only allows for one "_"
Bram Moolenaar <Bram@vim.org>
parents:
24555
diff
changeset
|
3028 for [_, n, _] in [[1, 2, 3], [4, 5, 6]] |
80422f66978a
patch 8.2.2878: Vim9: for loop list unpack only allows for one "_"
Bram Moolenaar <Bram@vim.org>
parents:
24555
diff
changeset
|
3029 res->add(n) |
80422f66978a
patch 8.2.2878: Vim9: for loop list unpack only allows for one "_"
Bram Moolenaar <Bram@vim.org>
parents:
24555
diff
changeset
|
3030 endfor |
80422f66978a
patch 8.2.2878: Vim9: for loop list unpack only allows for one "_"
Bram Moolenaar <Bram@vim.org>
parents:
24555
diff
changeset
|
3031 assert_equal([2, 5], res) |
23054
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3032 END |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3033 CheckDefAndScriptSuccess(lines) |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3034 |
df0548b649c1
patch 8.2.2073: Vim9: for with unpack only works for local variables
Bram Moolenaar <Bram@vim.org>
parents:
22975
diff
changeset
|
3035 lines =<< trim END |
22975
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3036 for [v1, v2] in [[1, 2, 3], [3, 4]] |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3037 echo v1 v2 |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3038 endfor |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3039 END |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3040 CheckDefExecFailure(lines, 'E710:', 1) |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3041 |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3042 lines =<< trim END |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3043 for [v1, v2] in [[1], [3, 4]] |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3044 echo v1 v2 |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3045 endfor |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3046 END |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3047 CheckDefExecFailure(lines, 'E711:', 1) |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3048 |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3049 lines =<< trim END |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3050 for [v1, v1] in [[1, 2], [3, 4]] |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3051 echo v1 |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3052 endfor |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3053 END |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3054 CheckDefExecFailure(lines, 'E1017:', 1) |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3055 enddef |
a943b175586a
patch 8.2.2034: Vim9: list unpack in for statement not compiled yet
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3056 |
23927
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
3057 def Test_for_loop_with_try_continue() |
24438
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
3058 var lines =<< trim END |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
3059 var looped = 0 |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
3060 var cleanup = 0 |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
3061 for i in range(3) |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
3062 looped += 1 |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
3063 try |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
3064 eval [][0] |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
3065 catch |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
3066 continue |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
3067 finally |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
3068 cleanup += 1 |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
3069 endtry |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
3070 endfor |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
3071 assert_equal(3, looped) |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
3072 assert_equal(3, cleanup) |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
3073 END |
5c6ccab68d1e
patch 8.2.2759: Vim9: for loop infers type of loop variable
Bram Moolenaar <Bram@vim.org>
parents:
24418
diff
changeset
|
3074 CheckDefAndScriptSuccess(lines) |
23927
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
3075 enddef |
5e5780e3f75d
patch 8.2.2506: Vim9: :continue does not work correctly in a :try block
Bram Moolenaar <Bram@vim.org>
parents:
23921
diff
changeset
|
3076 |
25650
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3077 def Test_while_skipped_block() |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3078 # test skipped blocks at outside of function |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3079 var lines =<< trim END |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3080 var result = [] |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3081 var n = 0 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3082 if true |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3083 n = 1 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3084 while n < 3 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3085 result += [n] |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3086 n += 1 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3087 endwhile |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3088 else |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3089 n = 3 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3090 while n < 5 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3091 result += [n] |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3092 n += 1 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3093 endwhile |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3094 endif |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3095 assert_equal([1, 2], result) |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3096 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3097 result = [] |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3098 if false |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3099 n = 1 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3100 while n < 3 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3101 result += [n] |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3102 n += 1 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3103 endwhile |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3104 else |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3105 n = 3 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3106 while n < 5 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3107 result += [n] |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3108 n += 1 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3109 endwhile |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3110 endif |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3111 assert_equal([3, 4], result) |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3112 END |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3113 CheckDefAndScriptSuccess(lines) |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3114 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3115 # test skipped blocks at inside of function |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3116 lines =<< trim END |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3117 def DefTrue() |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3118 var result = [] |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3119 var n = 0 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3120 if true |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3121 n = 1 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3122 while n < 3 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3123 result += [n] |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3124 n += 1 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3125 endwhile |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3126 else |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3127 n = 3 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3128 while n < 5 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3129 result += [n] |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3130 n += 1 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3131 endwhile |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3132 endif |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3133 assert_equal([1, 2], result) |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3134 enddef |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3135 DefTrue() |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3136 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3137 def DefFalse() |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3138 var result = [] |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3139 var n = 0 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3140 if false |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3141 n = 1 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3142 while n < 3 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3143 result += [n] |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3144 n += 1 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3145 endwhile |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3146 else |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3147 n = 3 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3148 while n < 5 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3149 result += [n] |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3150 n += 1 |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3151 endwhile |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3152 endif |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3153 assert_equal([3, 4], result) |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3154 enddef |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3155 DefFalse() |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3156 END |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3157 CheckDefAndScriptSuccess(lines) |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3158 enddef |
6ed39aa92cb9
patch 8.2.3361: Vim9: crash with nested :while
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
3159 |
19593
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
3160 def Test_while_loop() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
3161 var result = '' |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
3162 var cnt = 0 |
19593
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
3163 while cnt < 555 |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
3164 if cnt == 3 |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
3165 break |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
3166 endif |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
3167 cnt += 1 |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
3168 if cnt == 2 |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
3169 continue |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
3170 endif |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
3171 result ..= cnt .. '_' |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
3172 endwhile |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
3173 assert_equal('1_3_', result) |
23884
00e904bdb8a5
patch 8.2.2484: Vim9: Cannot use a comment starting with #{
Bram Moolenaar <Bram@vim.org>
parents:
23882
diff
changeset
|
3174 |
00e904bdb8a5
patch 8.2.2484: Vim9: Cannot use a comment starting with #{
Bram Moolenaar <Bram@vim.org>
parents:
23882
diff
changeset
|
3175 var s = '' |
24158
93e69703a290
patch 8.2.2620: Vim9: Using #{ for a dictionary gives strange errors
Bram Moolenaar <Bram@vim.org>
parents:
24150
diff
changeset
|
3176 while s == 'x' # {comment} |
23884
00e904bdb8a5
patch 8.2.2484: Vim9: Cannot use a comment starting with #{
Bram Moolenaar <Bram@vim.org>
parents:
23882
diff
changeset
|
3177 endwhile |
19593
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
3178 enddef |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
3179 |
26236
9e6ddd7b91cd
patch 8.2.3649: Vim9: error for variable declared in while loop
Bram Moolenaar <Bram@vim.org>
parents:
26211
diff
changeset
|
3180 def Test_while_loop_in_script() |
9e6ddd7b91cd
patch 8.2.3649: Vim9: error for variable declared in while loop
Bram Moolenaar <Bram@vim.org>
parents:
26211
diff
changeset
|
3181 var lines =<< trim END |
9e6ddd7b91cd
patch 8.2.3649: Vim9: error for variable declared in while loop
Bram Moolenaar <Bram@vim.org>
parents:
26211
diff
changeset
|
3182 vim9script |
9e6ddd7b91cd
patch 8.2.3649: Vim9: error for variable declared in while loop
Bram Moolenaar <Bram@vim.org>
parents:
26211
diff
changeset
|
3183 var result = '' |
9e6ddd7b91cd
patch 8.2.3649: Vim9: error for variable declared in while loop
Bram Moolenaar <Bram@vim.org>
parents:
26211
diff
changeset
|
3184 var cnt = 0 |
9e6ddd7b91cd
patch 8.2.3649: Vim9: error for variable declared in while loop
Bram Moolenaar <Bram@vim.org>
parents:
26211
diff
changeset
|
3185 while cnt < 3 |
9e6ddd7b91cd
patch 8.2.3649: Vim9: error for variable declared in while loop
Bram Moolenaar <Bram@vim.org>
parents:
26211
diff
changeset
|
3186 var s = 'v' .. cnt |
9e6ddd7b91cd
patch 8.2.3649: Vim9: error for variable declared in while loop
Bram Moolenaar <Bram@vim.org>
parents:
26211
diff
changeset
|
3187 result ..= s |
9e6ddd7b91cd
patch 8.2.3649: Vim9: error for variable declared in while loop
Bram Moolenaar <Bram@vim.org>
parents:
26211
diff
changeset
|
3188 cnt += 1 |
9e6ddd7b91cd
patch 8.2.3649: Vim9: error for variable declared in while loop
Bram Moolenaar <Bram@vim.org>
parents:
26211
diff
changeset
|
3189 endwhile |
9e6ddd7b91cd
patch 8.2.3649: Vim9: error for variable declared in while loop
Bram Moolenaar <Bram@vim.org>
parents:
26211
diff
changeset
|
3190 assert_equal('v0v1v2', result) |
9e6ddd7b91cd
patch 8.2.3649: Vim9: error for variable declared in while loop
Bram Moolenaar <Bram@vim.org>
parents:
26211
diff
changeset
|
3191 END |
9e6ddd7b91cd
patch 8.2.3649: Vim9: error for variable declared in while loop
Bram Moolenaar <Bram@vim.org>
parents:
26211
diff
changeset
|
3192 CheckScriptSuccess(lines) |
9e6ddd7b91cd
patch 8.2.3649: Vim9: error for variable declared in while loop
Bram Moolenaar <Bram@vim.org>
parents:
26211
diff
changeset
|
3193 enddef |
9e6ddd7b91cd
patch 8.2.3649: Vim9: error for variable declared in while loop
Bram Moolenaar <Bram@vim.org>
parents:
26211
diff
changeset
|
3194 |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
3195 def Test_while_loop_fails() |
20019
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
3196 CheckDefFailure(['while xxx'], 'E1001:') |
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
3197 CheckDefFailure(['endwhile'], 'E588:') |
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
3198 CheckDefFailure(['continue'], 'E586:') |
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
3199 CheckDefFailure(['if true', 'continue'], 'E586:') |
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
3200 CheckDefFailure(['break'], 'E587:') |
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
3201 CheckDefFailure(['if true', 'break'], 'E587:') |
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
3202 CheckDefFailure(['while 1', 'echo 3'], 'E170:') |
23882
a4df35126d9c
patch 8.2.2483: Vim9: type error for misformed expression
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
3203 |
a4df35126d9c
patch 8.2.2483: Vim9: type error for misformed expression
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
3204 var lines =<< trim END |
a4df35126d9c
patch 8.2.2483: Vim9: type error for misformed expression
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
3205 var s = '' |
a4df35126d9c
patch 8.2.2483: Vim9: type error for misformed expression
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
3206 while s = '' |
a4df35126d9c
patch 8.2.2483: Vim9: type error for misformed expression
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
3207 endwhile |
a4df35126d9c
patch 8.2.2483: Vim9: type error for misformed expression
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
3208 END |
a4df35126d9c
patch 8.2.2483: Vim9: type error for misformed expression
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
3209 CheckDefFailure(lines, 'E488:') |
19862
846fbbacce3a
patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19860
diff
changeset
|
3210 enddef |
846fbbacce3a
patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19860
diff
changeset
|
3211 |
19730
fe8ba2f82f59
patch 8.2.0421: interrupting with CTRL-C does not always work
Bram Moolenaar <Bram@vim.org>
parents:
19728
diff
changeset
|
3212 def Test_interrupt_loop() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
3213 var caught = false |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
3214 var x = 0 |
19736
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
3215 try |
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
3216 while 1 |
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
3217 x += 1 |
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
3218 if x == 100 |
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
3219 feedkeys("\<C-C>", 'Lt') |
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
3220 endif |
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
3221 endwhile |
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
3222 catch |
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
3223 caught = true |
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
3224 assert_equal(100, x) |
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
3225 endtry |
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
3226 assert_true(caught, 'should have caught an exception') |
21987
c33cec63cf53
patch 8.2.1543: Vim9: test with invalid SID is skipped in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
21985
diff
changeset
|
3227 # consume the CTRL-C |
c33cec63cf53
patch 8.2.1543: Vim9: test with invalid SID is skipped in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
21985
diff
changeset
|
3228 getchar(0) |
19730
fe8ba2f82f59
patch 8.2.0421: interrupting with CTRL-C does not always work
Bram Moolenaar <Bram@vim.org>
parents:
19728
diff
changeset
|
3229 enddef |
19726
ad37a198a708
patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents:
19623
diff
changeset
|
3230 |
19999
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
3231 def Test_automatic_line_continuation() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
3232 var mylist = [ |
19999
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
3233 'one', |
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
3234 'two', |
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
3235 'three', |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
3236 ] # comment |
19999
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
3237 assert_equal(['one', 'two', 'three'], mylist) |
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
3238 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
3239 var mydict = { |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23068
diff
changeset
|
3240 ['one']: 1, |
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23068
diff
changeset
|
3241 ['two']: 2, |
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23068
diff
changeset
|
3242 ['three']: |
19999
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
3243 3, |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
3244 } # comment |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23068
diff
changeset
|
3245 assert_equal({one: 1, two: 2, three: 3}, mydict) |
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23068
diff
changeset
|
3246 mydict = { |
20023
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20019
diff
changeset
|
3247 one: 1, # comment |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20019
diff
changeset
|
3248 two: # comment |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20019
diff
changeset
|
3249 2, # comment |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20019
diff
changeset
|
3250 three: 3 # comment |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20019
diff
changeset
|
3251 } |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23068
diff
changeset
|
3252 assert_equal({one: 1, two: 2, three: 3}, mydict) |
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23068
diff
changeset
|
3253 mydict = { |
20023
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20019
diff
changeset
|
3254 one: 1, |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20019
diff
changeset
|
3255 two: |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20019
diff
changeset
|
3256 2, |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20019
diff
changeset
|
3257 three: 3 |
19999
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
3258 } |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23068
diff
changeset
|
3259 assert_equal({one: 1, two: 2, three: 3}, mydict) |
20011
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
3260 |
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
3261 assert_equal( |
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
3262 ['one', 'two', 'three'], |
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
3263 split('one two three') |
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
3264 ) |
19999
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
3265 enddef |
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
3266 |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3267 def Test_vim9_comment() |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3268 CheckScriptSuccess([ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3269 'vim9script', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3270 '# something', |
23179
821701ecbde7
patch 8.2.2135: Vim9: #{ still seen as start of dict in some places
Bram Moolenaar <Bram@vim.org>
parents:
23162
diff
changeset
|
3271 '#something', |
821701ecbde7
patch 8.2.2135: Vim9: #{ still seen as start of dict in some places
Bram Moolenaar <Bram@vim.org>
parents:
23162
diff
changeset
|
3272 '#{something', |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3273 ]) |
23179
821701ecbde7
patch 8.2.2135: Vim9: #{ still seen as start of dict in some places
Bram Moolenaar <Bram@vim.org>
parents:
23162
diff
changeset
|
3274 |
821701ecbde7
patch 8.2.2135: Vim9: #{ still seen as start of dict in some places
Bram Moolenaar <Bram@vim.org>
parents:
23162
diff
changeset
|
3275 split Xfile |
821701ecbde7
patch 8.2.2135: Vim9: #{ still seen as start of dict in some places
Bram Moolenaar <Bram@vim.org>
parents:
23162
diff
changeset
|
3276 CheckScriptSuccess([ |
821701ecbde7
patch 8.2.2135: Vim9: #{ still seen as start of dict in some places
Bram Moolenaar <Bram@vim.org>
parents:
23162
diff
changeset
|
3277 'vim9script', |
821701ecbde7
patch 8.2.2135: Vim9: #{ still seen as start of dict in some places
Bram Moolenaar <Bram@vim.org>
parents:
23162
diff
changeset
|
3278 'edit #something', |
821701ecbde7
patch 8.2.2135: Vim9: #{ still seen as start of dict in some places
Bram Moolenaar <Bram@vim.org>
parents:
23162
diff
changeset
|
3279 ]) |
821701ecbde7
patch 8.2.2135: Vim9: #{ still seen as start of dict in some places
Bram Moolenaar <Bram@vim.org>
parents:
23162
diff
changeset
|
3280 CheckScriptSuccess([ |
821701ecbde7
patch 8.2.2135: Vim9: #{ still seen as start of dict in some places
Bram Moolenaar <Bram@vim.org>
parents:
23162
diff
changeset
|
3281 'vim9script', |
821701ecbde7
patch 8.2.2135: Vim9: #{ still seen as start of dict in some places
Bram Moolenaar <Bram@vim.org>
parents:
23162
diff
changeset
|
3282 'edit #{something', |
821701ecbde7
patch 8.2.2135: Vim9: #{ still seen as start of dict in some places
Bram Moolenaar <Bram@vim.org>
parents:
23162
diff
changeset
|
3283 ]) |
821701ecbde7
patch 8.2.2135: Vim9: #{ still seen as start of dict in some places
Bram Moolenaar <Bram@vim.org>
parents:
23162
diff
changeset
|
3284 close |
821701ecbde7
patch 8.2.2135: Vim9: #{ still seen as start of dict in some places
Bram Moolenaar <Bram@vim.org>
parents:
23162
diff
changeset
|
3285 |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3286 CheckScriptFailure([ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3287 'vim9script', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3288 ':# something', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3289 ], 'E488:') |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3290 CheckScriptFailure([ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3291 '# something', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3292 ], 'E488:') |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3293 CheckScriptFailure([ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3294 ':# something', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3295 ], 'E488:') |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3296 |
20061
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3297 { # block start |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3298 } # block end |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3299 CheckDefFailure([ |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3300 '{# comment', |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3301 ], 'E488:') |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3302 CheckDefFailure([ |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3303 '{', |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3304 '}# comment', |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3305 ], 'E488:') |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3306 |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3307 echo "yes" # comment |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3308 CheckDefFailure([ |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3309 'echo "yes"# comment', |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3310 ], 'E488:') |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3311 CheckScriptSuccess([ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3312 'vim9script', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3313 'echo "yes" # something', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3314 ]) |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3315 CheckScriptFailure([ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3316 'vim9script', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3317 'echo "yes"# something', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3318 ], 'E121:') |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3319 CheckScriptFailure([ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3320 'vim9script', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3321 'echo# something', |
23342
13572a262b15
patch 8.2.2214: ":e#" does not give a warning for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
23330
diff
changeset
|
3322 ], 'E1144:') |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3323 CheckScriptFailure([ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3324 'echo "yes" # something', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3325 ], 'E121:') |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3326 |
20061
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3327 exe "echo" # comment |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3328 CheckDefFailure([ |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3329 'exe "echo"# comment', |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3330 ], 'E488:') |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3331 CheckScriptSuccess([ |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3332 'vim9script', |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3333 'exe "echo" # something', |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3334 ]) |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3335 CheckScriptFailure([ |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3336 'vim9script', |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3337 'exe "echo"# something', |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3338 ], 'E121:') |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3339 CheckScriptFailure([ |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3340 'vim9script', |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3341 'exe# something', |
23342
13572a262b15
patch 8.2.2214: ":e#" does not give a warning for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
23330
diff
changeset
|
3342 ], 'E1144:') |
20061
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3343 CheckScriptFailure([ |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3344 'exe "echo" # something', |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3345 ], 'E121:') |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
3346 |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3347 CheckDefFailure([ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3348 'try# comment', |
20113
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3349 ' echo "yes"', |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3350 'catch', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3351 'endtry', |
23342
13572a262b15
patch 8.2.2214: ":e#" does not give a warning for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
23330
diff
changeset
|
3352 ], 'E1144:') |
20113
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3353 CheckScriptFailure([ |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3354 'vim9script', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3355 'try# comment', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3356 'echo "yes"', |
23342
13572a262b15
patch 8.2.2214: ":e#" does not give a warning for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
23330
diff
changeset
|
3357 ], 'E1144:') |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3358 CheckDefFailure([ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3359 'try', |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3360 ' throw#comment', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3361 'catch', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3362 'endtry', |
23342
13572a262b15
patch 8.2.2214: ":e#" does not give a warning for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
23330
diff
changeset
|
3363 ], 'E1144:') |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3364 CheckDefFailure([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3365 'try', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3366 ' throw "yes"#comment', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3367 'catch', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3368 'endtry', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3369 ], 'E488:') |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3370 CheckDefFailure([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3371 'try', |
20113
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3372 ' echo "yes"', |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3373 'catch# comment', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3374 'endtry', |
23342
13572a262b15
patch 8.2.2214: ":e#" does not give a warning for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
23330
diff
changeset
|
3375 ], 'E1144:') |
20113
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3376 CheckScriptFailure([ |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3377 'vim9script', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3378 'try', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3379 ' echo "yes"', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3380 'catch# comment', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3381 'endtry', |
23342
13572a262b15
patch 8.2.2214: ":e#" does not give a warning for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
23330
diff
changeset
|
3382 ], 'E1144:') |
20113
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3383 CheckDefFailure([ |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3384 'try', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3385 ' echo "yes"', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3386 'catch /pat/# comment', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3387 'endtry', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3388 ], 'E488:') |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3389 CheckDefFailure([ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3390 'try', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3391 'echo "yes"', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3392 'catch', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3393 'endtry# comment', |
23342
13572a262b15
patch 8.2.2214: ":e#" does not give a warning for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
23330
diff
changeset
|
3394 ], 'E1144:') |
20113
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3395 CheckScriptFailure([ |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3396 'vim9script', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3397 'try', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3398 ' echo "yes"', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3399 'catch', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3400 'endtry# comment', |
23342
13572a262b15
patch 8.2.2214: ":e#" does not give a warning for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
23330
diff
changeset
|
3401 ], 'E1144:') |
20113
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3402 |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3403 CheckScriptSuccess([ |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3404 'vim9script', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3405 'hi # comment', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3406 ]) |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3407 CheckScriptFailure([ |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3408 'vim9script', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3409 'hi# comment', |
23342
13572a262b15
patch 8.2.2214: ":e#" does not give a warning for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
23330
diff
changeset
|
3410 ], 'E1144:') |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3411 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3412 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3413 'hi Search # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3414 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3415 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3416 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3417 'hi Search# comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3418 ], 'E416:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3419 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3420 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3421 'hi link This Search # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3422 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3423 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3424 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3425 'hi link This That# comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3426 ], 'E413:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3427 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3428 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3429 'hi clear This # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3430 'hi clear # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3431 ]) |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
3432 # not tested, because it doesn't give an error but a warning: |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
3433 # hi clear This# comment', |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3434 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3435 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3436 'hi clear# comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3437 ], 'E416:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3438 |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3439 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3440 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3441 'hi Group term=bold', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3442 'match Group /todo/ # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3443 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3444 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3445 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3446 'hi Group term=bold', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3447 'match Group /todo/# comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3448 ], 'E488:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3449 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3450 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3451 'match # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3452 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3453 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3454 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3455 'match# comment', |
23342
13572a262b15
patch 8.2.2214: ":e#" does not give a warning for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
23330
diff
changeset
|
3456 ], 'E1144:') |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3457 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3458 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3459 'match none # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3460 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3461 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3462 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3463 'match none# comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3464 ], 'E475:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3465 |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3466 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3467 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3468 'menutrans clear # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3469 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3470 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3471 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3472 'menutrans clear# comment text', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3473 ], 'E474:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3474 |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3475 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3476 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3477 'syntax clear # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3478 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3479 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3480 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3481 'syntax clear# comment text', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3482 ], 'E28:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3483 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3484 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3485 'syntax keyword Word some', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3486 'syntax clear Word # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3487 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3488 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3489 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3490 'syntax keyword Word some', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3491 'syntax clear Word# comment text', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3492 ], 'E28:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3493 |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3494 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3495 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3496 'syntax list # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3497 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3498 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3499 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3500 'syntax list# comment text', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3501 ], 'E28:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3502 |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3503 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3504 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3505 'syntax match Word /pat/ oneline # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3506 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3507 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3508 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3509 'syntax match Word /pat/ oneline# comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3510 ], 'E475:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3511 |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3512 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3513 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3514 'syntax keyword Word word # comm[ent', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3515 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3516 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3517 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3518 'syntax keyword Word word# comm[ent', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3519 ], 'E789:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3520 |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3521 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3522 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3523 'syntax match Word /pat/ # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3524 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3525 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3526 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3527 'syntax match Word /pat/# comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3528 ], 'E402:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3529 |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3530 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3531 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3532 'syntax match Word /pat/ contains=Something # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3533 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3534 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3535 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3536 'syntax match Word /pat/ contains=Something# comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3537 ], 'E475:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3538 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3539 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3540 'syntax match Word /pat/ contains= # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3541 ], 'E406:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3542 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3543 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3544 'syntax match Word /pat/ contains=# comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3545 ], 'E475:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3546 |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3547 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3548 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3549 'syntax region Word start=/pat/ end=/pat/ # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3550 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3551 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3552 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3553 'syntax region Word start=/pat/ end=/pat/# comment', |
21375
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
3554 ], 'E402:') |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3555 |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3556 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3557 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3558 'syntax sync # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3559 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3560 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3561 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3562 'syntax sync# comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3563 ], 'E404:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3564 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3565 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3566 'syntax sync ccomment # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3567 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3568 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3569 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3570 'syntax sync ccomment# comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3571 ], 'E404:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3572 |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3573 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3574 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3575 'syntax cluster Some contains=Word # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3576 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3577 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3578 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3579 'syntax cluster Some contains=Word# comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
3580 ], 'E475:') |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3581 |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3582 CheckScriptSuccess([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3583 'vim9script', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3584 'command Echo echo # comment', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3585 'command Echo # comment', |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
23084
diff
changeset
|
3586 'delcommand Echo', |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3587 ]) |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3588 CheckScriptFailure([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3589 'vim9script', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3590 'command Echo echo# comment', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3591 'Echo', |
23342
13572a262b15
patch 8.2.2214: ":e#" does not give a warning for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
23330
diff
changeset
|
3592 ], 'E1144:') |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
23084
diff
changeset
|
3593 delcommand Echo |
23162
c923f1888a77
patch 8.2.2127: Vim9: executing user command from Vim9 script not tested
Bram Moolenaar <Bram@vim.org>
parents:
23152
diff
changeset
|
3594 |
c923f1888a77
patch 8.2.2127: Vim9: executing user command from Vim9 script not tested
Bram Moolenaar <Bram@vim.org>
parents:
23152
diff
changeset
|
3595 var curdir = getcwd() |
c923f1888a77
patch 8.2.2127: Vim9: executing user command from Vim9 script not tested
Bram Moolenaar <Bram@vim.org>
parents:
23152
diff
changeset
|
3596 CheckScriptSuccess([ |
c923f1888a77
patch 8.2.2127: Vim9: executing user command from Vim9 script not tested
Bram Moolenaar <Bram@vim.org>
parents:
23152
diff
changeset
|
3597 'command Echo cd " comment', |
c923f1888a77
patch 8.2.2127: Vim9: executing user command from Vim9 script not tested
Bram Moolenaar <Bram@vim.org>
parents:
23152
diff
changeset
|
3598 'Echo', |
c923f1888a77
patch 8.2.2127: Vim9: executing user command from Vim9 script not tested
Bram Moolenaar <Bram@vim.org>
parents:
23152
diff
changeset
|
3599 'delcommand Echo', |
c923f1888a77
patch 8.2.2127: Vim9: executing user command from Vim9 script not tested
Bram Moolenaar <Bram@vim.org>
parents:
23152
diff
changeset
|
3600 ]) |
c923f1888a77
patch 8.2.2127: Vim9: executing user command from Vim9 script not tested
Bram Moolenaar <Bram@vim.org>
parents:
23152
diff
changeset
|
3601 CheckScriptSuccess([ |
23247
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23237
diff
changeset
|
3602 'vim9script', |
23162
c923f1888a77
patch 8.2.2127: Vim9: executing user command from Vim9 script not tested
Bram Moolenaar <Bram@vim.org>
parents:
23152
diff
changeset
|
3603 'command Echo cd # comment', |
c923f1888a77
patch 8.2.2127: Vim9: executing user command from Vim9 script not tested
Bram Moolenaar <Bram@vim.org>
parents:
23152
diff
changeset
|
3604 'Echo', |
c923f1888a77
patch 8.2.2127: Vim9: executing user command from Vim9 script not tested
Bram Moolenaar <Bram@vim.org>
parents:
23152
diff
changeset
|
3605 'delcommand Echo', |
c923f1888a77
patch 8.2.2127: Vim9: executing user command from Vim9 script not tested
Bram Moolenaar <Bram@vim.org>
parents:
23152
diff
changeset
|
3606 ]) |
c923f1888a77
patch 8.2.2127: Vim9: executing user command from Vim9 script not tested
Bram Moolenaar <Bram@vim.org>
parents:
23152
diff
changeset
|
3607 CheckScriptFailure([ |
c923f1888a77
patch 8.2.2127: Vim9: executing user command from Vim9 script not tested
Bram Moolenaar <Bram@vim.org>
parents:
23152
diff
changeset
|
3608 'vim9script', |
c923f1888a77
patch 8.2.2127: Vim9: executing user command from Vim9 script not tested
Bram Moolenaar <Bram@vim.org>
parents:
23152
diff
changeset
|
3609 'command Echo cd " comment', |
c923f1888a77
patch 8.2.2127: Vim9: executing user command from Vim9 script not tested
Bram Moolenaar <Bram@vim.org>
parents:
23152
diff
changeset
|
3610 'Echo', |
c923f1888a77
patch 8.2.2127: Vim9: executing user command from Vim9 script not tested
Bram Moolenaar <Bram@vim.org>
parents:
23152
diff
changeset
|
3611 ], 'E344:') |
c923f1888a77
patch 8.2.2127: Vim9: executing user command from Vim9 script not tested
Bram Moolenaar <Bram@vim.org>
parents:
23152
diff
changeset
|
3612 delcommand Echo |
c923f1888a77
patch 8.2.2127: Vim9: executing user command from Vim9 script not tested
Bram Moolenaar <Bram@vim.org>
parents:
23152
diff
changeset
|
3613 chdir(curdir) |
c923f1888a77
patch 8.2.2127: Vim9: executing user command from Vim9 script not tested
Bram Moolenaar <Bram@vim.org>
parents:
23152
diff
changeset
|
3614 |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3615 CheckScriptFailure([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3616 'vim9script', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3617 'command Echo# comment', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3618 ], 'E182:') |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3619 CheckScriptFailure([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3620 'vim9script', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3621 'command Echo echo', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3622 'command Echo# comment', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3623 ], 'E182:') |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
23084
diff
changeset
|
3624 delcommand Echo |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3625 |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3626 CheckScriptSuccess([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3627 'vim9script', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3628 'function # comment', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3629 ]) |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3630 CheckScriptFailure([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3631 'vim9script', |
21528
e0aa9b81f6a9
patch 8.2.1314: Vim9: rule for comment after :function is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21526
diff
changeset
|
3632 'function " comment', |
e0aa9b81f6a9
patch 8.2.1314: Vim9: rule for comment after :function is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21526
diff
changeset
|
3633 ], 'E129:') |
e0aa9b81f6a9
patch 8.2.1314: Vim9: rule for comment after :function is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21526
diff
changeset
|
3634 CheckScriptFailure([ |
e0aa9b81f6a9
patch 8.2.1314: Vim9: rule for comment after :function is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21526
diff
changeset
|
3635 'vim9script', |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3636 'function# comment', |
23342
13572a262b15
patch 8.2.2214: ":e#" does not give a warning for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
23330
diff
changeset
|
3637 ], 'E1144:') |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3638 CheckScriptSuccess([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3639 'vim9script', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3640 'function CheckScriptSuccess # comment', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3641 ]) |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3642 CheckScriptFailure([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3643 'vim9script', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3644 'function CheckScriptSuccess# comment', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3645 ], 'E488:') |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3646 |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3647 CheckScriptSuccess([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3648 'vim9script', |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
3649 'func g:DeleteMeA()', |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3650 'endfunc', |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
3651 'delfunction g:DeleteMeA # comment', |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3652 ]) |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3653 CheckScriptFailure([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3654 'vim9script', |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
3655 'func g:DeleteMeB()', |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3656 'endfunc', |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
3657 'delfunction g:DeleteMeB# comment', |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3658 ], 'E488:') |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3659 |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3660 CheckScriptSuccess([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3661 'vim9script', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3662 'call execute("ls") # comment', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3663 ]) |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3664 CheckScriptFailure([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3665 'vim9script', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3666 'call execute("ls")# comment', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
3667 ], 'E488:') |
21435
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3668 |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3669 CheckScriptFailure([ |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3670 'def Test() " comment', |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3671 'enddef', |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3672 ], 'E488:') |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3673 CheckScriptFailure([ |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3674 'vim9script', |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3675 'def Test() " comment', |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3676 'enddef', |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3677 ], 'E488:') |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3678 |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3679 CheckScriptSuccess([ |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3680 'func Test() " comment', |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3681 'endfunc', |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
23084
diff
changeset
|
3682 'delfunc Test', |
21435
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3683 ]) |
21528
e0aa9b81f6a9
patch 8.2.1314: Vim9: rule for comment after :function is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21526
diff
changeset
|
3684 CheckScriptSuccess([ |
21435
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3685 'vim9script', |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3686 'func Test() " comment', |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3687 'endfunc', |
21528
e0aa9b81f6a9
patch 8.2.1314: Vim9: rule for comment after :function is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21526
diff
changeset
|
3688 ]) |
21435
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3689 |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3690 CheckScriptSuccess([ |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3691 'def Test() # comment', |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3692 'enddef', |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3693 ]) |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3694 CheckScriptFailure([ |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3695 'func Test() # comment', |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3696 'endfunc', |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
3697 ], 'E488:') |
24774
8bf9726097d8
patch 8.2.2925: Vim9: line continuation comment uses legacy syntax
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
3698 |
8bf9726097d8
patch 8.2.2925: Vim9: line continuation comment uses legacy syntax
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
3699 var lines =<< trim END |
8bf9726097d8
patch 8.2.2925: Vim9: line continuation comment uses legacy syntax
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
3700 vim9script |
8bf9726097d8
patch 8.2.2925: Vim9: line continuation comment uses legacy syntax
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
3701 syn region Text |
8bf9726097d8
patch 8.2.2925: Vim9: line continuation comment uses legacy syntax
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
3702 \ start='foo' |
8bf9726097d8
patch 8.2.2925: Vim9: line continuation comment uses legacy syntax
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
3703 #\ comment |
8bf9726097d8
patch 8.2.2925: Vim9: line continuation comment uses legacy syntax
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
3704 \ end='bar' |
24786
524120691c3d
patch 8.2.2931: Vim9: line continuation comment uses legacy syntax
Bram Moolenaar <Bram@vim.org>
parents:
24774
diff
changeset
|
3705 syn region Text start='foo' |
524120691c3d
patch 8.2.2931: Vim9: line continuation comment uses legacy syntax
Bram Moolenaar <Bram@vim.org>
parents:
24774
diff
changeset
|
3706 #\ comment |
524120691c3d
patch 8.2.2931: Vim9: line continuation comment uses legacy syntax
Bram Moolenaar <Bram@vim.org>
parents:
24774
diff
changeset
|
3707 \ end='bar' |
24774
8bf9726097d8
patch 8.2.2925: Vim9: line continuation comment uses legacy syntax
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
3708 END |
8bf9726097d8
patch 8.2.2925: Vim9: line continuation comment uses legacy syntax
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
3709 CheckScriptSuccess(lines) |
8bf9726097d8
patch 8.2.2925: Vim9: line continuation comment uses legacy syntax
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
3710 |
8bf9726097d8
patch 8.2.2925: Vim9: line continuation comment uses legacy syntax
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
3711 lines =<< trim END |
8bf9726097d8
patch 8.2.2925: Vim9: line continuation comment uses legacy syntax
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
3712 vim9script |
8bf9726097d8
patch 8.2.2925: Vim9: line continuation comment uses legacy syntax
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
3713 syn region Text |
8bf9726097d8
patch 8.2.2925: Vim9: line continuation comment uses legacy syntax
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
3714 \ start='foo' |
8bf9726097d8
patch 8.2.2925: Vim9: line continuation comment uses legacy syntax
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
3715 "\ comment |
8bf9726097d8
patch 8.2.2925: Vim9: line continuation comment uses legacy syntax
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
3716 \ end='bar' |
8bf9726097d8
patch 8.2.2925: Vim9: line continuation comment uses legacy syntax
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
3717 END |
8bf9726097d8
patch 8.2.2925: Vim9: line continuation comment uses legacy syntax
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
3718 CheckScriptFailure(lines, 'E399:') |
20113
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3719 enddef |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3720 |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3721 def Test_vim9_comment_gui() |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3722 CheckCanRunGui |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3723 |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3724 CheckScriptFailure([ |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3725 'vim9script', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3726 'gui#comment' |
23342
13572a262b15
patch 8.2.2214: ":e#" does not give a warning for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
23330
diff
changeset
|
3727 ], 'E1144:') |
20113
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3728 CheckScriptFailure([ |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3729 'vim9script', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
3730 'gui -f#comment' |
25654
ef38fc02faaa
patch 8.2.3363: when :edit reuses the current buffer the alternate file is set
Bram Moolenaar <Bram@vim.org>
parents:
25650
diff
changeset
|
3731 ], 'E194:') |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3732 enddef |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
3733 |
20079
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
3734 def Test_vim9_comment_not_compiled() |
20945
0653b9b72091
patch 8.2.1024: Vim9: no error for using "let g:var = val"
Bram Moolenaar <Bram@vim.org>
parents:
20921
diff
changeset
|
3735 au TabEnter *.vim g:entered = 1 |
0653b9b72091
patch 8.2.1024: Vim9: no error for using "let g:var = val"
Bram Moolenaar <Bram@vim.org>
parents:
20921
diff
changeset
|
3736 au TabEnter *.x g:entered = 2 |
20079
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
3737 |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
3738 edit test.vim |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
3739 doautocmd TabEnter #comment |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
3740 assert_equal(1, g:entered) |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
3741 |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
3742 doautocmd TabEnter f.x |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
3743 assert_equal(2, g:entered) |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
3744 |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
3745 g:entered = 0 |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
3746 doautocmd TabEnter f.x #comment |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
3747 assert_equal(2, g:entered) |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
3748 |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
3749 assert_fails('doautocmd Syntax#comment', 'E216:') |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
3750 |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
3751 au! TabEnter |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
3752 unlet g:entered |
20091
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
3753 |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
3754 CheckScriptSuccess([ |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
3755 'vim9script', |
20945
0653b9b72091
patch 8.2.1024: Vim9: no error for using "let g:var = val"
Bram Moolenaar <Bram@vim.org>
parents:
20921
diff
changeset
|
3756 'g:var = 123', |
20953
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3757 'b:var = 456', |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3758 'w:var = 777', |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3759 't:var = 888', |
20091
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
3760 'unlet g:var w:var # something', |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
3761 ]) |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
3762 |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
3763 CheckScriptFailure([ |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
3764 'vim9script', |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
3765 'let var = 123', |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
3766 ], 'E1126: Cannot use :let in Vim9 script') |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
3767 |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
3768 CheckScriptFailure([ |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
3769 'vim9script', |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
3770 'var g:var = 123', |
20953
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3771 ], 'E1016: Cannot declare a global variable:') |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3772 |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3773 CheckScriptFailure([ |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3774 'vim9script', |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
3775 'var b:var = 123', |
20953
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3776 ], 'E1016: Cannot declare a buffer variable:') |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3777 |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3778 CheckScriptFailure([ |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3779 'vim9script', |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
3780 'var w:var = 123', |
20953
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3781 ], 'E1016: Cannot declare a window variable:') |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3782 |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3783 CheckScriptFailure([ |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3784 'vim9script', |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
3785 'var t:var = 123', |
20953
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3786 ], 'E1016: Cannot declare a tab variable:') |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3787 |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3788 CheckScriptFailure([ |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3789 'vim9script', |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
3790 'var v:version = 123', |
20953
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3791 ], 'E1016: Cannot declare a v: variable:') |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3792 |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3793 CheckScriptFailure([ |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3794 'vim9script', |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
3795 'var $VARIABLE = "text"', |
20953
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3796 ], 'E1016: Cannot declare an environment variable:') |
20945
0653b9b72091
patch 8.2.1024: Vim9: no error for using "let g:var = val"
Bram Moolenaar <Bram@vim.org>
parents:
20921
diff
changeset
|
3797 |
0653b9b72091
patch 8.2.1024: Vim9: no error for using "let g:var = val"
Bram Moolenaar <Bram@vim.org>
parents:
20921
diff
changeset
|
3798 CheckScriptFailure([ |
0653b9b72091
patch 8.2.1024: Vim9: no error for using "let g:var = val"
Bram Moolenaar <Bram@vim.org>
parents:
20921
diff
changeset
|
3799 'vim9script', |
0653b9b72091
patch 8.2.1024: Vim9: no error for using "let g:var = val"
Bram Moolenaar <Bram@vim.org>
parents:
20921
diff
changeset
|
3800 'g:var = 123', |
20397
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
3801 'unlet g:var# comment1', |
20091
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
3802 ], 'E108:') |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
3803 |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
3804 CheckScriptFailure([ |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
3805 'let g:var = 123', |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
3806 'unlet g:var # something', |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
3807 ], 'E488:') |
20111
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3808 |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3809 CheckScriptSuccess([ |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3810 'vim9script', |
20397
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
3811 'if 1 # comment2', |
20111
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3812 ' echo "yes"', |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3813 'elseif 2 #comment', |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3814 ' echo "no"', |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3815 'endif', |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3816 ]) |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3817 |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3818 CheckScriptFailure([ |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3819 'vim9script', |
20397
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
3820 'if 1# comment3', |
20111
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3821 ' echo "yes"', |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3822 'endif', |
24958
21ec48d542a8
patch 8.2.3016: confusing error when expression is followed by comma
Bram Moolenaar <Bram@vim.org>
parents:
24934
diff
changeset
|
3823 ], 'E488:') |
20111
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3824 |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3825 CheckScriptFailure([ |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3826 'vim9script', |
20397
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
3827 'if 0 # comment4', |
20111
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3828 ' echo "yes"', |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3829 'elseif 2#comment', |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3830 ' echo "no"', |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3831 'endif', |
24958
21ec48d542a8
patch 8.2.3016: confusing error when expression is followed by comma
Bram Moolenaar <Bram@vim.org>
parents:
24934
diff
changeset
|
3832 ], 'E488:') |
20111
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3833 |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3834 CheckScriptSuccess([ |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3835 'vim9script', |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
3836 'var v = 1 # comment5', |
20111
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3837 ]) |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3838 |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3839 CheckScriptFailure([ |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3840 'vim9script', |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
3841 'var v = 1# comment6', |
24958
21ec48d542a8
patch 8.2.3016: confusing error when expression is followed by comma
Bram Moolenaar <Bram@vim.org>
parents:
24934
diff
changeset
|
3842 ], 'E488:') |
20111
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3843 |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3844 CheckScriptSuccess([ |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3845 'vim9script', |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3846 'new' |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
3847 'setline(1, ["# define pat", "last"])', |
20982
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
3848 ':$', |
20111
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3849 'dsearch /pat/ #comment', |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3850 'bwipe!', |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3851 ]) |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
3852 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
3853 CheckScriptFailure([ |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
3854 'vim9script', |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
3855 'new' |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
3856 'setline(1, ["# define pat", "last"])', |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
3857 ':$', |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
3858 'dsearch /pat/#comment', |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
3859 'bwipe!', |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
3860 ], 'E488:') |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
3861 |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
3862 CheckScriptFailure([ |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
3863 'vim9script', |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
3864 'func! SomeFunc()', |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
3865 ], 'E477:') |
20079
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
3866 enddef |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
3867 |
20351
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
3868 def Test_finish() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
3869 var lines =<< trim END |
20351
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
3870 vim9script |
20945
0653b9b72091
patch 8.2.1024: Vim9: no error for using "let g:var = val"
Bram Moolenaar <Bram@vim.org>
parents:
20921
diff
changeset
|
3871 g:res = 'one' |
20351
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
3872 if v:false | finish | endif |
20945
0653b9b72091
patch 8.2.1024: Vim9: no error for using "let g:var = val"
Bram Moolenaar <Bram@vim.org>
parents:
20921
diff
changeset
|
3873 g:res = 'two' |
20351
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
3874 finish |
20945
0653b9b72091
patch 8.2.1024: Vim9: no error for using "let g:var = val"
Bram Moolenaar <Bram@vim.org>
parents:
20921
diff
changeset
|
3875 g:res = 'three' |
20351
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
3876 END |
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
3877 writefile(lines, 'Xfinished') |
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
3878 source Xfinished |
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
3879 assert_equal('two', g:res) |
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
3880 |
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
3881 unlet g:res |
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
3882 delete('Xfinished') |
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
3883 enddef |
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
3884 |
20399
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
3885 def Test_forward_declaration() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
3886 var lines =<< trim END |
20399
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
3887 vim9script |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
3888 def GetValue(): string |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
3889 return theVal |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
3890 enddef |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
3891 var theVal = 'something' |
20528
489cb75c76b6
patch 8.2.0818: Vim9: using a discovery phase doesn't work well
Bram Moolenaar <Bram@vim.org>
parents:
20504
diff
changeset
|
3892 g:initVal = GetValue() |
20399
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
3893 theVal = 'else' |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
3894 g:laterVal = GetValue() |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
3895 END |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
3896 writefile(lines, 'Xforward') |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
3897 source Xforward |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
3898 assert_equal('something', g:initVal) |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
3899 assert_equal('else', g:laterVal) |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
3900 |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
3901 unlet g:initVal |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
3902 unlet g:laterVal |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
3903 delete('Xforward') |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
3904 enddef |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
3905 |
20816
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3906 def Test_source_vim9_from_legacy() |
23364
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
3907 var vim9_lines =<< trim END |
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
3908 vim9script |
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
3909 var local = 'local' |
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
3910 g:global = 'global' |
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
3911 export var exported = 'exported' |
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
3912 export def GetText(): string |
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
3913 return 'text' |
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
3914 enddef |
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
3915 END |
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
3916 writefile(vim9_lines, 'Xvim9_script.vim') |
17a0e32eefd4
patch 8.2.2225: Vim9: error when using :import in legacy script twice
Bram Moolenaar <Bram@vim.org>
parents:
23362
diff
changeset
|
3917 |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
3918 var legacy_lines =<< trim END |
20816
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3919 source Xvim9_script.vim |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3920 |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3921 call assert_false(exists('local')) |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3922 call assert_false(exists('exported')) |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3923 call assert_false(exists('s:exported')) |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3924 call assert_equal('global', global) |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3925 call assert_equal('global', g:global) |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3926 |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3927 " imported variable becomes script-local |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3928 import exported from './Xvim9_script.vim' |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3929 call assert_equal('exported', s:exported) |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3930 call assert_false(exists('exported')) |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3931 |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3932 " imported function becomes script-local |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3933 import GetText from './Xvim9_script.vim' |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3934 call assert_equal('text', s:GetText()) |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3935 call assert_false(exists('*GetText')) |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3936 END |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3937 writefile(legacy_lines, 'Xlegacy_script.vim') |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3938 |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3939 source Xlegacy_script.vim |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3940 assert_equal('global', g:global) |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
3941 unlet g:global |
20816
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3942 |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3943 delete('Xlegacy_script.vim') |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3944 delete('Xvim9_script.vim') |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
3945 enddef |
20399
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
3946 |
24279
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3947 def Test_declare_script_in_func() |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3948 var lines =<< trim END |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3949 vim9script |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3950 func Declare() |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3951 let s:local = 123 |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3952 endfunc |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3953 Declare() |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3954 assert_equal(123, local) |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3955 |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3956 var error: string |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3957 try |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3958 local = 'asdf' |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3959 catch |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3960 error = v:exception |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3961 endtry |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3962 assert_match('E1012: Type mismatch; expected number but got string', error) |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3963 |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3964 lockvar local |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3965 try |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3966 local = 999 |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3967 catch |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3968 error = v:exception |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3969 endtry |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3970 assert_match('E741: Value is locked: local', error) |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3971 END |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3972 CheckScriptSuccess(lines) |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3973 enddef |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3974 |
e3dbf2e58c6a
patch 8.2.2680: Vim9: problem defining a script variable from legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24234
diff
changeset
|
3975 |
21801
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
3976 func Test_vim9script_not_global() |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
3977 " check that items defined in Vim9 script are script-local, not global |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
3978 let vim9lines =<< trim END |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
3979 vim9script |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
3980 var name = 'local' |
21801
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
3981 func TheFunc() |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
3982 echo 'local' |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
3983 endfunc |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
3984 def DefFunc() |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
3985 echo 'local' |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
3986 enddef |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
3987 END |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
3988 call writefile(vim9lines, 'Xvim9script.vim') |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
3989 source Xvim9script.vim |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
3990 try |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
3991 echo g:var |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
3992 assert_report('did not fail') |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
3993 catch /E121:/ |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
3994 " caught |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
3995 endtry |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
3996 try |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
3997 call TheFunc() |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
3998 assert_report('did not fail') |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
3999 catch /E117:/ |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
4000 " caught |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
4001 endtry |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
4002 try |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
4003 call DefFunc() |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
4004 assert_report('did not fail') |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
4005 catch /E117:/ |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
4006 " caught |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
4007 endtry |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
4008 |
21987
c33cec63cf53
patch 8.2.1543: Vim9: test with invalid SID is skipped in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
21985
diff
changeset
|
4009 call delete('Xvim9script.vim') |
21801
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
4010 endfunc |
1344d45ca6f2
patch 8.2.1450: Vim9: no check that script-local items don't become global
Bram Moolenaar <Bram@vim.org>
parents:
21791
diff
changeset
|
4011 |
21150
951aad18b1af
patch 8.2.1126: Vim9: using :copen causes an error
Bram Moolenaar <Bram@vim.org>
parents:
21146
diff
changeset
|
4012 def Test_vim9_copen() |
951aad18b1af
patch 8.2.1126: Vim9: using :copen causes an error
Bram Moolenaar <Bram@vim.org>
parents:
21146
diff
changeset
|
4013 # this was giving an error for setting w:quickfix_title |
951aad18b1af
patch 8.2.1126: Vim9: using :copen causes an error
Bram Moolenaar <Bram@vim.org>
parents:
21146
diff
changeset
|
4014 copen |
951aad18b1af
patch 8.2.1126: Vim9: using :copen causes an error
Bram Moolenaar <Bram@vim.org>
parents:
21146
diff
changeset
|
4015 quit |
951aad18b1af
patch 8.2.1126: Vim9: using :copen causes an error
Bram Moolenaar <Bram@vim.org>
parents:
21146
diff
changeset
|
4016 enddef |
951aad18b1af
patch 8.2.1126: Vim9: using :copen causes an error
Bram Moolenaar <Bram@vim.org>
parents:
21146
diff
changeset
|
4017 |
23233
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4018 " test using an auto-loaded function and variable |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4019 def Test_vim9_autoload() |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4020 var lines =<< trim END |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4021 vim9script |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4022 def some#gettest(): string |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4023 return 'test' |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4024 enddef |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4025 g:some#name = 'name' |
24555
83877a1b66fd
patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
4026 g:some#dict = {key: 'value'} |
24077
5006d95ef82d
patch 8.2.2580: Vim9: checking vararg type may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
24051
diff
changeset
|
4027 |
5006d95ef82d
patch 8.2.2580: Vim9: checking vararg type may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
24051
diff
changeset
|
4028 def some#varargs(a1: string, ...l: list<string>): string |
5006d95ef82d
patch 8.2.2580: Vim9: checking vararg type may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
24051
diff
changeset
|
4029 return a1 .. l[0] .. l[1] |
5006d95ef82d
patch 8.2.2580: Vim9: checking vararg type may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
24051
diff
changeset
|
4030 enddef |
23233
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4031 END |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4032 |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4033 mkdir('Xdir/autoload', 'p') |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4034 writefile(lines, 'Xdir/autoload/some.vim') |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4035 var save_rtp = &rtp |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4036 exe 'set rtp^=' .. getcwd() .. '/Xdir' |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4037 |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4038 assert_equal('test', g:some#gettest()) |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4039 assert_equal('name', g:some#name) |
24555
83877a1b66fd
patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents:
24471
diff
changeset
|
4040 assert_equal('value', g:some#dict.key) |
23233
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4041 g:some#other = 'other' |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4042 assert_equal('other', g:some#other) |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4043 |
24077
5006d95ef82d
patch 8.2.2580: Vim9: checking vararg type may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
24051
diff
changeset
|
4044 assert_equal('abc', some#varargs('a', 'b', 'c')) |
5006d95ef82d
patch 8.2.2580: Vim9: checking vararg type may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
24051
diff
changeset
|
4045 |
23237
033b2a97d59b
patch 8.2.2164: Vim9: autoload function doesn't work in uppercased script
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
4046 # upper case script name works |
033b2a97d59b
patch 8.2.2164: Vim9: autoload function doesn't work in uppercased script
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
4047 lines =<< trim END |
033b2a97d59b
patch 8.2.2164: Vim9: autoload function doesn't work in uppercased script
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
4048 vim9script |
033b2a97d59b
patch 8.2.2164: Vim9: autoload function doesn't work in uppercased script
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
4049 def Other#getOther(): string |
033b2a97d59b
patch 8.2.2164: Vim9: autoload function doesn't work in uppercased script
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
4050 return 'other' |
033b2a97d59b
patch 8.2.2164: Vim9: autoload function doesn't work in uppercased script
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
4051 enddef |
033b2a97d59b
patch 8.2.2164: Vim9: autoload function doesn't work in uppercased script
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
4052 END |
033b2a97d59b
patch 8.2.2164: Vim9: autoload function doesn't work in uppercased script
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
4053 writefile(lines, 'Xdir/autoload/Other.vim') |
033b2a97d59b
patch 8.2.2164: Vim9: autoload function doesn't work in uppercased script
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
4054 assert_equal('other', g:Other#getOther()) |
033b2a97d59b
patch 8.2.2164: Vim9: autoload function doesn't work in uppercased script
Bram Moolenaar <Bram@vim.org>
parents:
23233
diff
changeset
|
4055 |
23233
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4056 delete('Xdir', 'rf') |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4057 &rtp = save_rtp |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4058 enddef |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4059 |
26430
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4060 " test disassembling an auto-loaded function starting with "debug" |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4061 def Test_vim9_autoload_disass() |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4062 mkdir('Xdir/autoload', 'p') |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4063 var save_rtp = &rtp |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4064 exe 'set rtp^=' .. getcwd() .. '/Xdir' |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4065 |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4066 var lines =<< trim END |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4067 vim9script |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4068 def debugit#test(): string |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4069 return 'debug' |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4070 enddef |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4071 END |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4072 writefile(lines, 'Xdir/autoload/debugit.vim') |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4073 |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4074 lines =<< trim END |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4075 vim9script |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4076 def profileit#test(): string |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4077 return 'profile' |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4078 enddef |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4079 END |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4080 writefile(lines, 'Xdir/autoload/profileit.vim') |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4081 |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4082 lines =<< trim END |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4083 vim9script |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4084 assert_equal('debug', debugit#test()) |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4085 disass debugit#test |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4086 assert_equal('profile', profileit#test()) |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4087 disass profileit#test |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4088 END |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4089 CheckScriptSuccess(lines) |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4090 |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4091 delete('Xdir', 'rf') |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4092 &rtp = save_rtp |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4093 enddef |
42471d3ac079
patch 8.2.3746: cannot disassemble function starting with "debug" or "profile"
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
4094 |
21485
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
4095 " test using a vim9script that is auto-loaded from an autocmd |
23233
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4096 def Test_vim9_aucmd_autoload() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
4097 var lines =<< trim END |
21485
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
4098 vim9script |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
4099 def foo#test() |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
4100 echomsg getreg('"') |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
4101 enddef |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
4102 END |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
4103 |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
4104 mkdir('Xdir/autoload', 'p') |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
4105 writefile(lines, 'Xdir/autoload/foo.vim') |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
4106 var save_rtp = &rtp |
21485
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
4107 exe 'set rtp^=' .. getcwd() .. '/Xdir' |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
4108 augroup test |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
4109 autocmd TextYankPost * call foo#test() |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
4110 augroup END |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
4111 |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
4112 normal Y |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
4113 |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
4114 augroup test |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
4115 autocmd! |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
4116 augroup END |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
4117 delete('Xdir', 'rf') |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
4118 &rtp = save_rtp |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
4119 enddef |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
4120 |
22310
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4121 " This was causing a crash because suppress_errthrow wasn't reset. |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4122 def Test_vim9_autoload_error() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
4123 var lines =<< trim END |
22310
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4124 vim9script |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4125 def crash#func() |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4126 try |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4127 for x in List() |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4128 endfor |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4129 catch |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4130 endtry |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4131 g:ok = true |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4132 enddef |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4133 fu List() |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4134 invalid |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4135 endfu |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4136 try |
23571
b02ac00aacbf
patch 8.2.2328: some test files may not be deleted
Bram Moolenaar <Bram@vim.org>
parents:
23440
diff
changeset
|
4137 alsoinvalid |
22310
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4138 catch /wontmatch/ |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4139 endtry |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4140 END |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4141 call mkdir('Xruntime/autoload', 'p') |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4142 call writefile(lines, 'Xruntime/autoload/crash.vim') |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4143 |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4144 # run in a separate Vim to avoid the side effects of assert_fails() |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4145 lines =<< trim END |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4146 exe 'set rtp^=' .. getcwd() .. '/Xruntime' |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4147 call crash#func() |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4148 call writefile(['ok'], 'Xdidit') |
22381
6fe9536694ff
patch 8.2.1739: Vim9: crash when compiling a manually defined function
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
4149 qall! |
22310
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4150 END |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4151 writefile(lines, 'Xscript') |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4152 RunVim([], [], '-S Xscript') |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4153 assert_equal(['ok'], readfile('Xdidit')) |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4154 |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4155 delete('Xdidit') |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4156 delete('Xscript') |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4157 delete('Xruntime', 'rf') |
23233
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4158 |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4159 lines =<< trim END |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4160 vim9script |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4161 var foo#bar = 'asdf' |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4162 END |
657216220293
patch 8.2.2162: Vim9: Cannot load or store autoload variables
Bram Moolenaar <Bram@vim.org>
parents:
23197
diff
changeset
|
4163 CheckScriptFailure(lines, 'E461: Illegal variable name: foo#bar', 2) |
22310
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4164 enddef |
74d0a7a30583
patch 8.2.1704: Vim9: crash in for loop when autoload script has an error
Bram Moolenaar <Bram@vim.org>
parents:
22302
diff
changeset
|
4165 |
21907
f4e21796f47d
patch 8.2.1503: Vim9: error for autocmd defined in :def in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
21905
diff
changeset
|
4166 def Test_script_var_in_autocmd() |
f4e21796f47d
patch 8.2.1503: Vim9: error for autocmd defined in :def in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
21905
diff
changeset
|
4167 # using a script variable from an autocommand, defined in a :def function in a |
f4e21796f47d
patch 8.2.1503: Vim9: error for autocmd defined in :def in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
21905
diff
changeset
|
4168 # legacy Vim script, cannot check the variable type. |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
4169 var lines =<< trim END |
21907
f4e21796f47d
patch 8.2.1503: Vim9: error for autocmd defined in :def in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
21905
diff
changeset
|
4170 let s:counter = 1 |
f4e21796f47d
patch 8.2.1503: Vim9: error for autocmd defined in :def in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
21905
diff
changeset
|
4171 def s:Func() |
f4e21796f47d
patch 8.2.1503: Vim9: error for autocmd defined in :def in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
21905
diff
changeset
|
4172 au! CursorHold |
f4e21796f47d
patch 8.2.1503: Vim9: error for autocmd defined in :def in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
21905
diff
changeset
|
4173 au CursorHold * s:counter += 1 |
f4e21796f47d
patch 8.2.1503: Vim9: error for autocmd defined in :def in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
21905
diff
changeset
|
4174 enddef |
f4e21796f47d
patch 8.2.1503: Vim9: error for autocmd defined in :def in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
21905
diff
changeset
|
4175 call s:Func() |
f4e21796f47d
patch 8.2.1503: Vim9: error for autocmd defined in :def in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
21905
diff
changeset
|
4176 doau CursorHold |
f4e21796f47d
patch 8.2.1503: Vim9: error for autocmd defined in :def in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
21905
diff
changeset
|
4177 call assert_equal(2, s:counter) |
f4e21796f47d
patch 8.2.1503: Vim9: error for autocmd defined in :def in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
21905
diff
changeset
|
4178 au! CursorHold |
f4e21796f47d
patch 8.2.1503: Vim9: error for autocmd defined in :def in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
21905
diff
changeset
|
4179 END |
f4e21796f47d
patch 8.2.1503: Vim9: error for autocmd defined in :def in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
21905
diff
changeset
|
4180 CheckScriptSuccess(lines) |
f4e21796f47d
patch 8.2.1503: Vim9: error for autocmd defined in :def in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
21905
diff
changeset
|
4181 enddef |
f4e21796f47d
patch 8.2.1503: Vim9: error for autocmd defined in :def in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
21905
diff
changeset
|
4182 |
25260
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4183 def Test_error_in_autoload_script() |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4184 var save_rtp = &rtp |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4185 var dir = getcwd() .. '/Xruntime' |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4186 &rtp = dir |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4187 mkdir(dir .. '/autoload', 'p') |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4188 |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4189 var lines =<< trim END |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4190 vim9script noclear |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4191 def script#autoloaded() |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4192 enddef |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4193 def Broken() |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4194 var x: any = '' |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4195 eval x != 0 |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4196 enddef |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4197 Broken() |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4198 END |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4199 writefile(lines, dir .. '/autoload/script.vim') |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4200 |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4201 lines =<< trim END |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4202 vim9script |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4203 def CallAutoloaded() |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4204 script#autoloaded() |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4205 enddef |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4206 |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4207 function Legacy() |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4208 try |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4209 call s:CallAutoloaded() |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4210 catch |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4211 call assert_match('E1030: Using a String as a Number', v:exception) |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4212 endtry |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4213 endfunction |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4214 |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4215 Legacy() |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4216 END |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4217 CheckScriptSuccess(lines) |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4218 |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4219 &rtp = save_rtp |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4220 delete(dir, 'rf') |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4221 enddef |
a60895011da9
patch 8.2.3166: Vim9: nested autoload call error overruled by "Unknown error"
Bram Moolenaar <Bram@vim.org>
parents:
25230
diff
changeset
|
4222 |
21707
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4223 def Test_cmdline_win() |
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4224 # if the Vim syntax highlighting uses Vim9 constructs they can be used from |
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4225 # the command line window. |
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4226 mkdir('rtp/syntax', 'p') |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
4227 var export_lines =<< trim END |
21707
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4228 vim9script |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
4229 export var That = 'yes' |
21707
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4230 END |
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4231 writefile(export_lines, 'rtp/syntax/Xexport.vim') |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
4232 var import_lines =<< trim END |
21707
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4233 vim9script |
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4234 import That from './Xexport.vim' |
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4235 END |
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4236 writefile(import_lines, 'rtp/syntax/vim.vim') |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
4237 var save_rtp = &rtp |
21707
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4238 &rtp = getcwd() .. '/rtp' .. ',' .. &rtp |
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4239 syntax on |
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4240 augroup CmdWin |
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4241 autocmd CmdwinEnter * g:got_there = 'yes' |
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4242 augroup END |
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4243 # this will open and also close the cmdline window |
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4244 feedkeys('q:', 'xt') |
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4245 assert_equal('yes', g:got_there) |
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4246 |
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4247 augroup CmdWin |
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4248 au! |
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4249 augroup END |
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4250 &rtp = save_rtp |
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4251 delete('rtp', 'rf') |
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4252 enddef |
8e224527391e
patch 8.2.1403: Vim9: Vim highlighting may fail in cmdline window
Bram Moolenaar <Bram@vim.org>
parents:
21701
diff
changeset
|
4253 |
21979
a98211c3e14e
patch 8.2.1539: using invalid script ID causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
21957
diff
changeset
|
4254 def Test_invalid_sid() |
a98211c3e14e
patch 8.2.1539: using invalid script ID causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
21957
diff
changeset
|
4255 assert_fails('func <SNR>1234_func', 'E123:') |
21987
c33cec63cf53
patch 8.2.1543: Vim9: test with invalid SID is skipped in the GUI
Bram Moolenaar <Bram@vim.org>
parents:
21985
diff
changeset
|
4256 |
22381
6fe9536694ff
patch 8.2.1739: Vim9: crash when compiling a manually defined function
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
4257 if RunVim([], ['wq! Xdidit'], '+"func <SNR>1_func"') |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
4258 assert_equal([], readfile('Xdidit')) |
21979
a98211c3e14e
patch 8.2.1539: using invalid script ID causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
21957
diff
changeset
|
4259 endif |
a98211c3e14e
patch 8.2.1539: using invalid script ID causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
21957
diff
changeset
|
4260 delete('Xdidit') |
a98211c3e14e
patch 8.2.1539: using invalid script ID causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
21957
diff
changeset
|
4261 enddef |
a98211c3e14e
patch 8.2.1539: using invalid script ID causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
21957
diff
changeset
|
4262 |
23152
1c94e4c9db00
patch 8.2.2122: Vim9: crash when sourcing vim9script early
Bram Moolenaar <Bram@vim.org>
parents:
23106
diff
changeset
|
4263 def Test_restoring_cpo() |
1c94e4c9db00
patch 8.2.2122: Vim9: crash when sourcing vim9script early
Bram Moolenaar <Bram@vim.org>
parents:
23106
diff
changeset
|
4264 writefile(['vim9script', 'set nocp'], 'Xsourced') |
1c94e4c9db00
patch 8.2.2122: Vim9: crash when sourcing vim9script early
Bram Moolenaar <Bram@vim.org>
parents:
23106
diff
changeset
|
4265 writefile(['call writefile(["done"], "Xdone")', 'quit!'], 'Xclose') |
1c94e4c9db00
patch 8.2.2122: Vim9: crash when sourcing vim9script early
Bram Moolenaar <Bram@vim.org>
parents:
23106
diff
changeset
|
4266 if RunVim([], [], '-u NONE +"set cpo+=a" -S Xsourced -S Xclose') |
1c94e4c9db00
patch 8.2.2122: Vim9: crash when sourcing vim9script early
Bram Moolenaar <Bram@vim.org>
parents:
23106
diff
changeset
|
4267 assert_equal(['done'], readfile('Xdone')) |
1c94e4c9db00
patch 8.2.2122: Vim9: crash when sourcing vim9script early
Bram Moolenaar <Bram@vim.org>
parents:
23106
diff
changeset
|
4268 endif |
1c94e4c9db00
patch 8.2.2122: Vim9: crash when sourcing vim9script early
Bram Moolenaar <Bram@vim.org>
parents:
23106
diff
changeset
|
4269 delete('Xsourced') |
1c94e4c9db00
patch 8.2.2122: Vim9: crash when sourcing vim9script early
Bram Moolenaar <Bram@vim.org>
parents:
23106
diff
changeset
|
4270 delete('Xclose') |
23247
f2d05fb28e54
patch 8.2.2169: Vim9: test leaves file behind
Bram Moolenaar <Bram@vim.org>
parents:
23237
diff
changeset
|
4271 delete('Xdone') |
23886
eef0cffbdb94
patch 8.2.2485: when sourcing a script again the script version isn't reset
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
4272 |
eef0cffbdb94
patch 8.2.2485: when sourcing a script again the script version isn't reset
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
4273 writefile(['vim9script'], 'XanotherScript') |
eef0cffbdb94
patch 8.2.2485: when sourcing a script again the script version isn't reset
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
4274 set cpo=aABceFsMny> |
eef0cffbdb94
patch 8.2.2485: when sourcing a script again the script version isn't reset
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
4275 edit XanotherScript |
eef0cffbdb94
patch 8.2.2485: when sourcing a script again the script version isn't reset
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
4276 so % |
eef0cffbdb94
patch 8.2.2485: when sourcing a script again the script version isn't reset
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
4277 assert_equal('aABceFsMny>', &cpo) |
eef0cffbdb94
patch 8.2.2485: when sourcing a script again the script version isn't reset
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
4278 :1del |
eef0cffbdb94
patch 8.2.2485: when sourcing a script again the script version isn't reset
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
4279 w |
eef0cffbdb94
patch 8.2.2485: when sourcing a script again the script version isn't reset
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
4280 so % |
eef0cffbdb94
patch 8.2.2485: when sourcing a script again the script version isn't reset
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
4281 assert_equal('aABceFsMny>', &cpo) |
eef0cffbdb94
patch 8.2.2485: when sourcing a script again the script version isn't reset
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
4282 |
eef0cffbdb94
patch 8.2.2485: when sourcing a script again the script version isn't reset
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
4283 delete('XanotherScript') |
eef0cffbdb94
patch 8.2.2485: when sourcing a script again the script version isn't reset
Bram Moolenaar <Bram@vim.org>
parents:
23884
diff
changeset
|
4284 set cpo&vim |
23152
1c94e4c9db00
patch 8.2.2122: Vim9: crash when sourcing vim9script early
Bram Moolenaar <Bram@vim.org>
parents:
23106
diff
changeset
|
4285 enddef |
1c94e4c9db00
patch 8.2.2122: Vim9: crash when sourcing vim9script early
Bram Moolenaar <Bram@vim.org>
parents:
23106
diff
changeset
|
4286 |
24081
7d28bac98927
patch 8.2.2582: Vim9: screendump test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4287 " Use :function so we can use Check commands |
7d28bac98927
patch 8.2.2582: Vim9: screendump test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4288 func Test_no_redraw_when_restoring_cpo() |
24079
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
24077
diff
changeset
|
4289 CheckScreendump |
24081
7d28bac98927
patch 8.2.2582: Vim9: screendump test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4290 CheckFeature timers |
7d28bac98927
patch 8.2.2582: Vim9: screendump test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4291 |
7d28bac98927
patch 8.2.2582: Vim9: screendump test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4292 let lines =<< trim END |
24079
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
24077
diff
changeset
|
4293 vim9script |
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
24077
diff
changeset
|
4294 def script#func() |
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
24077
diff
changeset
|
4295 enddef |
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
24077
diff
changeset
|
4296 END |
24081
7d28bac98927
patch 8.2.2582: Vim9: screendump test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4297 call mkdir('Xdir/autoload', 'p') |
7d28bac98927
patch 8.2.2582: Vim9: screendump test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4298 call writefile(lines, 'Xdir/autoload/script.vim') |
7d28bac98927
patch 8.2.2582: Vim9: screendump test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4299 |
7d28bac98927
patch 8.2.2582: Vim9: screendump test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4300 let lines =<< trim END |
24079
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
24077
diff
changeset
|
4301 vim9script |
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
24077
diff
changeset
|
4302 set cpo+=M |
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
24077
diff
changeset
|
4303 exe 'set rtp^=' .. getcwd() .. '/Xdir' |
24398
bed5ec739304
patch 8.2.2739: Vim9: a lambda accepts too many arguments at the script level
Bram Moolenaar <Bram@vim.org>
parents:
24295
diff
changeset
|
4304 au CmdlineEnter : ++once timer_start(0, (_) => script#func()) |
24079
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
24077
diff
changeset
|
4305 setline(1, 'some text') |
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
24077
diff
changeset
|
4306 END |
24081
7d28bac98927
patch 8.2.2582: Vim9: screendump test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4307 call writefile(lines, 'XTest_redraw_cpo') |
7d28bac98927
patch 8.2.2582: Vim9: screendump test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4308 let buf = RunVimInTerminal('-S XTest_redraw_cpo', {'rows': 6}) |
7d28bac98927
patch 8.2.2582: Vim9: screendump test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4309 call term_sendkeys(buf, "V:") |
7d28bac98927
patch 8.2.2582: Vim9: screendump test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4310 call VerifyScreenDump(buf, 'Test_vim9_no_redraw', {}) |
7d28bac98927
patch 8.2.2582: Vim9: screendump test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4311 |
7d28bac98927
patch 8.2.2582: Vim9: screendump test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4312 " clean up |
7d28bac98927
patch 8.2.2582: Vim9: screendump test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4313 call term_sendkeys(buf, "\<Esc>u") |
7d28bac98927
patch 8.2.2582: Vim9: screendump test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4314 call StopVimInTerminal(buf) |
7d28bac98927
patch 8.2.2582: Vim9: screendump test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4315 call delete('XTest_redraw_cpo') |
7d28bac98927
patch 8.2.2582: Vim9: screendump test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4316 call delete('Xdir', 'rf') |
7d28bac98927
patch 8.2.2582: Vim9: screendump test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
24079
diff
changeset
|
4317 endfunc |
24079
a9ff8368d35f
patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents:
24077
diff
changeset
|
4318 |
23152
1c94e4c9db00
patch 8.2.2122: Vim9: crash when sourcing vim9script early
Bram Moolenaar <Bram@vim.org>
parents:
23106
diff
changeset
|
4319 |
22250
dd42235ed626
patch 8.2.1674: Vim9: internal error when using variable that was not set
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
4320 def Test_unset_any_variable() |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
4321 var lines =<< trim END |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
4322 var name: any |
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
4323 assert_equal(0, name) |
22250
dd42235ed626
patch 8.2.1674: Vim9: internal error when using variable that was not set
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
4324 END |
dd42235ed626
patch 8.2.1674: Vim9: internal error when using variable that was not set
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
4325 CheckDefAndScriptSuccess(lines) |
dd42235ed626
patch 8.2.1674: Vim9: internal error when using variable that was not set
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
4326 enddef |
dd42235ed626
patch 8.2.1674: Vim9: internal error when using variable that was not set
Bram Moolenaar <Bram@vim.org>
parents:
22202
diff
changeset
|
4327 |
22387
36f13f35bd78
patch 8.2.1742: test still fails without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
22383
diff
changeset
|
4328 func Test_define_func_at_command_line() |
22383
82d92f6c756c
patch 8.2.1740: test fails without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
22381
diff
changeset
|
4329 CheckRunVimInTerminal |
82d92f6c756c
patch 8.2.1740: test fails without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
22381
diff
changeset
|
4330 |
22387
36f13f35bd78
patch 8.2.1742: test still fails without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
22383
diff
changeset
|
4331 " call indirectly to avoid compilation error for missing functions |
36f13f35bd78
patch 8.2.1742: test still fails without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
22383
diff
changeset
|
4332 call Run_Test_define_func_at_command_line() |
36f13f35bd78
patch 8.2.1742: test still fails without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
22383
diff
changeset
|
4333 endfunc |
36f13f35bd78
patch 8.2.1742: test still fails without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
22383
diff
changeset
|
4334 |
36f13f35bd78
patch 8.2.1742: test still fails without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
22383
diff
changeset
|
4335 def Run_Test_define_func_at_command_line() |
22381
6fe9536694ff
patch 8.2.1739: Vim9: crash when compiling a manually defined function
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
4336 # run in a separate Vim instance to avoid the script context |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
4337 var lines =<< trim END |
22381
6fe9536694ff
patch 8.2.1739: Vim9: crash when compiling a manually defined function
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
4338 func CheckAndQuit() |
6fe9536694ff
patch 8.2.1739: Vim9: crash when compiling a manually defined function
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
4339 call assert_fails('call Afunc()', 'E117: Unknown function: Bfunc') |
6fe9536694ff
patch 8.2.1739: Vim9: crash when compiling a manually defined function
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
4340 call writefile(['errors: ' .. string(v:errors)], 'Xdidcmd') |
6fe9536694ff
patch 8.2.1739: Vim9: crash when compiling a manually defined function
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
4341 endfunc |
6fe9536694ff
patch 8.2.1739: Vim9: crash when compiling a manually defined function
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
4342 END |
6fe9536694ff
patch 8.2.1739: Vim9: crash when compiling a manually defined function
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
4343 writefile([''], 'Xdidcmd') |
6fe9536694ff
patch 8.2.1739: Vim9: crash when compiling a manually defined function
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
4344 writefile(lines, 'XcallFunc') |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23068
diff
changeset
|
4345 var buf = RunVimInTerminal('-S XcallFunc', {rows: 6}) |
22381
6fe9536694ff
patch 8.2.1739: Vim9: crash when compiling a manually defined function
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
4346 # define Afunc() on the command line |
6fe9536694ff
patch 8.2.1739: Vim9: crash when compiling a manually defined function
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
4347 term_sendkeys(buf, ":def Afunc()\<CR>Bfunc()\<CR>enddef\<CR>") |
6fe9536694ff
patch 8.2.1739: Vim9: crash when compiling a manually defined function
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
4348 term_sendkeys(buf, ":call CheckAndQuit()\<CR>") |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23364
diff
changeset
|
4349 WaitForAssert(() => assert_equal(['errors: []'], readfile('Xdidcmd'))) |
22381
6fe9536694ff
patch 8.2.1739: Vim9: crash when compiling a manually defined function
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
4350 |
6fe9536694ff
patch 8.2.1739: Vim9: crash when compiling a manually defined function
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
4351 call StopVimInTerminal(buf) |
6fe9536694ff
patch 8.2.1739: Vim9: crash when compiling a manually defined function
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
4352 delete('XcallFunc') |
6fe9536694ff
patch 8.2.1739: Vim9: crash when compiling a manually defined function
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
4353 delete('Xdidcmd') |
6fe9536694ff
patch 8.2.1739: Vim9: crash when compiling a manually defined function
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
4354 enddef |
6fe9536694ff
patch 8.2.1739: Vim9: crash when compiling a manually defined function
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
4355 |
22551
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4356 def Test_script_var_scope() |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4357 var lines =<< trim END |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4358 vim9script |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4359 if true |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4360 if true |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4361 var one = 'one' |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4362 echo one |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4363 endif |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4364 echo one |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4365 endif |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4366 END |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4367 CheckScriptFailure(lines, 'E121:', 7) |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4368 |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4369 lines =<< trim END |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4370 vim9script |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4371 if true |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4372 if false |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4373 var one = 'one' |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4374 echo one |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4375 else |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4376 var one = 'one' |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4377 echo one |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4378 endif |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4379 echo one |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4380 endif |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4381 END |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4382 CheckScriptFailure(lines, 'E121:', 10) |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4383 |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4384 lines =<< trim END |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4385 vim9script |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4386 while true |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4387 var one = 'one' |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4388 echo one |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4389 break |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4390 endwhile |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4391 echo one |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4392 END |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4393 CheckScriptFailure(lines, 'E121:', 7) |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4394 |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4395 lines =<< trim END |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4396 vim9script |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4397 for i in range(1) |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4398 var one = 'one' |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4399 echo one |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4400 endfor |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4401 echo one |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4402 END |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4403 CheckScriptFailure(lines, 'E121:', 6) |
22555
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22551
diff
changeset
|
4404 |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22551
diff
changeset
|
4405 lines =<< trim END |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22551
diff
changeset
|
4406 vim9script |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22551
diff
changeset
|
4407 { |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22551
diff
changeset
|
4408 var one = 'one' |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22551
diff
changeset
|
4409 assert_equal('one', one) |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22551
diff
changeset
|
4410 } |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22551
diff
changeset
|
4411 assert_false(exists('one')) |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22551
diff
changeset
|
4412 assert_false(exists('s:one')) |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22551
diff
changeset
|
4413 END |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22551
diff
changeset
|
4414 CheckScriptSuccess(lines) |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22551
diff
changeset
|
4415 |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22551
diff
changeset
|
4416 lines =<< trim END |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22551
diff
changeset
|
4417 vim9script |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22551
diff
changeset
|
4418 { |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22551
diff
changeset
|
4419 var one = 'one' |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22551
diff
changeset
|
4420 echo one |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22551
diff
changeset
|
4421 } |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22551
diff
changeset
|
4422 echo one |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22551
diff
changeset
|
4423 END |
7d25264c246c
patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents:
22551
diff
changeset
|
4424 CheckScriptFailure(lines, 'E121:', 6) |
22551
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4425 enddef |
86a115a80262
patch 8.2.1824: Vim9: variables at the script level escape their scope
Bram Moolenaar <Bram@vim.org>
parents:
22529
diff
changeset
|
4426 |
22621
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22612
diff
changeset
|
4427 def Test_catch_exception_in_callback() |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22612
diff
changeset
|
4428 var lines =<< trim END |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22612
diff
changeset
|
4429 vim9script |
24400
62e978382fa0
patch 8.2.2740: Vim9: lambda with varargs doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24398
diff
changeset
|
4430 def Callback(...l: list<any>) |
22621
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22612
diff
changeset
|
4431 try |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22612
diff
changeset
|
4432 var x: string |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22612
diff
changeset
|
4433 var y: string |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22612
diff
changeset
|
4434 # this error should be caught with CHECKLEN |
26372
f5727e2603f0
patch 8.2.3717: Vim9: error for constant list size is only given at runtime
Bram Moolenaar <Bram@vim.org>
parents:
26238
diff
changeset
|
4435 var sl = [''] |
f5727e2603f0
patch 8.2.3717: Vim9: error for constant list size is only given at runtime
Bram Moolenaar <Bram@vim.org>
parents:
26238
diff
changeset
|
4436 [x, y] = sl |
22621
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22612
diff
changeset
|
4437 catch |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22612
diff
changeset
|
4438 g:caught = 'yes' |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22612
diff
changeset
|
4439 endtry |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22612
diff
changeset
|
4440 enddef |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23068
diff
changeset
|
4441 popup_menu('popup', {callback: Callback}) |
22621
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22612
diff
changeset
|
4442 feedkeys("\r", 'xt') |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22612
diff
changeset
|
4443 END |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22612
diff
changeset
|
4444 CheckScriptSuccess(lines) |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22612
diff
changeset
|
4445 |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22612
diff
changeset
|
4446 unlet g:caught |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22612
diff
changeset
|
4447 enddef |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22612
diff
changeset
|
4448 |
22810
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22732
diff
changeset
|
4449 def Test_no_unknown_error_after_error() |
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22732
diff
changeset
|
4450 if !has('unix') || !has('job') |
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22732
diff
changeset
|
4451 throw 'Skipped: not unix of missing +job feature' |
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22732
diff
changeset
|
4452 endif |
25846
8b0dad68e98a
patch 8.2.3457: MS-Windows Vim9: test executed and fails
Bram Moolenaar <Bram@vim.org>
parents:
25755
diff
changeset
|
4453 # FIXME: this check should not be needed |
8b0dad68e98a
patch 8.2.3457: MS-Windows Vim9: test executed and fails
Bram Moolenaar <Bram@vim.org>
parents:
25755
diff
changeset
|
4454 if has('win32') |
8b0dad68e98a
patch 8.2.3457: MS-Windows Vim9: test executed and fails
Bram Moolenaar <Bram@vim.org>
parents:
25755
diff
changeset
|
4455 throw 'Skipped: does not work on MS-Windows' |
8b0dad68e98a
patch 8.2.3457: MS-Windows Vim9: test executed and fails
Bram Moolenaar <Bram@vim.org>
parents:
25755
diff
changeset
|
4456 endif |
22810
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22732
diff
changeset
|
4457 var lines =<< trim END |
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22732
diff
changeset
|
4458 vim9script |
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22732
diff
changeset
|
4459 var source: list<number> |
24400
62e978382fa0
patch 8.2.2740: Vim9: lambda with varargs doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24398
diff
changeset
|
4460 def Out_cb(...l: list<any>) |
22810
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22732
diff
changeset
|
4461 eval [][0] |
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22732
diff
changeset
|
4462 enddef |
24400
62e978382fa0
patch 8.2.2740: Vim9: lambda with varargs doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24398
diff
changeset
|
4463 def Exit_cb(...l: list<any>) |
22810
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22732
diff
changeset
|
4464 sleep 1m |
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22732
diff
changeset
|
4465 source += l |
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22732
diff
changeset
|
4466 enddef |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23068
diff
changeset
|
4467 var myjob = job_start('echo burp', {out_cb: Out_cb, exit_cb: Exit_cb, mode: 'raw'}) |
23268
65fd662b434d
patch 8.2.2180: Vim9: test for error after error is flaky
Bram Moolenaar <Bram@vim.org>
parents:
23252
diff
changeset
|
4468 while job_status(myjob) == 'run' |
65fd662b434d
patch 8.2.2180: Vim9: test for error after error is flaky
Bram Moolenaar <Bram@vim.org>
parents:
23252
diff
changeset
|
4469 sleep 10m |
65fd662b434d
patch 8.2.2180: Vim9: test for error after error is flaky
Bram Moolenaar <Bram@vim.org>
parents:
23252
diff
changeset
|
4470 endwhile |
23790
e2ebd45d4db0
patch 8.2.2436: Vim9 script test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents:
23723
diff
changeset
|
4471 # wait for Exit_cb() to be called |
24418
baf4913fe21c
patch 8.2.2749: Vim9: test for error can be a bit flaky
Bram Moolenaar <Bram@vim.org>
parents:
24400
diff
changeset
|
4472 sleep 200m |
22810
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22732
diff
changeset
|
4473 END |
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22732
diff
changeset
|
4474 writefile(lines, 'Xdef') |
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22732
diff
changeset
|
4475 assert_fails('so Xdef', ['E684:', 'E1012:']) |
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22732
diff
changeset
|
4476 delete('Xdef') |
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22732
diff
changeset
|
4477 enddef |
2d05dd71aac3
patch 8.2.1953: Vim9: extra "unknown" error after other error
Bram Moolenaar <Bram@vim.org>
parents:
22732
diff
changeset
|
4478 |
23056
57b6427c18e4
patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents:
23054
diff
changeset
|
4479 def InvokeNormal() |
57b6427c18e4
patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents:
23054
diff
changeset
|
4480 exe "norm! :m+1\r" |
57b6427c18e4
patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents:
23054
diff
changeset
|
4481 enddef |
57b6427c18e4
patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents:
23054
diff
changeset
|
4482 |
57b6427c18e4
patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents:
23054
diff
changeset
|
4483 def Test_invoke_normal_in_visual_mode() |
57b6427c18e4
patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents:
23054
diff
changeset
|
4484 xnoremap <F3> <Cmd>call <SID>InvokeNormal()<CR> |
57b6427c18e4
patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents:
23054
diff
changeset
|
4485 new |
57b6427c18e4
patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents:
23054
diff
changeset
|
4486 setline(1, ['aaa', 'bbb']) |
57b6427c18e4
patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents:
23054
diff
changeset
|
4487 feedkeys("V\<F3>", 'xt') |
57b6427c18e4
patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents:
23054
diff
changeset
|
4488 assert_equal(['bbb', 'aaa'], getline(1, 2)) |
57b6427c18e4
patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents:
23054
diff
changeset
|
4489 xunmap <F3> |
57b6427c18e4
patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents:
23054
diff
changeset
|
4490 enddef |
57b6427c18e4
patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents:
23054
diff
changeset
|
4491 |
23185
055fa9db6f39
patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
23183
diff
changeset
|
4492 def Test_white_space_after_command() |
055fa9db6f39
patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
23183
diff
changeset
|
4493 var lines =<< trim END |
055fa9db6f39
patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
23183
diff
changeset
|
4494 exit_cb: Func}) |
055fa9db6f39
patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
23183
diff
changeset
|
4495 END |
055fa9db6f39
patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
23183
diff
changeset
|
4496 CheckDefAndScriptFailure(lines, 'E1144:', 1) |
23342
13572a262b15
patch 8.2.2214: ":e#" does not give a warning for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
23330
diff
changeset
|
4497 |
13572a262b15
patch 8.2.2214: ":e#" does not give a warning for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
23330
diff
changeset
|
4498 lines =<< trim END |
13572a262b15
patch 8.2.2214: ":e#" does not give a warning for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
23330
diff
changeset
|
4499 e# |
13572a262b15
patch 8.2.2214: ":e#" does not give a warning for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
23330
diff
changeset
|
4500 END |
13572a262b15
patch 8.2.2214: ":e#" does not give a warning for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
23330
diff
changeset
|
4501 CheckDefAndScriptFailure(lines, 'E1144:', 1) |
23185
055fa9db6f39
patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
23183
diff
changeset
|
4502 enddef |
055fa9db6f39
patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
23183
diff
changeset
|
4503 |
23330
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4504 def Test_script_var_gone_when_sourced_twice() |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4505 var lines =<< trim END |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4506 vim9script |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4507 if exists('g:guard') |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4508 finish |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4509 endif |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4510 g:guard = 1 |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4511 var name = 'thename' |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4512 def g:GetName(): string |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4513 return name |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4514 enddef |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4515 def g:SetName(arg: string) |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4516 name = arg |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4517 enddef |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4518 END |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4519 writefile(lines, 'XscriptTwice.vim') |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4520 so XscriptTwice.vim |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4521 assert_equal('thename', g:GetName()) |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4522 g:SetName('newname') |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4523 assert_equal('newname', g:GetName()) |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4524 so XscriptTwice.vim |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4525 assert_fails('call g:GetName()', 'E1149:') |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4526 assert_fails('call g:SetName("x")', 'E1149:') |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4527 |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4528 delfunc g:GetName |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4529 delfunc g:SetName |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4530 delete('XscriptTwice.vim') |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4531 unlet g:guard |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4532 enddef |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4533 |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4534 def Test_import_gone_when_sourced_twice() |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4535 var exportlines =<< trim END |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4536 vim9script |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4537 if exists('g:guard') |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4538 finish |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4539 endif |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4540 g:guard = 1 |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4541 export var name = 'someName' |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4542 END |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4543 writefile(exportlines, 'XexportScript.vim') |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4544 |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4545 var lines =<< trim END |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4546 vim9script |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4547 import name from './XexportScript.vim' |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4548 def g:GetName(): string |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4549 return name |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4550 enddef |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4551 END |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4552 writefile(lines, 'XscriptImport.vim') |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4553 so XscriptImport.vim |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4554 assert_equal('someName', g:GetName()) |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4555 |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4556 so XexportScript.vim |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4557 assert_fails('call g:GetName()', 'E1149:') |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4558 |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4559 delfunc g:GetName |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4560 delete('XexportScript.vim') |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4561 delete('XscriptImport.vim') |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4562 unlet g:guard |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4563 enddef |
e8eb4fd44902
patch 8.2.2208: Vim9: after reloading a script variable index may be invalid
Bram Moolenaar <Bram@vim.org>
parents:
23268
diff
changeset
|
4564 |
23978
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
4565 def Test_unsupported_commands() |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
4566 var lines =<< trim END |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
4567 ka |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
4568 END |
24699
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24679
diff
changeset
|
4569 CheckDefFailure(lines, 'E476:') |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24679
diff
changeset
|
4570 CheckScriptFailure(['vim9script'] + lines, 'E492:') |
23978
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
4571 |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
4572 lines =<< trim END |
23980
bee8c78c0c6a
patch 8.2.2532: Vim9: confusing error if :k is used with a range
Bram Moolenaar <Bram@vim.org>
parents:
23978
diff
changeset
|
4573 :1ka |
bee8c78c0c6a
patch 8.2.2532: Vim9: confusing error if :k is used with a range
Bram Moolenaar <Bram@vim.org>
parents:
23978
diff
changeset
|
4574 END |
24699
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24679
diff
changeset
|
4575 CheckDefFailure(lines, 'E476:') |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24679
diff
changeset
|
4576 CheckScriptFailure(['vim9script'] + lines, 'E492:') |
23980
bee8c78c0c6a
patch 8.2.2532: Vim9: confusing error if :k is used with a range
Bram Moolenaar <Bram@vim.org>
parents:
23978
diff
changeset
|
4577 |
bee8c78c0c6a
patch 8.2.2532: Vim9: confusing error if :k is used with a range
Bram Moolenaar <Bram@vim.org>
parents:
23978
diff
changeset
|
4578 lines =<< trim END |
23978
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
4579 t |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
4580 END |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
4581 CheckDefFailure(lines, 'E1100:') |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
4582 CheckScriptFailure(['vim9script'] + lines, 'E1100:') |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
4583 |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
4584 lines =<< trim END |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
4585 x |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
4586 END |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
4587 CheckDefFailure(lines, 'E1100:') |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
4588 CheckScriptFailure(['vim9script'] + lines, 'E1100:') |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
4589 |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
4590 lines =<< trim END |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
4591 xit |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
4592 END |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
4593 CheckDefFailure(lines, 'E1100:') |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
4594 CheckScriptFailure(['vim9script'] + lines, 'E1100:') |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
4595 enddef |
54b2aa1f0d42
patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents:
23974
diff
changeset
|
4596 |
24471
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4597 def Test_mapping_line_number() |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4598 var lines =<< trim END |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4599 vim9script |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4600 def g:FuncA() |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4601 # Some comment |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4602 FuncB(0) |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4603 enddef |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4604 # Some comment |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4605 def FuncB( |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4606 # Some comment |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4607 n: number |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4608 ) |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4609 exe 'nno ' |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4610 # Some comment |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4611 .. '<F3> a' |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4612 .. 'b' |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4613 .. 'c' |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4614 enddef |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4615 END |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4616 CheckScriptSuccess(lines) |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4617 var res = execute('verbose nmap <F3>') |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4618 assert_match('No mapping found', res) |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4619 |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4620 g:FuncA() |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4621 res = execute('verbose nmap <F3>') |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4622 assert_match(' <F3> .* abc.*Last set from .*XScriptSuccess\d\+ line 11', res) |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4623 |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4624 nunmap <F3> |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4625 delfunc g:FuncA |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4626 enddef |
baf75c8e1b7b
patch 8.2.2775: Vim9: wrong line number used for some commands
Bram Moolenaar <Bram@vim.org>
parents:
24469
diff
changeset
|
4627 |
25176
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4628 def Test_option_set() |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4629 # legacy script allows for white space |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4630 var lines =<< trim END |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4631 set foldlevel =11 |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4632 call assert_equal(11, &foldlevel) |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4633 END |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4634 CheckScriptSuccess(lines) |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4635 |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4636 set foldlevel |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4637 set foldlevel=12 |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4638 assert_equal(12, &foldlevel) |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4639 set foldlevel+=2 |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4640 assert_equal(14, &foldlevel) |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4641 set foldlevel-=3 |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4642 assert_equal(11, &foldlevel) |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4643 |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4644 lines =<< trim END |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4645 set foldlevel =1 |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4646 END |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4647 CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: =1') |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4648 |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4649 lines =<< trim END |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4650 set foldlevel +=1 |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4651 END |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4652 CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: +=1') |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4653 |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4654 lines =<< trim END |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4655 set foldlevel ^=1 |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4656 END |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4657 CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: ^=1') |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4658 |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4659 lines =<< trim END |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4660 set foldlevel -=1 |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4661 END |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4662 CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: -=1') |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4663 |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4664 set foldlevel& |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4665 enddef |
af3d0198faad
patch 8.2.3124: Vim9: no error for white space between option and "=9"
Bram Moolenaar <Bram@vim.org>
parents:
25174
diff
changeset
|
4666 |
24968
d81a5c3a3aa6
patch 8.2.3021: spaces allowed between option name and "!", "?", etc.
Bram Moolenaar <Bram@vim.org>
parents:
24958
diff
changeset
|
4667 def Test_option_modifier() |
25174
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25164
diff
changeset
|
4668 # legacy script allows for white space |
24968
d81a5c3a3aa6
patch 8.2.3021: spaces allowed between option name and "!", "?", etc.
Bram Moolenaar <Bram@vim.org>
parents:
24958
diff
changeset
|
4669 var lines =<< trim END |
d81a5c3a3aa6
patch 8.2.3021: spaces allowed between option name and "!", "?", etc.
Bram Moolenaar <Bram@vim.org>
parents:
24958
diff
changeset
|
4670 set hlsearch & hlsearch ! |
d81a5c3a3aa6
patch 8.2.3021: spaces allowed between option name and "!", "?", etc.
Bram Moolenaar <Bram@vim.org>
parents:
24958
diff
changeset
|
4671 call assert_equal(1, &hlsearch) |
d81a5c3a3aa6
patch 8.2.3021: spaces allowed between option name and "!", "?", etc.
Bram Moolenaar <Bram@vim.org>
parents:
24958
diff
changeset
|
4672 END |
d81a5c3a3aa6
patch 8.2.3021: spaces allowed between option name and "!", "?", etc.
Bram Moolenaar <Bram@vim.org>
parents:
24958
diff
changeset
|
4673 CheckScriptSuccess(lines) |
d81a5c3a3aa6
patch 8.2.3021: spaces allowed between option name and "!", "?", etc.
Bram Moolenaar <Bram@vim.org>
parents:
24958
diff
changeset
|
4674 |
25174
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25164
diff
changeset
|
4675 set hlsearch |
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25164
diff
changeset
|
4676 set hlsearch! |
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25164
diff
changeset
|
4677 assert_equal(false, &hlsearch) |
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25164
diff
changeset
|
4678 |
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25164
diff
changeset
|
4679 set hlsearch |
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25164
diff
changeset
|
4680 set hlsearch& |
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25164
diff
changeset
|
4681 assert_equal(false, &hlsearch) |
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25164
diff
changeset
|
4682 |
24968
d81a5c3a3aa6
patch 8.2.3021: spaces allowed between option name and "!", "?", etc.
Bram Moolenaar <Bram@vim.org>
parents:
24958
diff
changeset
|
4683 lines =<< trim END |
d81a5c3a3aa6
patch 8.2.3021: spaces allowed between option name and "!", "?", etc.
Bram Moolenaar <Bram@vim.org>
parents:
24958
diff
changeset
|
4684 set hlsearch & |
d81a5c3a3aa6
patch 8.2.3021: spaces allowed between option name and "!", "?", etc.
Bram Moolenaar <Bram@vim.org>
parents:
24958
diff
changeset
|
4685 END |
25174
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25164
diff
changeset
|
4686 CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: &') |
24968
d81a5c3a3aa6
patch 8.2.3021: spaces allowed between option name and "!", "?", etc.
Bram Moolenaar <Bram@vim.org>
parents:
24958
diff
changeset
|
4687 |
d81a5c3a3aa6
patch 8.2.3021: spaces allowed between option name and "!", "?", etc.
Bram Moolenaar <Bram@vim.org>
parents:
24958
diff
changeset
|
4688 lines =<< trim END |
25174
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25164
diff
changeset
|
4689 set hlsearch ! |
24968
d81a5c3a3aa6
patch 8.2.3021: spaces allowed between option name and "!", "?", etc.
Bram Moolenaar <Bram@vim.org>
parents:
24958
diff
changeset
|
4690 END |
25174
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25164
diff
changeset
|
4691 CheckDefExecAndScriptFailure(lines, 'E1205: No white space allowed between option and: !') |
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25164
diff
changeset
|
4692 |
b32c83317492
patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents:
25164
diff
changeset
|
4693 set hlsearch& |
24968
d81a5c3a3aa6
patch 8.2.3021: spaces allowed between option name and "!", "?", etc.
Bram Moolenaar <Bram@vim.org>
parents:
24958
diff
changeset
|
4694 enddef |
d81a5c3a3aa6
patch 8.2.3021: spaces allowed between option name and "!", "?", etc.
Bram Moolenaar <Bram@vim.org>
parents:
24958
diff
changeset
|
4695 |
25220
89b39ce243e2
patch 8.2.3146: Vim9: line number wrong for :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
25218
diff
changeset
|
4696 " This must be called last, it may cause following :def functions to fail |
89b39ce243e2
patch 8.2.3146: Vim9: line number wrong for :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
25218
diff
changeset
|
4697 def Test_xxx_echoerr_line_number() |
89b39ce243e2
patch 8.2.3146: Vim9: line number wrong for :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
25218
diff
changeset
|
4698 var lines =<< trim END |
89b39ce243e2
patch 8.2.3146: Vim9: line number wrong for :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
25218
diff
changeset
|
4699 echoerr 'some' |
89b39ce243e2
patch 8.2.3146: Vim9: line number wrong for :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
25218
diff
changeset
|
4700 .. ' error' |
89b39ce243e2
patch 8.2.3146: Vim9: line number wrong for :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
25218
diff
changeset
|
4701 .. ' continued' |
89b39ce243e2
patch 8.2.3146: Vim9: line number wrong for :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
25218
diff
changeset
|
4702 END |
89b39ce243e2
patch 8.2.3146: Vim9: line number wrong for :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
25218
diff
changeset
|
4703 CheckDefExecAndScriptFailure(lines, 'some error continued', 1) |
89b39ce243e2
patch 8.2.3146: Vim9: line number wrong for :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
25218
diff
changeset
|
4704 enddef |
89b39ce243e2
patch 8.2.3146: Vim9: line number wrong for :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
25218
diff
changeset
|
4705 |
26496
8861ece40b4b
patch 8.2.3778: lambda debug test fails in some configurations
Bram Moolenaar <Bram@vim.org>
parents:
26490
diff
changeset
|
4706 func Test_debug_with_lambda() |
26490
cd452f46085e
patch 8.2.3775: Vim9: lambda compiled without outer context when debugging
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
4707 CheckRunVimInTerminal |
cd452f46085e
patch 8.2.3775: Vim9: lambda compiled without outer context when debugging
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
4708 |
26496
8861ece40b4b
patch 8.2.3778: lambda debug test fails in some configurations
Bram Moolenaar <Bram@vim.org>
parents:
26490
diff
changeset
|
4709 " call indirectly to avoid compilation error for missing functions |
8861ece40b4b
patch 8.2.3778: lambda debug test fails in some configurations
Bram Moolenaar <Bram@vim.org>
parents:
26490
diff
changeset
|
4710 call Run_Test_debug_with_lambda() |
8861ece40b4b
patch 8.2.3778: lambda debug test fails in some configurations
Bram Moolenaar <Bram@vim.org>
parents:
26490
diff
changeset
|
4711 endfunc |
8861ece40b4b
patch 8.2.3778: lambda debug test fails in some configurations
Bram Moolenaar <Bram@vim.org>
parents:
26490
diff
changeset
|
4712 |
8861ece40b4b
patch 8.2.3778: lambda debug test fails in some configurations
Bram Moolenaar <Bram@vim.org>
parents:
26490
diff
changeset
|
4713 def Run_Test_debug_with_lambda() |
26490
cd452f46085e
patch 8.2.3775: Vim9: lambda compiled without outer context when debugging
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
4714 var lines =<< trim END |
cd452f46085e
patch 8.2.3775: Vim9: lambda compiled without outer context when debugging
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
4715 vim9script |
cd452f46085e
patch 8.2.3775: Vim9: lambda compiled without outer context when debugging
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
4716 def Func() |
cd452f46085e
patch 8.2.3775: Vim9: lambda compiled without outer context when debugging
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
4717 var n = 0 |
cd452f46085e
patch 8.2.3775: Vim9: lambda compiled without outer context when debugging
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
4718 echo [0]->filter((_, v) => v == n) |
cd452f46085e
patch 8.2.3775: Vim9: lambda compiled without outer context when debugging
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
4719 enddef |
cd452f46085e
patch 8.2.3775: Vim9: lambda compiled without outer context when debugging
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
4720 breakadd func Func |
cd452f46085e
patch 8.2.3775: Vim9: lambda compiled without outer context when debugging
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
4721 Func() |
cd452f46085e
patch 8.2.3775: Vim9: lambda compiled without outer context when debugging
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
4722 END |
cd452f46085e
patch 8.2.3775: Vim9: lambda compiled without outer context when debugging
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
4723 writefile(lines, 'XdebugFunc') |
cd452f46085e
patch 8.2.3775: Vim9: lambda compiled without outer context when debugging
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
4724 var buf = RunVimInTerminal('-S XdebugFunc', {rows: 6, wait_for_ruler: 0}) |
cd452f46085e
patch 8.2.3775: Vim9: lambda compiled without outer context when debugging
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
4725 WaitForAssert(() => assert_match('^>', term_getline(buf, 6))) |
cd452f46085e
patch 8.2.3775: Vim9: lambda compiled without outer context when debugging
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
4726 |
cd452f46085e
patch 8.2.3775: Vim9: lambda compiled without outer context when debugging
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
4727 term_sendkeys(buf, "cont\<CR>") |
cd452f46085e
patch 8.2.3775: Vim9: lambda compiled without outer context when debugging
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
4728 WaitForAssert(() => assert_match('\[0\]', term_getline(buf, 5))) |
cd452f46085e
patch 8.2.3775: Vim9: lambda compiled without outer context when debugging
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
4729 |
cd452f46085e
patch 8.2.3775: Vim9: lambda compiled without outer context when debugging
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
4730 StopVimInTerminal(buf) |
cd452f46085e
patch 8.2.3775: Vim9: lambda compiled without outer context when debugging
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
4731 delete('XdebugFunc') |
cd452f46085e
patch 8.2.3775: Vim9: lambda compiled without outer context when debugging
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
4732 enddef |
cd452f46085e
patch 8.2.3775: Vim9: lambda compiled without outer context when debugging
Bram Moolenaar <Bram@vim.org>
parents:
26430
diff
changeset
|
4733 |
26698
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4734 func Test_debug_running_out_of_lines() |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4735 CheckRunVimInTerminal |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4736 |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4737 " call indirectly to avoid compilation error for missing functions |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4738 call Run_Test_debug_running_out_of_lines() |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4739 endfunc |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4740 |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4741 def Run_Test_debug_running_out_of_lines() |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4742 var lines =<< trim END |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4743 vim9script |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4744 def Crash() |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4745 # |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4746 # |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4747 # |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4748 # |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4749 # |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4750 # |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4751 # |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4752 if true |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4753 # |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4754 endif |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4755 enddef |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4756 breakadd func Crash |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4757 Crash() |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4758 END |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4759 writefile(lines, 'XdebugFunc') |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4760 var buf = RunVimInTerminal('-S XdebugFunc', {rows: 6, wait_for_ruler: 0}) |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4761 WaitForAssert(() => assert_match('^>', term_getline(buf, 6))) |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4762 |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4763 term_sendkeys(buf, "next\<CR>") |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4764 TermWait(buf) |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4765 WaitForAssert(() => assert_match('^>', term_getline(buf, 6))) |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4766 |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4767 term_sendkeys(buf, "cont\<CR>") |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4768 TermWait(buf) |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4769 |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4770 StopVimInTerminal(buf) |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4771 delete('XdebugFunc') |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4772 enddef |
254fffd11fda
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Bram Moolenaar <Bram@vim.org>
parents:
26660
diff
changeset
|
4773 |
25222
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25220
diff
changeset
|
4774 def ProfiledWithLambda() |
25214
218df177cff8
patch 8.2.3143: Vim9: wrong context if lambda called from profiled function
Bram Moolenaar <Bram@vim.org>
parents:
25202
diff
changeset
|
4775 var n = 3 |
218df177cff8
patch 8.2.3143: Vim9: wrong context if lambda called from profiled function
Bram Moolenaar <Bram@vim.org>
parents:
25202
diff
changeset
|
4776 echo [[1, 2], [3, 4]]->filter((_, l) => l[0] == n) |
218df177cff8
patch 8.2.3143: Vim9: wrong context if lambda called from profiled function
Bram Moolenaar <Bram@vim.org>
parents:
25202
diff
changeset
|
4777 enddef |
218df177cff8
patch 8.2.3143: Vim9: wrong context if lambda called from profiled function
Bram Moolenaar <Bram@vim.org>
parents:
25202
diff
changeset
|
4778 |
25222
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25220
diff
changeset
|
4779 def ProfiledNested() |
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25220
diff
changeset
|
4780 var x = 0 |
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25220
diff
changeset
|
4781 def Nested(): any |
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25220
diff
changeset
|
4782 return x |
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25220
diff
changeset
|
4783 enddef |
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25220
diff
changeset
|
4784 Nested() |
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25220
diff
changeset
|
4785 enddef |
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25220
diff
changeset
|
4786 |
25230
658dfd6be868
patch 8.2.3151: Vim9: profiling fails if nested function is also profiled
Bram Moolenaar <Bram@vim.org>
parents:
25222
diff
changeset
|
4787 def ProfiledNestedProfiled() |
658dfd6be868
patch 8.2.3151: Vim9: profiling fails if nested function is also profiled
Bram Moolenaar <Bram@vim.org>
parents:
25222
diff
changeset
|
4788 var x = 0 |
658dfd6be868
patch 8.2.3151: Vim9: profiling fails if nested function is also profiled
Bram Moolenaar <Bram@vim.org>
parents:
25222
diff
changeset
|
4789 def Nested(): any |
658dfd6be868
patch 8.2.3151: Vim9: profiling fails if nested function is also profiled
Bram Moolenaar <Bram@vim.org>
parents:
25222
diff
changeset
|
4790 return x |
658dfd6be868
patch 8.2.3151: Vim9: profiling fails if nested function is also profiled
Bram Moolenaar <Bram@vim.org>
parents:
25222
diff
changeset
|
4791 enddef |
658dfd6be868
patch 8.2.3151: Vim9: profiling fails if nested function is also profiled
Bram Moolenaar <Bram@vim.org>
parents:
25222
diff
changeset
|
4792 Nested() |
658dfd6be868
patch 8.2.3151: Vim9: profiling fails if nested function is also profiled
Bram Moolenaar <Bram@vim.org>
parents:
25222
diff
changeset
|
4793 enddef |
658dfd6be868
patch 8.2.3151: Vim9: profiling fails if nested function is also profiled
Bram Moolenaar <Bram@vim.org>
parents:
25222
diff
changeset
|
4794 |
26211
485c7c4afeb7
patch 8.2.3637: typos in test files
Bram Moolenaar <Bram@vim.org>
parents:
26048
diff
changeset
|
4795 " Execute this near the end, profiling doesn't stop until Vim exits. |
25214
218df177cff8
patch 8.2.3143: Vim9: wrong context if lambda called from profiled function
Bram Moolenaar <Bram@vim.org>
parents:
25202
diff
changeset
|
4796 " This only tests that it works, not the profiling output. |
218df177cff8
patch 8.2.3143: Vim9: wrong context if lambda called from profiled function
Bram Moolenaar <Bram@vim.org>
parents:
25202
diff
changeset
|
4797 def Test_xx_profile_with_lambda() |
25218
645c7963a586
patch 8.2.3145: Vim9: profile test fails without profile feature
Bram Moolenaar <Bram@vim.org>
parents:
25214
diff
changeset
|
4798 CheckFeature profile |
645c7963a586
patch 8.2.3145: Vim9: profile test fails without profile feature
Bram Moolenaar <Bram@vim.org>
parents:
25214
diff
changeset
|
4799 |
25214
218df177cff8
patch 8.2.3143: Vim9: wrong context if lambda called from profiled function
Bram Moolenaar <Bram@vim.org>
parents:
25202
diff
changeset
|
4800 profile start Xprofile.log |
25222
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25220
diff
changeset
|
4801 profile func ProfiledWithLambda |
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25220
diff
changeset
|
4802 ProfiledWithLambda() |
25230
658dfd6be868
patch 8.2.3151: Vim9: profiling fails if nested function is also profiled
Bram Moolenaar <Bram@vim.org>
parents:
25222
diff
changeset
|
4803 |
25222
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25220
diff
changeset
|
4804 profile func ProfiledNested |
fbb530e081ca
patch 8.2.3147: Vim9: profiling does not work with a nested function
Bram Moolenaar <Bram@vim.org>
parents:
25220
diff
changeset
|
4805 ProfiledNested() |
25230
658dfd6be868
patch 8.2.3151: Vim9: profiling fails if nested function is also profiled
Bram Moolenaar <Bram@vim.org>
parents:
25222
diff
changeset
|
4806 |
658dfd6be868
patch 8.2.3151: Vim9: profiling fails if nested function is also profiled
Bram Moolenaar <Bram@vim.org>
parents:
25222
diff
changeset
|
4807 # Also profile the nested function. Use a different function, although the |
658dfd6be868
patch 8.2.3151: Vim9: profiling fails if nested function is also profiled
Bram Moolenaar <Bram@vim.org>
parents:
25222
diff
changeset
|
4808 # contents is the same, to make sure it was not already compiled. |
658dfd6be868
patch 8.2.3151: Vim9: profiling fails if nested function is also profiled
Bram Moolenaar <Bram@vim.org>
parents:
25222
diff
changeset
|
4809 profile func * |
658dfd6be868
patch 8.2.3151: Vim9: profiling fails if nested function is also profiled
Bram Moolenaar <Bram@vim.org>
parents:
25222
diff
changeset
|
4810 ProfiledNestedProfiled() |
658dfd6be868
patch 8.2.3151: Vim9: profiling fails if nested function is also profiled
Bram Moolenaar <Bram@vim.org>
parents:
25222
diff
changeset
|
4811 |
658dfd6be868
patch 8.2.3151: Vim9: profiling fails if nested function is also profiled
Bram Moolenaar <Bram@vim.org>
parents:
25222
diff
changeset
|
4812 profdel func * |
658dfd6be868
patch 8.2.3151: Vim9: profiling fails if nested function is also profiled
Bram Moolenaar <Bram@vim.org>
parents:
25222
diff
changeset
|
4813 profile pause |
25214
218df177cff8
patch 8.2.3143: Vim9: wrong context if lambda called from profiled function
Bram Moolenaar <Bram@vim.org>
parents:
25202
diff
changeset
|
4814 enddef |
218df177cff8
patch 8.2.3143: Vim9: wrong context if lambda called from profiled function
Bram Moolenaar <Bram@vim.org>
parents:
25202
diff
changeset
|
4815 |
19894
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4816 " Keep this last, it messes up highlighting. |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4817 def Test_substitute_cmd() |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4818 new |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4819 setline(1, 'something') |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4820 :substitute(some(other( |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4821 assert_equal('otherthing', getline(1)) |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4822 bwipe! |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4823 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
4824 # also when the context is Vim9 script |
22415
1cefe1c013ac
patch 8.2.1756: Vim9: :let will soon be disallowed
Bram Moolenaar <Bram@vim.org>
parents:
22395
diff
changeset
|
4825 var lines =<< trim END |
19894
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4826 vim9script |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4827 new |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4828 setline(1, 'something') |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4829 :substitute(some(other( |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4830 assert_equal('otherthing', getline(1)) |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4831 bwipe! |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4832 END |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4833 writefile(lines, 'Xvim9lines') |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4834 source Xvim9lines |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4835 |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4836 delete('Xvim9lines') |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4837 enddef |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
4838 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4839 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |