Mercurial > vim
annotate src/testdir/test_vim9_script.vim @ 21584:d0c76ce48326 v8.2.1342
patch 8.2.1342: Vim9: accidentally using "t" gives a confusing error
Commit: https://github.com/vim/vim/commit/f5a48010ef9e47319185f1aaac1bc6d45cd4d47a
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Aug 1 17:00:03 2020 +0200
patch 8.2.1342: Vim9: accidentally using "t" gives a confusing error
Problem: Vim9: accidentally using "x" gives a confusing error.
Solution: Disallow using ":t" in Vim9 script. (issue https://github.com/vim/vim/issues/6399)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 01 Aug 2020 17:15:03 +0200 |
parents | 7417cb54cb24 |
children | 7b5b9558500a |
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 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 def Test_syntax() |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 let var = 234 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 let other: list<string> = ['asdf'] |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 |
19326
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
13 let s:appendToMe = 'xxx' |
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
14 let s:addToMe = 111 |
19449
f8408ba21982
patch 8.2.0282: Vim9: setting number option not tested
Bram Moolenaar <Bram@vim.org>
parents:
19445
diff
changeset
|
15 let g:existing = 'yes' |
19872
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
16 let g:inc_counter = 1 |
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
17 let $SOME_ENV_VAR = 'some' |
20419
d54dfb5f12db
patch 8.2.0764: Vim9: assigning to option not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
20401
diff
changeset
|
18 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
|
19 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
|
20 let g:anumber = 123 |
19326
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
21 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 def Test_assignment() |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 let bool1: bool = true |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 assert_equal(v:true, bool1) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 let bool2: bool = false |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 assert_equal(v:false, bool2) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 |
20142
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20138
diff
changeset
|
28 call CheckDefFailure(['let x:string'], 'E1069:') |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20138
diff
changeset
|
29 call CheckDefFailure(['let x:string = "x"'], 'E1069:') |
20349
e29b2ec8d4d2
patch 8.2.0730: Vim9: Assignment to dict member does not work
Bram Moolenaar <Bram@vim.org>
parents:
20347
diff
changeset
|
30 call CheckDefFailure(['let a:string = "x"'], 'E1069:') |
20142
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20138
diff
changeset
|
31 |
21443
66386ca8a69f
patch 8.2.1272: Vim9: type not checked if declaration also assigns value
Bram Moolenaar <Bram@vim.org>
parents:
21435
diff
changeset
|
32 let nr: number = 1234 |
66386ca8a69f
patch 8.2.1272: Vim9: type not checked if declaration also assigns value
Bram Moolenaar <Bram@vim.org>
parents:
21435
diff
changeset
|
33 call CheckDefFailure(['let nr: number = "asdf"'], 'E1013:') |
66386ca8a69f
patch 8.2.1272: Vim9: type not checked if declaration also assigns value
Bram Moolenaar <Bram@vim.org>
parents:
21435
diff
changeset
|
34 |
21391
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
35 let a: number = 6 #comment |
19860
37c4779ca8f5
patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19822
diff
changeset
|
36 assert_equal(6, a) |
37c4779ca8f5
patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19822
diff
changeset
|
37 |
19558
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19532
diff
changeset
|
38 if has('channel') |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19532
diff
changeset
|
39 let chan1: channel |
19564
06f29b6ea04a
patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents:
19558
diff
changeset
|
40 let job1: job |
19572
6b6e97d0185e
patch 8.2.0343: Vim9: using wrong instruction, limited test coverage
Bram Moolenaar <Bram@vim.org>
parents:
19568
diff
changeset
|
41 let job2: job = job_start('willfail') |
19558
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19532
diff
changeset
|
42 endif |
19564
06f29b6ea04a
patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents:
19558
diff
changeset
|
43 if has('float') |
06f29b6ea04a
patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents:
19558
diff
changeset
|
44 let float1: float = 3.4 |
06f29b6ea04a
patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents:
19558
diff
changeset
|
45 endif |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
19904
diff
changeset
|
46 let Funky1: func |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
19904
diff
changeset
|
47 let Funky2: func = function('len') |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
48 let Party2: func = funcref('g:Test_syntax') |
19558
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19532
diff
changeset
|
49 |
21391
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
50 g:newvar = 'new' #comment |
19449
f8408ba21982
patch 8.2.0282: Vim9: setting number option not tested
Bram Moolenaar <Bram@vim.org>
parents:
19445
diff
changeset
|
51 assert_equal('new', g:newvar) |
f8408ba21982
patch 8.2.0282: Vim9: setting number option not tested
Bram Moolenaar <Bram@vim.org>
parents:
19445
diff
changeset
|
52 |
f8408ba21982
patch 8.2.0282: Vim9: setting number option not tested
Bram Moolenaar <Bram@vim.org>
parents:
19445
diff
changeset
|
53 assert_equal('yes', g:existing) |
f8408ba21982
patch 8.2.0282: Vim9: setting number option not tested
Bram Moolenaar <Bram@vim.org>
parents:
19445
diff
changeset
|
54 g:existing = 'no' |
f8408ba21982
patch 8.2.0282: Vim9: setting number option not tested
Bram Moolenaar <Bram@vim.org>
parents:
19445
diff
changeset
|
55 assert_equal('no', g:existing) |
f8408ba21982
patch 8.2.0282: Vim9: setting number option not tested
Bram Moolenaar <Bram@vim.org>
parents:
19445
diff
changeset
|
56 |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
57 v:char = 'abc' |
19326
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
58 assert_equal('abc', v:char) |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
59 |
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
60 $ENVVAR = 'foobar' |
19326
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
61 assert_equal('foobar', $ENVVAR) |
19283
9dc843109c97
patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19281
diff
changeset
|
62 $ENVVAR = '' |
19326
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
63 |
21526
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
64 let lines =<< trim END |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
65 vim9script |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
66 $ENVVAR = 'barfoo' |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
67 assert_equal('barfoo', $ENVVAR) |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
68 $ENVVAR = '' |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
69 END |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
70 call CheckScriptSuccess(lines) |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
71 |
19451
b26e96f7c12f
patch 8.2.0283: Vim9: failing to load script var not tested
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
72 s:appendToMe ..= 'yyy' |
b26e96f7c12f
patch 8.2.0283: Vim9: failing to load script var not tested
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
73 assert_equal('xxxyyy', s:appendToMe) |
b26e96f7c12f
patch 8.2.0283: Vim9: failing to load script var not tested
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
74 s:addToMe += 222 |
b26e96f7c12f
patch 8.2.0283: Vim9: failing to load script var not tested
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
75 assert_equal(333, s:addToMe) |
19455
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
76 s:newVar = 'new' |
655631882288
patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
77 assert_equal('new', s:newVar) |
19872
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
78 |
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
79 set ts=7 |
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
80 &ts += 1 |
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
81 assert_equal(8, &ts) |
19878
dd3c80122a0e
patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19874
diff
changeset
|
82 &ts -= 3 |
dd3c80122a0e
patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19874
diff
changeset
|
83 assert_equal(5, &ts) |
dd3c80122a0e
patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19874
diff
changeset
|
84 &ts *= 2 |
dd3c80122a0e
patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19874
diff
changeset
|
85 assert_equal(10, &ts) |
dd3c80122a0e
patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19874
diff
changeset
|
86 &ts /= 3 |
dd3c80122a0e
patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19874
diff
changeset
|
87 assert_equal(3, &ts) |
dd3c80122a0e
patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19874
diff
changeset
|
88 set ts=10 |
dd3c80122a0e
patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19874
diff
changeset
|
89 &ts %= 4 |
dd3c80122a0e
patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19874
diff
changeset
|
90 assert_equal(2, &ts) |
21526
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
91 |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
92 lines =<< trim END |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
93 vim9script |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
94 &ts = 6 |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
95 &ts += 3 |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
96 assert_equal(9, &ts) |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
97 END |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
98 call CheckScriptSuccess(lines) |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
99 |
19872
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
100 call CheckDefFailure(['¬ex += 3'], 'E113:') |
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
101 call CheckDefFailure(['&ts ..= "xxx"'], 'E1019:') |
20419
d54dfb5f12db
patch 8.2.0764: Vim9: assigning to option not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
20401
diff
changeset
|
102 call CheckDefFailure(['&ts = [7]'], 'E1013:') |
d54dfb5f12db
patch 8.2.0764: Vim9: assigning to option not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
20401
diff
changeset
|
103 call CheckDefExecFailure(['&ts = g:alist'], 'E1029: Expected number but got list') |
d54dfb5f12db
patch 8.2.0764: Vim9: assigning to option not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
20401
diff
changeset
|
104 call CheckDefFailure(['&ts = "xx"'], 'E1013:') |
d54dfb5f12db
patch 8.2.0764: Vim9: assigning to option not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
20401
diff
changeset
|
105 call CheckDefExecFailure(['&ts = g:astring'], 'E1029: Expected number but got string') |
19872
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
106 call CheckDefFailure(['&path += 3'], 'E1013:') |
20419
d54dfb5f12db
patch 8.2.0764: Vim9: assigning to option not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
20401
diff
changeset
|
107 call CheckDefExecFailure(['&bs = "asdf"'], 'E474:') |
20055
686deb5959c2
patch 8.2.0583: Vim9: # comment not recognized in :def function
Bram Moolenaar <Bram@vim.org>
parents:
20029
diff
changeset
|
108 # test freeing ISN_STOREOPT |
19894
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
109 call CheckDefFailure(['&ts = 3', 'let asdf'], 'E1022:') |
19878
dd3c80122a0e
patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19874
diff
changeset
|
110 &ts = 8 |
19872
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
111 |
21540
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
112 call CheckDefFailure(['let s:var = 123'], 'E1101:') |
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
113 call CheckDefFailure(['let s:var: number'], 'E1101:') |
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
114 |
19872
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
115 g:inc_counter += 1 |
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
116 assert_equal(2, g:inc_counter) |
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
117 |
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
118 $SOME_ENV_VAR ..= 'more' |
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
119 assert_equal('somemore', $SOME_ENV_VAR) |
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
120 call CheckDefFailure(['$SOME_ENV_VAR += "more"'], 'E1013:') |
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
121 call CheckDefFailure(['$SOME_ENV_VAR += 123'], 'E1013:') |
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
122 |
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
123 @a = 'areg' |
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
124 @a ..= 'add' |
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
125 assert_equal('aregadd', @a) |
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
126 call CheckDefFailure(['@a += "more"'], 'E1013:') |
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19862
diff
changeset
|
127 call CheckDefFailure(['@a += 123'], 'E1013:') |
19874
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
128 |
21526
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
129 lines =<< trim END |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
130 vim9script |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
131 @c = 'areg' |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
132 @c ..= 'add' |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
133 assert_equal('aregadd', @c) |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
134 END |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
135 call CheckScriptSuccess(lines) |
a7afee13873d
patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents:
21516
diff
changeset
|
136 |
19874
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
137 v:errmsg = 'none' |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
138 v:errmsg ..= 'again' |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
139 assert_equal('noneagain', v:errmsg) |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
140 call CheckDefFailure(['v:errmsg += "more"'], 'E1013:') |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
141 call CheckDefFailure(['v:errmsg += 123'], 'E1013:') |
21540
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
142 |
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
143 # single letter variables |
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
144 a = 123 |
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
145 assert_equal(123, a) |
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
146 let b: number |
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
147 b = 123 |
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
148 assert_equal(123, b) |
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
149 let g: number |
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
150 g = 123 |
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
151 assert_equal(123, g) |
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
152 let s: number |
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
153 s = 123 |
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
154 assert_equal(123, s) |
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
155 let t: number |
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
156 t = 123 |
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
157 assert_equal(123, t) |
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
158 let v: number |
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
159 v = 123 |
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
160 assert_equal(123, v) |
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
161 let w: number |
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
162 w = 123 |
8e278698b1fe
patch 8.2.1320: Vim9: cannot declare some single letter variables
Bram Moolenaar <Bram@vim.org>
parents:
21528
diff
changeset
|
163 assert_equal(123, w) |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
19904
diff
changeset
|
164 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
19904
diff
changeset
|
165 |
20921
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
166 def Test_vim9_single_char_vars() |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
167 let lines =<< trim END |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
168 vim9script |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
169 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
170 # single character variable declarations work |
20921
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
171 let a: string |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
172 let b: number |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
173 let l: list<any> |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
174 let s: string |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
175 let t: number |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
176 let v: number |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
177 let w: number |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
178 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
179 # script-local variables can be used without s: prefix |
20921
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
180 a = 'script-a' |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
181 b = 111 |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
182 l = [1, 2, 3] |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
183 s = 'script-s' |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
184 t = 222 |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
185 v = 333 |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
186 w = 444 |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
187 |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
188 assert_equal('script-a', a) |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
189 assert_equal(111, b) |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
190 assert_equal([1, 2, 3], l) |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
191 assert_equal('script-s', s) |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
192 assert_equal(222, t) |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
193 assert_equal(333, v) |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
194 assert_equal(444, w) |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
195 END |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
196 writefile(lines, 'Xsinglechar') |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
197 source Xsinglechar |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
198 delete('Xsinglechar') |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
199 enddef |
187c3fb42c8f
patch 8.2.1012: Vim9: cannot declare single character script variables
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
200 |
20472
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
201 def Test_assignment_list() |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
202 let list1: list<bool> = [false, true, false] |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
203 let list2: list<number> = [1, 2, 3] |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
204 let list3: list<string> = ['sdf', 'asdf'] |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
205 let list4: list<any> = ['yes', true, 1234] |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
206 let list5: list<blob> = [0z01, 0z02] |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
207 |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
208 let listS: list<string> = [] |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
209 let listN: list<number> = [] |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
210 |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
211 assert_equal([1, 2, 3], list2) |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
212 list2[-1] = 99 |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
213 assert_equal([1, 2, 99], list2) |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
214 list2[-2] = 88 |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
215 assert_equal([1, 88, 99], list2) |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
216 list2[-3] = 77 |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
217 assert_equal([77, 88, 99], list2) |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
218 call CheckDefExecFailure(['let ll = [1, 2, 3]', 'll[-4] = 6'], 'E684:') |
20915
a3853794a768
patch 8.2.1009: Vim9: some failures not checked for
Bram Moolenaar <Bram@vim.org>
parents:
20899
diff
changeset
|
219 call CheckDefExecFailure(['let [v1, v2] = [1, 2]'], 'E1092:') |
20472
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
220 |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
221 # type becomes list<any> |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
222 let somelist = rand() > 0 ? [1, 2, 3] : ['a', 'b', 'c'] |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
223 enddef |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
224 |
21413
8992d4f63761
patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
21391
diff
changeset
|
225 def Test_assignment_list_vim9script() |
8992d4f63761
patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
21391
diff
changeset
|
226 let lines =<< trim END |
8992d4f63761
patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
21391
diff
changeset
|
227 vim9script |
8992d4f63761
patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
21391
diff
changeset
|
228 let v1: number |
8992d4f63761
patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
21391
diff
changeset
|
229 let v2: number |
8992d4f63761
patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
21391
diff
changeset
|
230 let v3: number |
8992d4f63761
patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
21391
diff
changeset
|
231 [v1, v2, v3] = [1, 2, 3] |
8992d4f63761
patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
21391
diff
changeset
|
232 assert_equal([1, 2, 3], [v1, v2, v3]) |
8992d4f63761
patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
21391
diff
changeset
|
233 END |
8992d4f63761
patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
21391
diff
changeset
|
234 call CheckScriptSuccess(lines) |
8992d4f63761
patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
21391
diff
changeset
|
235 enddef |
8992d4f63761
patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
21391
diff
changeset
|
236 |
20472
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
237 def Test_assignment_dict() |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
238 let dict1: dict<bool> = #{one: false, two: true} |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
239 let dict2: dict<number> = #{one: 1, two: 2} |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
240 let dict3: dict<string> = #{key: 'value'} |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
241 let dict4: dict<any> = #{one: 1, two: '2'} |
20504
7fb80f486aad
patch 8.2.0806: using "func!" after vim9script gives confusing error
Bram Moolenaar <Bram@vim.org>
parents:
20472
diff
changeset
|
242 let dict5: dict<blob> = #{one: 0z01, two: 0z02} |
20472
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
243 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
244 # overwrite |
20919
96bf2b304932
patch 8.2.1011: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
20915
diff
changeset
|
245 dict3['key'] = 'another' |
96bf2b304932
patch 8.2.1011: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
20915
diff
changeset
|
246 |
21574
b8b15e8cbf5f
patch 8.2.1337: Vim9: cannot use empty key in dict assignment
Bram Moolenaar <Bram@vim.org>
parents:
21548
diff
changeset
|
247 # empty key can be used |
b8b15e8cbf5f
patch 8.2.1337: Vim9: cannot use empty key in dict assignment
Bram Moolenaar <Bram@vim.org>
parents:
21548
diff
changeset
|
248 let dd = {} |
b8b15e8cbf5f
patch 8.2.1337: Vim9: cannot use empty key in dict assignment
Bram Moolenaar <Bram@vim.org>
parents:
21548
diff
changeset
|
249 dd[""] = 6 |
b8b15e8cbf5f
patch 8.2.1337: Vim9: cannot use empty key in dict assignment
Bram Moolenaar <Bram@vim.org>
parents:
21548
diff
changeset
|
250 assert_equal({'': 6}, dd) |
20472
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
251 |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
252 # type becomes dict<any> |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
253 let somedict = rand() > 0 ? #{a: 1, b: 2} : #{a: 'a', b: 'b'} |
21576
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
254 |
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
255 # assignment to script-local dict |
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
256 let lines =<< trim END |
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
257 vim9script |
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
258 let test: dict<any> = {} |
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
259 def FillDict(): dict<any> |
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
260 test['a'] = 43 |
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
261 return test |
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
262 enddef |
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
263 assert_equal(#{a: 43}, FillDict()) |
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
264 END |
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
265 call CheckScriptSuccess(lines) |
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
266 |
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
267 lines =<< trim END |
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
268 vim9script |
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
269 let test: dict<any> |
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
270 def FillDict(): dict<any> |
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
271 test['a'] = 43 |
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
272 return test |
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
273 enddef |
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
274 FillDict() |
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
275 END |
f4252efe370e
patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Bram Moolenaar <Bram@vim.org>
parents:
21574
diff
changeset
|
276 call CheckScriptFailure(lines, 'E1103:') |
21578
7417cb54cb24
patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
277 |
7417cb54cb24
patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
278 # assignment to global dict |
7417cb54cb24
patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
279 lines =<< trim END |
7417cb54cb24
patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
280 vim9script |
7417cb54cb24
patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
281 g:test = {} |
7417cb54cb24
patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
282 def FillDict(): dict<any> |
7417cb54cb24
patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
283 g:test['a'] = 43 |
7417cb54cb24
patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
284 return g:test |
7417cb54cb24
patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
285 enddef |
7417cb54cb24
patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
286 assert_equal(#{a: 43}, FillDict()) |
7417cb54cb24
patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
287 END |
7417cb54cb24
patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
288 call CheckScriptSuccess(lines) |
7417cb54cb24
patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
289 |
7417cb54cb24
patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
290 # assignment to buffer dict |
7417cb54cb24
patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
291 lines =<< trim END |
7417cb54cb24
patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
292 vim9script |
7417cb54cb24
patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
293 b:test = {} |
7417cb54cb24
patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
294 def FillDict(): dict<any> |
7417cb54cb24
patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
295 b:test['a'] = 43 |
7417cb54cb24
patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
296 return b:test |
7417cb54cb24
patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
297 enddef |
7417cb54cb24
patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
298 assert_equal(#{a: 43}, FillDict()) |
7417cb54cb24
patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
299 END |
7417cb54cb24
patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21576
diff
changeset
|
300 call CheckScriptSuccess(lines) |
20472
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
301 enddef |
1338b4dcb885
patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents:
20435
diff
changeset
|
302 |
20089
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
303 def Test_assignment_local() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
304 # Test in a separated file in order not to the current buffer/window/tab is |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
305 # changed. |
20089
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
306 let script_lines: list<string> =<< trim END |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
307 let b:existing = 'yes' |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
308 let w:existing = 'yes' |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
309 let t:existing = 'yes' |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
310 |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
311 def Test_assignment_local_internal() |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
312 b:newvar = 'new' |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
313 assert_equal('new', b:newvar) |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
314 assert_equal('yes', b:existing) |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
315 b:existing = 'no' |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
316 assert_equal('no', b:existing) |
20338
ff4ae3f09307
patch 8.2.0724: Vim9: appending to buffer/window/tab variable not tested
Bram Moolenaar <Bram@vim.org>
parents:
20301
diff
changeset
|
317 b:existing ..= 'NO' |
ff4ae3f09307
patch 8.2.0724: Vim9: appending to buffer/window/tab variable not tested
Bram Moolenaar <Bram@vim.org>
parents:
20301
diff
changeset
|
318 assert_equal('noNO', b:existing) |
20089
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
319 |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
320 w:newvar = 'new' |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
321 assert_equal('new', w:newvar) |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
322 assert_equal('yes', w:existing) |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
323 w:existing = 'no' |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
324 assert_equal('no', w:existing) |
20338
ff4ae3f09307
patch 8.2.0724: Vim9: appending to buffer/window/tab variable not tested
Bram Moolenaar <Bram@vim.org>
parents:
20301
diff
changeset
|
325 w:existing ..= 'NO' |
ff4ae3f09307
patch 8.2.0724: Vim9: appending to buffer/window/tab variable not tested
Bram Moolenaar <Bram@vim.org>
parents:
20301
diff
changeset
|
326 assert_equal('noNO', w:existing) |
20089
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
327 |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
328 t:newvar = 'new' |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
329 assert_equal('new', t:newvar) |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
330 assert_equal('yes', t:existing) |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
331 t:existing = 'no' |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
332 assert_equal('no', t:existing) |
20338
ff4ae3f09307
patch 8.2.0724: Vim9: appending to buffer/window/tab variable not tested
Bram Moolenaar <Bram@vim.org>
parents:
20301
diff
changeset
|
333 t:existing ..= 'NO' |
ff4ae3f09307
patch 8.2.0724: Vim9: appending to buffer/window/tab variable not tested
Bram Moolenaar <Bram@vim.org>
parents:
20301
diff
changeset
|
334 assert_equal('noNO', t:existing) |
20089
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
335 enddef |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
336 call Test_assignment_local_internal() |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
337 END |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
338 call CheckScriptSuccess(script_lines) |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
339 enddef |
7fc5d62fe2a5
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents:
20079
diff
changeset
|
340 |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
19904
diff
changeset
|
341 def Test_assignment_default() |
19874
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
342 |
20055
686deb5959c2
patch 8.2.0583: Vim9: # comment not recognized in :def function
Bram Moolenaar <Bram@vim.org>
parents:
20029
diff
changeset
|
343 # Test default values. |
19874
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
344 let thebool: bool |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
345 assert_equal(v:false, thebool) |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
346 |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
347 let thenumber: number |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
348 assert_equal(0, thenumber) |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
349 |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
350 if has('float') |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
351 let thefloat: float |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
352 assert_equal(0.0, thefloat) |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
353 endif |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
354 |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
355 let thestring: string |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
356 assert_equal('', thestring) |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
357 |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
358 let theblob: blob |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
359 assert_equal(0z, theblob) |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
360 |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
19904
diff
changeset
|
361 let Thefunc: func |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
19904
diff
changeset
|
362 assert_equal(test_null_function(), Thefunc) |
19874
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
363 |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
364 let thelist: list<any> |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
365 assert_equal([], thelist) |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
366 |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
367 let thedict: dict<any> |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
368 assert_equal({}, thedict) |
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
369 |
19890
2b117844f784
patch 8.2.0501: Vim9: script test fails when channel feature is missing
Bram Moolenaar <Bram@vim.org>
parents:
19878
diff
changeset
|
370 if has('channel') |
2b117844f784
patch 8.2.0501: Vim9: script test fails when channel feature is missing
Bram Moolenaar <Bram@vim.org>
parents:
19878
diff
changeset
|
371 let thejob: job |
2b117844f784
patch 8.2.0501: Vim9: script test fails when channel feature is missing
Bram Moolenaar <Bram@vim.org>
parents:
19878
diff
changeset
|
372 assert_equal(test_null_job(), thejob) |
19874
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
373 |
19890
2b117844f784
patch 8.2.0501: Vim9: script test fails when channel feature is missing
Bram Moolenaar <Bram@vim.org>
parents:
19878
diff
changeset
|
374 let thechannel: channel |
2b117844f784
patch 8.2.0501: Vim9: script test fails when channel feature is missing
Bram Moolenaar <Bram@vim.org>
parents:
19878
diff
changeset
|
375 assert_equal(test_null_channel(), thechannel) |
20919
96bf2b304932
patch 8.2.1011: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
20915
diff
changeset
|
376 |
96bf2b304932
patch 8.2.1011: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
20915
diff
changeset
|
377 if has('unix') && executable('cat') |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
378 # check with non-null job and channel, types must match |
20919
96bf2b304932
patch 8.2.1011: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
20915
diff
changeset
|
379 thejob = job_start("cat ", #{}) |
96bf2b304932
patch 8.2.1011: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
20915
diff
changeset
|
380 thechannel = job_getchannel(thejob) |
96bf2b304932
patch 8.2.1011: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
20915
diff
changeset
|
381 job_stop(thejob, 'kill') |
96bf2b304932
patch 8.2.1011: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
20915
diff
changeset
|
382 endif |
19890
2b117844f784
patch 8.2.0501: Vim9: script test fails when channel feature is missing
Bram Moolenaar <Bram@vim.org>
parents:
19878
diff
changeset
|
383 endif |
19894
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
384 |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
385 let nr = 1234 | nr = 5678 |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
386 assert_equal(5678, nr) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
387 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
388 |
20859
876e16c48bd1
patch 8.2.0981: Vim9: cannot compile "[var, var] = list"
Bram Moolenaar <Bram@vim.org>
parents:
20846
diff
changeset
|
389 def Test_assignment_var_list() |
876e16c48bd1
patch 8.2.0981: Vim9: cannot compile "[var, var] = list"
Bram Moolenaar <Bram@vim.org>
parents:
20846
diff
changeset
|
390 let v1: string |
876e16c48bd1
patch 8.2.0981: Vim9: cannot compile "[var, var] = list"
Bram Moolenaar <Bram@vim.org>
parents:
20846
diff
changeset
|
391 let v2: string |
20871
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
392 let vrem: list<string> |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
393 [v1] = ['aaa'] |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
394 assert_equal('aaa', v1) |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
395 |
20859
876e16c48bd1
patch 8.2.0981: Vim9: cannot compile "[var, var] = list"
Bram Moolenaar <Bram@vim.org>
parents:
20846
diff
changeset
|
396 [v1, v2] = ['one', 'two'] |
876e16c48bd1
patch 8.2.0981: Vim9: cannot compile "[var, var] = list"
Bram Moolenaar <Bram@vim.org>
parents:
20846
diff
changeset
|
397 assert_equal('one', v1) |
876e16c48bd1
patch 8.2.0981: Vim9: cannot compile "[var, var] = list"
Bram Moolenaar <Bram@vim.org>
parents:
20846
diff
changeset
|
398 assert_equal('two', v2) |
20871
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
399 |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
400 [v1, v2; vrem] = ['one', 'two'] |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
401 assert_equal('one', v1) |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
402 assert_equal('two', v2) |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
403 assert_equal([], vrem) |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
404 |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
405 [v1, v2; vrem] = ['one', 'two', 'three'] |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
406 assert_equal('one', v1) |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
407 assert_equal('two', v2) |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
408 assert_equal(['three'], vrem) |
20859
876e16c48bd1
patch 8.2.0981: Vim9: cannot compile "[var, var] = list"
Bram Moolenaar <Bram@vim.org>
parents:
20846
diff
changeset
|
409 enddef |
876e16c48bd1
patch 8.2.0981: Vim9: cannot compile "[var, var] = list"
Bram Moolenaar <Bram@vim.org>
parents:
20846
diff
changeset
|
410 |
21548
4e679db1c404
patch 8.2.1324: Vim9: line break after "=" does not work
Bram Moolenaar <Bram@vim.org>
parents:
21540
diff
changeset
|
411 def Test_assignment_vim9script() |
4e679db1c404
patch 8.2.1324: Vim9: line break after "=" does not work
Bram Moolenaar <Bram@vim.org>
parents:
21540
diff
changeset
|
412 let lines =<< trim END |
4e679db1c404
patch 8.2.1324: Vim9: line break after "=" does not work
Bram Moolenaar <Bram@vim.org>
parents:
21540
diff
changeset
|
413 vim9script |
4e679db1c404
patch 8.2.1324: Vim9: line break after "=" does not work
Bram Moolenaar <Bram@vim.org>
parents:
21540
diff
changeset
|
414 def Func(): list<number> |
4e679db1c404
patch 8.2.1324: Vim9: line break after "=" does not work
Bram Moolenaar <Bram@vim.org>
parents:
21540
diff
changeset
|
415 return [1, 2] |
4e679db1c404
patch 8.2.1324: Vim9: line break after "=" does not work
Bram Moolenaar <Bram@vim.org>
parents:
21540
diff
changeset
|
416 enddef |
4e679db1c404
patch 8.2.1324: Vim9: line break after "=" does not work
Bram Moolenaar <Bram@vim.org>
parents:
21540
diff
changeset
|
417 let var1: number |
4e679db1c404
patch 8.2.1324: Vim9: line break after "=" does not work
Bram Moolenaar <Bram@vim.org>
parents:
21540
diff
changeset
|
418 let var2: number |
4e679db1c404
patch 8.2.1324: Vim9: line break after "=" does not work
Bram Moolenaar <Bram@vim.org>
parents:
21540
diff
changeset
|
419 [var1, var2] = |
4e679db1c404
patch 8.2.1324: Vim9: line break after "=" does not work
Bram Moolenaar <Bram@vim.org>
parents:
21540
diff
changeset
|
420 Func() |
4e679db1c404
patch 8.2.1324: Vim9: line break after "=" does not work
Bram Moolenaar <Bram@vim.org>
parents:
21540
diff
changeset
|
421 assert_equal(1, var1) |
4e679db1c404
patch 8.2.1324: Vim9: line break after "=" does not work
Bram Moolenaar <Bram@vim.org>
parents:
21540
diff
changeset
|
422 assert_equal(2, var2) |
4e679db1c404
patch 8.2.1324: Vim9: line break after "=" does not work
Bram Moolenaar <Bram@vim.org>
parents:
21540
diff
changeset
|
423 let ll = |
4e679db1c404
patch 8.2.1324: Vim9: line break after "=" does not work
Bram Moolenaar <Bram@vim.org>
parents:
21540
diff
changeset
|
424 Func() |
4e679db1c404
patch 8.2.1324: Vim9: line break after "=" does not work
Bram Moolenaar <Bram@vim.org>
parents:
21540
diff
changeset
|
425 assert_equal([1, 2], ll) |
4e679db1c404
patch 8.2.1324: Vim9: line break after "=" does not work
Bram Moolenaar <Bram@vim.org>
parents:
21540
diff
changeset
|
426 END |
4e679db1c404
patch 8.2.1324: Vim9: line break after "=" does not work
Bram Moolenaar <Bram@vim.org>
parents:
21540
diff
changeset
|
427 CheckScriptSuccess(lines) |
4e679db1c404
patch 8.2.1324: Vim9: line break after "=" does not work
Bram Moolenaar <Bram@vim.org>
parents:
21540
diff
changeset
|
428 enddef |
4e679db1c404
patch 8.2.1324: Vim9: line break after "=" does not work
Bram Moolenaar <Bram@vim.org>
parents:
21540
diff
changeset
|
429 |
19962
12fa79cac39b
patch 8.2.0537: Vim9: no check for sandbox when setting v:var
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
430 def Mess(): string |
12fa79cac39b
patch 8.2.0537: Vim9: no check for sandbox when setting v:var
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
431 v:foldstart = 123 |
12fa79cac39b
patch 8.2.0537: Vim9: no check for sandbox when setting v:var
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
432 return 'xxx' |
12fa79cac39b
patch 8.2.0537: Vim9: no check for sandbox when setting v:var
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
433 enddef |
12fa79cac39b
patch 8.2.0537: Vim9: no check for sandbox when setting v:var
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
434 |
20091
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
435 def Test_assignment_failure() |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
436 call CheckDefFailure(['let var=234'], 'E1004:') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
437 call CheckDefFailure(['let var =234'], 'E1004:') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
438 call CheckDefFailure(['let var= 234'], 'E1004:') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
439 |
21447
369cde0d5771
patch 8.2.1274: Vim9: no error for missing white space at script level
Bram Moolenaar <Bram@vim.org>
parents:
21443
diff
changeset
|
440 call CheckScriptFailure(['vim9script', 'let var=234'], 'E1004:') |
369cde0d5771
patch 8.2.1274: Vim9: no error for missing white space at script level
Bram Moolenaar <Bram@vim.org>
parents:
21443
diff
changeset
|
441 call CheckScriptFailure(['vim9script', 'let var=234'], "before and after '='") |
369cde0d5771
patch 8.2.1274: Vim9: no error for missing white space at script level
Bram Moolenaar <Bram@vim.org>
parents:
21443
diff
changeset
|
442 call CheckScriptFailure(['vim9script', 'let var =234'], 'E1004:') |
369cde0d5771
patch 8.2.1274: Vim9: no error for missing white space at script level
Bram Moolenaar <Bram@vim.org>
parents:
21443
diff
changeset
|
443 call CheckScriptFailure(['vim9script', 'let var= 234'], 'E1004:') |
369cde0d5771
patch 8.2.1274: Vim9: no error for missing white space at script level
Bram Moolenaar <Bram@vim.org>
parents:
21443
diff
changeset
|
444 call CheckScriptFailure(['vim9script', 'let var = 234', 'var+=234'], 'E1004:') |
369cde0d5771
patch 8.2.1274: Vim9: no error for missing white space at script level
Bram Moolenaar <Bram@vim.org>
parents:
21443
diff
changeset
|
445 call CheckScriptFailure(['vim9script', 'let var = 234', 'var+=234'], "before and after '+='") |
369cde0d5771
patch 8.2.1274: Vim9: no error for missing white space at script level
Bram Moolenaar <Bram@vim.org>
parents:
21443
diff
changeset
|
446 call CheckScriptFailure(['vim9script', 'let var = "x"', 'var..="y"'], 'E1004:') |
369cde0d5771
patch 8.2.1274: Vim9: no error for missing white space at script level
Bram Moolenaar <Bram@vim.org>
parents:
21443
diff
changeset
|
447 call CheckScriptFailure(['vim9script', 'let var = "x"', 'var..="y"'], "before and after '..='") |
369cde0d5771
patch 8.2.1274: Vim9: no error for missing white space at script level
Bram Moolenaar <Bram@vim.org>
parents:
21443
diff
changeset
|
448 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
449 call CheckDefFailure(['let true = 1'], 'E1034:') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
450 call CheckDefFailure(['let false = 1'], 'E1034:') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
451 |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
21216
diff
changeset
|
452 call CheckDefFailure(['[a; b; c] = g:list'], 'E452:') |
20871
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
453 call CheckDefExecFailure(['let a: number', |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
454 '[a] = test_null_list()'], 'E1093:') |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
455 call CheckDefExecFailure(['let a: number', |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
456 '[a] = []'], 'E1093:') |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
457 call CheckDefExecFailure(['let x: number', |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
458 'let y: number', |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
459 '[x, y] = [1]'], 'E1093:') |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
460 call CheckDefExecFailure(['let x: number', |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
461 'let y: number', |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
462 'let z: list<number>', |
65d9189d4dca
patch 8.2.0987: Vim9: cannot assign to [var; var]
Bram Moolenaar <Bram@vim.org>
parents:
20859
diff
changeset
|
463 '[x, y; z] = [1]'], 'E1093:') |
19860
37c4779ca8f5
patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19822
diff
changeset
|
464 |
19874
f92435f0f449
patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19872
diff
changeset
|
465 call CheckDefFailure(['let somevar'], "E1022:") |
19860
37c4779ca8f5
patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19822
diff
changeset
|
466 call CheckDefFailure(['let &option'], 'E1052:') |
37c4779ca8f5
patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19822
diff
changeset
|
467 call CheckDefFailure(['&g:option = 5'], 'E113:') |
37c4779ca8f5
patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19822
diff
changeset
|
468 |
20953
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
469 call CheckDefFailure(['let $VAR = 5'], 'E1016: Cannot declare an environment variable:') |
19860
37c4779ca8f5
patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19822
diff
changeset
|
470 |
37c4779ca8f5
patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19822
diff
changeset
|
471 call CheckDefFailure(['let @~ = 5'], 'E354:') |
37c4779ca8f5
patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19822
diff
changeset
|
472 call CheckDefFailure(['let @a = 5'], 'E1066:') |
37c4779ca8f5
patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19822
diff
changeset
|
473 |
20953
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
474 call CheckDefFailure(['let g:var = 5'], '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
|
475 call CheckDefFailure(['let w:var = 5'], '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
|
476 call CheckDefFailure(['let b:var = 5'], '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
|
477 call CheckDefFailure(['let t:var = 5'], 'E1016: Cannot declare a tab variable:') |
19860
37c4779ca8f5
patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19822
diff
changeset
|
478 |
37c4779ca8f5
patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19822
diff
changeset
|
479 call CheckDefFailure(['let anr = 4', 'anr ..= "text"'], 'E1019:') |
37c4779ca8f5
patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19822
diff
changeset
|
480 call CheckDefFailure(['let xnr += 4'], 'E1020:') |
37c4779ca8f5
patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19822
diff
changeset
|
481 |
20528
489cb75c76b6
patch 8.2.0818: Vim9: using a discovery phase doesn't work well
Bram Moolenaar <Bram@vim.org>
parents:
20504
diff
changeset
|
482 call CheckScriptFailure(['vim9script', 'def Func()', 'let dummy = s:notfound', 'enddef', 'defcompile'], 'E1050:') |
19822
fc3cdc819d80
patch 8.2.0467: Vim9: some errors are not tested
Bram Moolenaar <Bram@vim.org>
parents:
19818
diff
changeset
|
483 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
484 call CheckDefFailure(['let var: list<string> = [123]'], 'expected list<string> but got list<number>') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
485 call CheckDefFailure(['let var: list<number> = ["xx"]'], 'expected list<number> but got list<string>') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
486 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
487 call CheckDefFailure(['let var: dict<string> = #{key: 123}'], 'expected dict<string> but got dict<number>') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
488 call CheckDefFailure(['let var: dict<number> = #{key: "xx"}'], 'expected dict<number> but got dict<string>') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
489 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
490 call CheckDefFailure(['let var = feedkeys("0")'], 'E1031:') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
491 call CheckDefFailure(['let var: number = feedkeys("0")'], 'expected number but got void') |
19558
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19532
diff
changeset
|
492 |
19904
bd4f91762d0f
patch 8.2.0508: Vim9: func and partial types not done yet
Bram Moolenaar <Bram@vim.org>
parents:
19894
diff
changeset
|
493 call CheckDefFailure(['let var: dict <number>'], 'E1068:') |
19558
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19532
diff
changeset
|
494 call CheckDefFailure(['let var: dict<number'], 'E1009:') |
19962
12fa79cac39b
patch 8.2.0537: Vim9: no check for sandbox when setting v:var
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
495 |
12fa79cac39b
patch 8.2.0537: Vim9: no check for sandbox when setting v:var
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
496 call assert_fails('s/^/\=Mess()/n', 'E794:') |
12fa79cac39b
patch 8.2.0537: Vim9: no check for sandbox when setting v:var
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
497 call CheckDefFailure(['let var: dict<number'], 'E1009:') |
21471
126dcb0411ed
patch 8.2.1286: Vim9: No error when using a type to a window variable
Bram Moolenaar <Bram@vim.org>
parents:
21447
diff
changeset
|
498 |
126dcb0411ed
patch 8.2.1286: Vim9: No error when using a type to a window variable
Bram Moolenaar <Bram@vim.org>
parents:
21447
diff
changeset
|
499 call CheckDefFailure(['w:foo: number = 10'], |
126dcb0411ed
patch 8.2.1286: Vim9: No error when using a type to a window variable
Bram Moolenaar <Bram@vim.org>
parents:
21447
diff
changeset
|
500 'E488: Trailing characters: : number = 1') |
126dcb0411ed
patch 8.2.1286: Vim9: No error when using a type to a window variable
Bram Moolenaar <Bram@vim.org>
parents:
21447
diff
changeset
|
501 call CheckDefFailure(['t:foo: bool = true'], |
126dcb0411ed
patch 8.2.1286: Vim9: No error when using a type to a window variable
Bram Moolenaar <Bram@vim.org>
parents:
21447
diff
changeset
|
502 'E488: Trailing characters: : bool = true') |
126dcb0411ed
patch 8.2.1286: Vim9: No error when using a type to a window variable
Bram Moolenaar <Bram@vim.org>
parents:
21447
diff
changeset
|
503 call CheckDefFailure(['b:foo: string = "x"'], |
126dcb0411ed
patch 8.2.1286: Vim9: No error when using a type to a window variable
Bram Moolenaar <Bram@vim.org>
parents:
21447
diff
changeset
|
504 'E488: Trailing characters: : string = "x"') |
126dcb0411ed
patch 8.2.1286: Vim9: No error when using a type to a window variable
Bram Moolenaar <Bram@vim.org>
parents:
21447
diff
changeset
|
505 call CheckDefFailure(['g:foo: number = 123'], |
126dcb0411ed
patch 8.2.1286: Vim9: No error when using a type to a window variable
Bram Moolenaar <Bram@vim.org>
parents:
21447
diff
changeset
|
506 'E488: Trailing characters: : number = 123') |
20091
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
507 enddef |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
508 |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
509 def Test_unlet() |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
510 g:somevar = 'yes' |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
511 assert_true(exists('g:somevar')) |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
512 unlet g:somevar |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
513 assert_false(exists('g:somevar')) |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
514 unlet! g:somevar |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
515 |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
516 call CheckScriptFailure([ |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
517 'vim9script', |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
518 'let svar = 123', |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
519 'unlet svar', |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
520 ], 'E1081:') |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
521 call CheckScriptFailure([ |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
522 'vim9script', |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
523 'let svar = 123', |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
524 'unlet s:svar', |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
525 ], 'E1081:') |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
526 call CheckScriptFailure([ |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
527 'vim9script', |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
528 'let svar = 123', |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
529 'def Func()', |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
530 ' unlet svar', |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
531 '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
|
532 'defcompile', |
20091
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
533 ], 'E1081:') |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
534 call CheckScriptFailure([ |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
535 'vim9script', |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
536 'let svar = 123', |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
537 'def Func()', |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
538 ' unlet s:svar', |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
539 '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
|
540 'defcompile', |
20091
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
541 ], 'E1081:') |
20099
058b41f85bcb
patch 8.2.0605: Vim9: cannot unlet an environment variable
Bram Moolenaar <Bram@vim.org>
parents:
20091
diff
changeset
|
542 |
058b41f85bcb
patch 8.2.0605: Vim9: cannot unlet an environment variable
Bram Moolenaar <Bram@vim.org>
parents:
20091
diff
changeset
|
543 $ENVVAR = 'foobar' |
058b41f85bcb
patch 8.2.0605: Vim9: cannot unlet an environment variable
Bram Moolenaar <Bram@vim.org>
parents:
20091
diff
changeset
|
544 assert_equal('foobar', $ENVVAR) |
058b41f85bcb
patch 8.2.0605: Vim9: cannot unlet an environment variable
Bram Moolenaar <Bram@vim.org>
parents:
20091
diff
changeset
|
545 unlet $ENVVAR |
058b41f85bcb
patch 8.2.0605: Vim9: cannot unlet an environment variable
Bram Moolenaar <Bram@vim.org>
parents:
20091
diff
changeset
|
546 assert_equal('', $ENVVAR) |
20091
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
547 enddef |
19818
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
548 |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
549 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
|
550 # 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
|
551 CheckScriptSuccess([ |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
552 'vim9script', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
553 'func CheckMe()', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
554 ' return 123', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
555 'endfunc', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
556 '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
|
557 ]) |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
558 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
559 # 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
|
560 CheckScriptFailure([ |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
561 'vim9script', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
562 'func DeleteMe1()', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
563 'endfunc', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
564 'delfunction DeleteMe1', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
565 ], 'E1084:') |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
566 CheckScriptFailure([ |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
567 'vim9script', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
568 'func DeleteMe2()', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
569 'endfunc', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
570 'def DoThat()', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
571 ' delfunction DeleteMe2', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
572 'enddef', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
573 'DoThat()', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
574 ], 'E1084:') |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
575 CheckScriptFailure([ |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
576 'vim9script', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
577 'def DeleteMe3()', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
578 'enddef', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
579 'delfunction DeleteMe3', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
580 ], 'E1084:') |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
581 CheckScriptFailure([ |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
582 'vim9script', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
583 'def DeleteMe4()', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
584 'enddef', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
585 'def DoThat()', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
586 ' delfunction DeleteMe4', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
587 'enddef', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
588 'DoThat()', |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
589 ], 'E1084:') |
21479
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
590 |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
591 # Check that global :def function can be replaced and deleted |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
592 let lines =<< trim END |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
593 vim9script |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
594 def g:Global(): string |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
595 return "yes" |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
596 enddef |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
597 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
|
598 def! g:Global(): string |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
599 return "no" |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
600 enddef |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
601 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
|
602 delfunc g:Global |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
603 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
|
604 END |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
605 CheckScriptSuccess(lines) |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
606 |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
607 # 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
|
608 lines =<< trim END |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
609 vim9script |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
610 func g:Global() |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
611 return "yes" |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
612 endfunc |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
613 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
|
614 def! g:Global(): string |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
615 return "no" |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
616 enddef |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
617 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
|
618 delfunc g:Global |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
619 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
|
620 END |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
621 CheckScriptSuccess(lines) |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
622 |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
623 # 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
|
624 lines =<< trim END |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
625 vim9script |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
626 def g:Global(): string |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
627 return "yes" |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
628 enddef |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
629 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
|
630 func! g:Global() |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
631 return "no" |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
632 endfunc |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
633 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
|
634 delfunc g:Global |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
635 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
|
636 END |
90d859a402cc
patch 8.2.1290: Vim9: cannot replace a global function
Bram Moolenaar <Bram@vim.org>
parents:
21473
diff
changeset
|
637 CheckScriptSuccess(lines) |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
638 enddef |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
639 |
19818
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
640 func Test_wrong_type() |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
641 call CheckDefFailure(['let var: list<nothing>'], 'E1010:') |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
642 call CheckDefFailure(['let var: list<list<nothing>>'], 'E1010:') |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
643 call CheckDefFailure(['let var: dict<nothing>'], 'E1010:') |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
644 call CheckDefFailure(['let var: dict<dict<nothing>>'], 'E1010:') |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
645 |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
646 call CheckDefFailure(['let var: dict<number'], 'E1009:') |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
647 call CheckDefFailure(['let var: dict<list<number>'], 'E1009:') |
19558
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19532
diff
changeset
|
648 |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19532
diff
changeset
|
649 call CheckDefFailure(['let var: ally'], 'E1010:') |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19532
diff
changeset
|
650 call CheckDefFailure(['let var: bram'], 'E1010:') |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19532
diff
changeset
|
651 call CheckDefFailure(['let var: cathy'], 'E1010:') |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19532
diff
changeset
|
652 call CheckDefFailure(['let var: dom'], 'E1010:') |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19532
diff
changeset
|
653 call CheckDefFailure(['let var: freddy'], 'E1010:') |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19532
diff
changeset
|
654 call CheckDefFailure(['let var: john'], 'E1010:') |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19532
diff
changeset
|
655 call CheckDefFailure(['let var: larry'], 'E1010:') |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19532
diff
changeset
|
656 call CheckDefFailure(['let var: ned'], 'E1010:') |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19532
diff
changeset
|
657 call CheckDefFailure(['let var: pam'], 'E1010:') |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19532
diff
changeset
|
658 call CheckDefFailure(['let var: sam'], 'E1010:') |
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19532
diff
changeset
|
659 call CheckDefFailure(['let var: vim'], 'E1010:') |
20203
5a397db2c1ed
patch 8.2.0657: Vim9: no check if called variable is a FuncRef
Bram Moolenaar <Bram@vim.org>
parents:
20195
diff
changeset
|
660 |
5a397db2c1ed
patch 8.2.0657: Vim9: no check if called variable is a FuncRef
Bram Moolenaar <Bram@vim.org>
parents:
20195
diff
changeset
|
661 call CheckDefFailure(['let Ref: number', 'Ref()'], 'E1085:') |
5a397db2c1ed
patch 8.2.0657: Vim9: no check if called variable is a FuncRef
Bram Moolenaar <Bram@vim.org>
parents:
20195
diff
changeset
|
662 call CheckDefFailure(['let Ref: string', 'let res = Ref()'], 'E1085:') |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
663 endfunc |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
664 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
665 func Test_const() |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
666 call CheckDefFailure(['const var = 234', 'var = 99'], 'E1018:') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
667 call CheckDefFailure(['const one = 234', 'let one = 99'], 'E1017:') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
668 call CheckDefFailure(['const two'], 'E1021:') |
19860
37c4779ca8f5
patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19822
diff
changeset
|
669 call CheckDefFailure(['const &option'], 'E996:') |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
670 endfunc |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
671 |
20982
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
672 def Test_range_no_colon() |
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
673 call CheckDefFailure(['%s/a/b/'], 'E1050:') |
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
674 call CheckDefFailure(['+ s/a/b/'], 'E1050:') |
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
675 call CheckDefFailure(['- s/a/b/'], 'E1050:') |
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
676 call CheckDefFailure(['. s/a/b/'], 'E1050:') |
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
677 enddef |
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
678 |
bb49b5090a9c
patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
679 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
680 def Test_block() |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
681 let outer = 1 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
682 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
683 let inner = 2 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
684 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
|
685 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
|
686 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
687 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
|
688 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
689 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
690 func Test_block_failure() |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
691 call CheckDefFailure(['{', 'let inner = 1', '}', 'echo inner'], 'E1001:') |
19894
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
692 call CheckDefFailure(['}'], 'E1025:') |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
693 call CheckDefFailure(['{', 'echo 1'], 'E1026:') |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
694 endfunc |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
695 |
19894
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
696 def Test_cmd_modifier() |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
697 tab echo '0' |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
698 call CheckDefFailure(['5tab echo 3'], 'E16:') |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
699 enddef |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
700 |
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
|
701 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
|
702 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
|
703 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
|
704 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
705 def Test_try_catch() |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
706 let l = [] |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
707 try # comment |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
708 add(l, '1') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
709 throw 'wrong' |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
710 add(l, '2') |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
711 catch # comment |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
712 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
|
713 finally # comment |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
714 add(l, '3') |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
715 endtry # comment |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
716 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
|
717 |
21371
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
718 l = [] |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
719 try |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
720 try |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
721 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
|
722 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
|
723 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
|
724 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
|
725 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
|
726 endtry |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
727 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
|
728 add(l, 'caught') |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
729 finally |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
730 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
|
731 endtry |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
732 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
|
733 |
21359
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
734 let n: number |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
735 try |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
736 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
|
737 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
|
738 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
|
739 endtry |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
740 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
|
741 |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
742 try |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
743 n = g:astring[3] |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
744 catch /E714:/ |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
745 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
|
746 endtry |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
747 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
|
748 |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
749 try |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
750 n = l[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
|
751 catch /E39:/ |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
752 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
|
753 endtry |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
754 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
|
755 |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
756 try |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
757 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
|
758 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
|
759 n = 111 |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
760 endtry |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
761 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
|
762 |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
763 try |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
764 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
|
765 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
|
766 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
|
767 endtry |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
768 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
|
769 |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
770 let d = #{one: 1} |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
771 try |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
772 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
|
773 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
|
774 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
|
775 endtry |
e3711ce8133b
patch 8.2.1230: Vim9: list index error not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
776 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
|
777 |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
778 try |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
779 n = -g:astring |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
780 catch /E39:/ |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
781 n = 233 |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
782 endtry |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
783 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
|
784 |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
785 try |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
786 n = +g:astring |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
787 catch /E1030:/ |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
788 n = 244 |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
789 endtry |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
790 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
|
791 |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
792 try |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
793 n = +g:alist |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
794 catch /E745:/ |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
795 n = 255 |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
796 endtry |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
797 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
|
798 |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
799 let nd: dict<any> |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
800 try |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
801 nd = {g:anumber: 1} |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
802 catch /E1029:/ |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
803 n = 266 |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
804 endtry |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
805 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
|
806 |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
807 try |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
808 [n] = [1, 2, 3] |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
809 catch /E1093:/ |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
810 n = 277 |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
811 endtry |
fca850f4d603
patch 8.2.1233: Vim9: various errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21359
diff
changeset
|
812 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
|
813 |
21371
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
814 try |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
815 &ts = g:astring |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
816 catch /E1029:/ |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
817 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
|
818 endtry |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
819 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
|
820 |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
821 try |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
822 &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
|
823 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
|
824 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
|
825 endtry |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
826 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
|
827 |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
828 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
|
829 try |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
830 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
|
831 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
|
832 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
|
833 endtry |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
834 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
|
835 |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
836 try |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
837 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
|
838 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
|
839 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
|
840 endtry |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
841 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
|
842 |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
843 try |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
844 d = {'text': 1, g:astring: 2} |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
845 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
|
846 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
|
847 endtry |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
848 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
|
849 |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
850 try |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
851 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
|
852 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
|
853 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
|
854 endtry |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
855 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
|
856 |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
857 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
|
858 echo len(v:true) |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
859 catch /E701:/ |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
860 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
|
861 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
|
862 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
|
863 |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
864 let P = function('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
|
865 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
|
866 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
|
867 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
|
868 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
|
869 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
|
870 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
|
871 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
|
872 |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
873 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
|
874 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
|
875 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
|
876 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
|
877 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
|
878 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
|
879 |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
880 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
|
881 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
|
882 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
|
883 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
|
884 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
|
885 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
|
886 |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
887 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
|
888 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
|
889 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
|
890 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
|
891 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
|
892 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
|
893 |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
894 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
|
895 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
|
896 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
|
897 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
|
898 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
|
899 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
|
900 |
92e2ed2a2778
patch 8.2.1238: Vim9: a few remaining errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21371
diff
changeset
|
901 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
|
902 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
|
903 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
|
904 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
|
905 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
|
906 assert_equal(411, n) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
907 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
908 |
21371
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
909 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
|
910 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
|
911 enddef |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
912 defcompile |
8e1081ede3b8
patch 8.2.1236: Vim9: a few errors not caught by try/catch
Bram Moolenaar <Bram@vim.org>
parents:
21365
diff
changeset
|
913 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
|
914 |
19445
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
915 def ThrowFromDef() |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
916 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
|
917 enddef |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
918 |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
919 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
|
920 try |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
921 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
|
922 catch |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
923 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
|
924 endtry |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
925 endfunc |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
926 |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
927 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
|
928 try |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
929 ThrowFromDef() |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
930 catch |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
931 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
|
932 endtry |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
933 enddef |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
934 |
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
|
935 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
|
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 return 'intry' |
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 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
|
939 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
|
940 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
|
941 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
|
942 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
|
943 |
19445
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
944 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
|
945 CatchInFunc() |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
946 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
|
947 |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
948 CatchInDef() |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
949 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
|
950 |
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
951 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
|
952 assert_equal('finally', g:in_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
|
953 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
|
954 |
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
955 def Test_try_catch_match() |
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
956 let seq = 'a' |
423b27246383
patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents:
19455
diff
changeset
|
957 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
|
958 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
|
959 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
|
960 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
|
961 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
|
962 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
|
963 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
|
964 seq ..= 'x' |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
965 catch ?a\?sdf? |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
966 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
|
967 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
|
968 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
|
969 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
|
970 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
|
971 enddef |
6e27e1ffa2a6
patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents:
19443
diff
changeset
|
972 |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
973 def Test_try_catch_fails() |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
974 call CheckDefFailure(['catch'], 'E603:') |
21216
bcd08812cde3
patch 8.2.1159: Vim9: no error for missing space after a comma
Bram Moolenaar <Bram@vim.org>
parents:
21206
diff
changeset
|
975 call CheckDefFailure(['try', 'echo 0', 'catch', 'catch'], 'E1033:') |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
976 call CheckDefFailure(['try', 'echo 0', 'catch /pat'], 'E1067:') |
19894
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
977 call CheckDefFailure(['finally'], 'E606:') |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
978 call CheckDefFailure(['try', 'echo 0', 'finally', 'echo 1', 'finally'], 'E607:') |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
979 call CheckDefFailure(['endtry'], 'E602:') |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
980 call CheckDefFailure(['while 1', 'endtry'], 'E170:') |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
981 call CheckDefFailure(['for i in range(5)', 'endtry'], 'E170:') |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
982 call CheckDefFailure(['if 2', 'endtry'], 'E171:') |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
983 call CheckDefFailure(['try', 'echo 1', 'endtry'], 'E1032:') |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
984 |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
985 call CheckDefFailure(['throw'], 'E1015:') |
19894
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
986 call 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
|
987 enddef |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
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 |
21094
376b520312d6
patch 8.2.1098: Vim9: cannot use line break in :throw argument
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
991 let lines =<< trim END |
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) |
376b520312d6
patch 8.2.1098: Vim9: cannot use line break in :throw argument
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
1001 enddef |
376b520312d6
patch 8.2.1098: Vim9: cannot use line break in :throw argument
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
1002 |
21096
74e5e212e550
patch 8.2.1099: Vim9: cannot use line break in :cexpr argument
Bram Moolenaar <Bram@vim.org>
parents:
21094
diff
changeset
|
1003 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
|
1004 # 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
|
1005 set errorformat=File\ %f\ line\ %l |
74e5e212e550
patch 8.2.1099: Vim9: cannot use line break in :cexpr argument
Bram Moolenaar <Bram@vim.org>
parents:
21094
diff
changeset
|
1006 let lines =<< trim END |
74e5e212e550
patch 8.2.1099: Vim9: cannot use line break in :cexpr argument
Bram Moolenaar <Bram@vim.org>
parents:
21094
diff
changeset
|
1007 vim9script |
74e5e212e550
patch 8.2.1099: Vim9: cannot use line break in :cexpr argument
Bram Moolenaar <Bram@vim.org>
parents:
21094
diff
changeset
|
1008 cexpr 'File' |
74e5e212e550
patch 8.2.1099: Vim9: cannot use line break in :cexpr argument
Bram Moolenaar <Bram@vim.org>
parents:
21094
diff
changeset
|
1009 .. ' someFile' .. |
74e5e212e550
patch 8.2.1099: Vim9: cannot use line break in :cexpr argument
Bram Moolenaar <Bram@vim.org>
parents:
21094
diff
changeset
|
1010 ' line 19' |
74e5e212e550
patch 8.2.1099: Vim9: cannot use line break in :cexpr argument
Bram Moolenaar <Bram@vim.org>
parents:
21094
diff
changeset
|
1011 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
|
1012 END |
74e5e212e550
patch 8.2.1099: Vim9: cannot use line break in :cexpr argument
Bram Moolenaar <Bram@vim.org>
parents:
21094
diff
changeset
|
1013 CheckScriptSuccess(lines) |
74e5e212e550
patch 8.2.1099: Vim9: cannot use line break in :cexpr argument
Bram Moolenaar <Bram@vim.org>
parents:
21094
diff
changeset
|
1014 set errorformat& |
74e5e212e550
patch 8.2.1099: Vim9: cannot use line break in :cexpr argument
Bram Moolenaar <Bram@vim.org>
parents:
21094
diff
changeset
|
1015 enddef |
74e5e212e550
patch 8.2.1099: Vim9: cannot use line break in :cexpr argument
Bram Moolenaar <Bram@vim.org>
parents:
21094
diff
changeset
|
1016 |
21391
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1017 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
|
1018 # checks line continuation and comments |
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1019 let lines =<< trim END |
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1020 vim9script |
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1021 let mylist = [ |
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1022 'one', |
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1023 # comment |
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1024 '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
|
1025 |
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1026 'three', |
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1027 ] |
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1028 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
|
1029 END |
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1030 CheckScriptSuccess(lines) |
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1031 enddef |
8b882afa8ed2
patch 8.2.1246: Vim9: comment after assignment doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21375
diff
changeset
|
1032 |
20291
f7b1e43beb8f
patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents:
20289
diff
changeset
|
1033 if has('channel') |
f7b1e43beb8f
patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents:
20289
diff
changeset
|
1034 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
|
1035 |
20291
f7b1e43beb8f
patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents:
20289
diff
changeset
|
1036 def FuncWithError() |
f7b1e43beb8f
patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents:
20289
diff
changeset
|
1037 echomsg g:someJob |
f7b1e43beb8f
patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents:
20289
diff
changeset
|
1038 enddef |
20289
208b38bddc36
patch 8.2.0700: Vim9: converting error message to exception not tested
Bram Moolenaar <Bram@vim.org>
parents:
20203
diff
changeset
|
1039 |
20291
f7b1e43beb8f
patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents:
20289
diff
changeset
|
1040 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
|
1041 try |
f7b1e43beb8f
patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents:
20289
diff
changeset
|
1042 call FuncWithError() |
f7b1e43beb8f
patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents:
20289
diff
changeset
|
1043 catch |
f7b1e43beb8f
patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents:
20289
diff
changeset
|
1044 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
|
1045 endtry |
f7b1e43beb8f
patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents:
20289
diff
changeset
|
1046 endfunc |
f7b1e43beb8f
patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents:
20289
diff
changeset
|
1047 endif |
20289
208b38bddc36
patch 8.2.0700: Vim9: converting error message to exception not tested
Bram Moolenaar <Bram@vim.org>
parents:
20203
diff
changeset
|
1048 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1049 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
|
1050 vim9script |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1051 let name: string = 'bob' |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1052 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
|
1053 return name .. arg |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1054 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
|
1055 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
|
1056 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
|
1057 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1058 export const CONST = 1234 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1059 export let exported = 9876 |
19326
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
1060 export let 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
|
1061 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
|
1062 return 'Exported' |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1063 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1064 END |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1065 |
19623
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1066 def Test_vim9_import_export() |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1067 let import_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
|
1068 vim9script |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1069 import {exported, Exported} from './Xexport.vim' |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1070 g:imported = exported |
19326
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
1071 exported += 3 |
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
1072 g:imported_added = exported |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1073 g:imported_func = Exported() |
19326
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
1074 |
21473
8bcd1ee2630b
patch 8.2.1287: Vim9: crash when using an imported function
Bram Moolenaar <Bram@vim.org>
parents:
21471
diff
changeset
|
1075 def GetExported(): string |
8bcd1ee2630b
patch 8.2.1287: Vim9: crash when using an imported function
Bram Moolenaar <Bram@vim.org>
parents:
21471
diff
changeset
|
1076 let local_dict = #{ref: Exported} |
8bcd1ee2630b
patch 8.2.1287: Vim9: crash when using an imported function
Bram Moolenaar <Bram@vim.org>
parents:
21471
diff
changeset
|
1077 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
|
1078 enddef |
8bcd1ee2630b
patch 8.2.1287: Vim9: crash when using an imported function
Bram Moolenaar <Bram@vim.org>
parents:
21471
diff
changeset
|
1079 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
|
1080 |
19326
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
1081 import {exp_name} from './Xexport.vim' |
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
1082 g:imported_name = exp_name |
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
1083 exp_name ..= ' Doe' |
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
1084 g:imported_name_appended = exp_name |
19583
ba35daca6553
patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents:
19579
diff
changeset
|
1085 g:imported_later = exported |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1086 END |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1087 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1088 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
|
1089 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
|
1090 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1091 source Ximport.vim |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1092 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1093 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
|
1094 assert_equal('bob', g:localname) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1095 assert_equal(9876, g:imported) |
19326
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
1096 assert_equal(9879, g:imported_added) |
19583
ba35daca6553
patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents:
19579
diff
changeset
|
1097 assert_equal(9879, g:imported_later) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1098 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
|
1099 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
|
1100 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
|
1101 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
|
1102 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
|
1103 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1104 unlet g:result |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1105 unlet g:localname |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1106 unlet g:imported |
19326
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
1107 unlet g:imported_added |
19583
ba35daca6553
patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents:
19579
diff
changeset
|
1108 unlet g:imported_later |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1109 unlet g:imported_func |
19326
d1810b726592
patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents:
19320
diff
changeset
|
1110 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
|
1111 delete('Ximport.vim') |
19509
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1112 |
21146
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1113 # similar, with line breaks |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1114 let import_line_break_script_lines =<< trim END |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1115 vim9script |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1116 import { |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1117 exported, |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1118 Exported, |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1119 } |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1120 from |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1121 './Xexport.vim' |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1122 g:imported = exported |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1123 exported += 5 |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1124 g:imported_added = exported |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1125 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
|
1126 END |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1127 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
|
1128 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
|
1129 |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1130 assert_equal(9876, g:imported) |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1131 assert_equal(9881, g:imported_added) |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1132 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
|
1133 |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1134 # 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
|
1135 assert_false(exists('g:result')) |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1136 unlet g:imported |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1137 unlet g:imported_added |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1138 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
|
1139 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
|
1140 |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1141 # import inside :def function |
19583
ba35daca6553
patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents:
19579
diff
changeset
|
1142 let import_in_def_lines =<< trim END |
ba35daca6553
patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents:
19579
diff
changeset
|
1143 vim9script |
ba35daca6553
patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents:
19579
diff
changeset
|
1144 def ImportInDef() |
ba35daca6553
patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents:
19579
diff
changeset
|
1145 import exported from './Xexport.vim' |
ba35daca6553
patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents:
19579
diff
changeset
|
1146 g:imported = exported |
ba35daca6553
patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents:
19579
diff
changeset
|
1147 exported += 7 |
ba35daca6553
patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents:
19579
diff
changeset
|
1148 g:imported_added = exported |
ba35daca6553
patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents:
19579
diff
changeset
|
1149 enddef |
ba35daca6553
patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents:
19579
diff
changeset
|
1150 ImportInDef() |
ba35daca6553
patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents:
19579
diff
changeset
|
1151 END |
ba35daca6553
patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents:
19579
diff
changeset
|
1152 writefile(import_in_def_lines, 'Ximport2.vim') |
ba35daca6553
patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents:
19579
diff
changeset
|
1153 source Ximport2.vim |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
1154 # TODO: this should be 9879 |
19583
ba35daca6553
patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents:
19579
diff
changeset
|
1155 assert_equal(9876, g:imported) |
ba35daca6553
patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents:
19579
diff
changeset
|
1156 assert_equal(9883, g:imported_added) |
ba35daca6553
patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents:
19579
diff
changeset
|
1157 unlet g:imported |
ba35daca6553
patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents:
19579
diff
changeset
|
1158 unlet g:imported_added |
ba35daca6553
patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents:
19579
diff
changeset
|
1159 delete('Ximport2.vim') |
ba35daca6553
patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents:
19579
diff
changeset
|
1160 |
19509
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1161 let import_star_as_lines =<< trim END |
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1162 vim9script |
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1163 import * as Export from './Xexport.vim' |
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1164 def UseExport() |
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1165 g:imported = Export.exported |
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1166 enddef |
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1167 UseExport() |
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1168 END |
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1169 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
|
1170 source Ximport.vim |
19583
ba35daca6553
patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents:
19579
diff
changeset
|
1171 assert_equal(9883, g:imported) |
19509
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1172 |
19818
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1173 let import_star_as_lines_no_dot =<< trim END |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1174 vim9script |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1175 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
|
1176 def Func() |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1177 let dummy = 1 |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1178 let imported = Export + dummy |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1179 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
|
1180 defcompile |
19818
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1181 END |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1182 writefile(import_star_as_lines_no_dot, 'Ximport.vim') |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1183 assert_fails('source Ximport.vim', 'E1060:') |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1184 |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1185 let import_star_as_lines_dot_space =<< trim END |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1186 vim9script |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1187 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
|
1188 def Func() |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1189 let imported = Export . exported |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1190 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
|
1191 defcompile |
19818
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1192 END |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1193 writefile(import_star_as_lines_dot_space, 'Ximport.vim') |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1194 assert_fails('source Ximport.vim', 'E1074:') |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1195 |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1196 let import_star_as_lines_missing_name =<< trim END |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1197 vim9script |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1198 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
|
1199 def Func() |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1200 let imported = Export. |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1201 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
|
1202 defcompile |
19818
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1203 END |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1204 writefile(import_star_as_lines_missing_name, 'Ximport.vim') |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1205 assert_fails('source Ximport.vim', 'E1048:') |
c1c88b333481
patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents:
19787
diff
changeset
|
1206 |
21146
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1207 let import_star_as_lbr_lines =<< trim END |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1208 vim9script |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1209 import * |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1210 as Export |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1211 from |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1212 './Xexport.vim' |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1213 def UseExport() |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1214 g:imported = Export.exported |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1215 enddef |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1216 UseExport() |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1217 END |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1218 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
|
1219 source Ximport.vim |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1220 assert_equal(9883, g:imported) |
465d6e40e79c
patch 8.2.1124: Vim9: no line break allowed in :import command
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
1221 |
19509
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1222 let import_star_lines =<< trim END |
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1223 vim9script |
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1224 import * from './Xexport.vim' |
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1225 END |
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1226 writefile(import_star_lines, 'Ximport.vim') |
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1227 assert_fails('source Ximport.vim', 'E1045:') |
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1228 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
1229 # try to import something that exists but is not exported |
19511
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1230 let import_not_exported_lines =<< trim END |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1231 vim9script |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1232 import name from './Xexport.vim' |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1233 END |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1234 writefile(import_not_exported_lines, 'Ximport.vim') |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1235 assert_fails('source Ximport.vim', 'E1049:') |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1236 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
1237 # 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
|
1238 let 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
|
1239 vim9script |
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1240 let exported = 'something' |
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1241 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
|
1242 END |
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1243 writefile(import_already_defined, 'Ximport.vim') |
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1244 assert_fails('source Ximport.vim', 'E1073:') |
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1245 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
1246 # 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
|
1247 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
|
1248 vim9script |
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1249 let exported = 'something' |
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1250 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
|
1251 END |
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1252 writefile(import_already_defined, 'Ximport.vim') |
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1253 assert_fails('source Ximport.vim', 'E1073:') |
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1254 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
1255 # 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
|
1256 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
|
1257 vim9script |
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1258 let exported = 'something' |
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1259 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
|
1260 END |
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1261 writefile(import_already_defined, 'Ximport.vim') |
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1262 assert_fails('source Ximport.vim', 'E1073:') |
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1263 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
1264 # import a very long name, requires making a copy |
19511
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1265 let import_long_name_lines =<< trim END |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1266 vim9script |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1267 import name012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 from './Xexport.vim' |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1268 END |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1269 writefile(import_long_name_lines, 'Ximport.vim') |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1270 assert_fails('source Ximport.vim', 'E1048:') |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1271 |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1272 let import_no_from_lines =<< trim END |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1273 vim9script |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1274 import name './Xexport.vim' |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1275 END |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1276 writefile(import_no_from_lines, 'Ximport.vim') |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1277 assert_fails('source Ximport.vim', 'E1070:') |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1278 |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1279 let import_invalid_string_lines =<< trim END |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1280 vim9script |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1281 import name from Xexport.vim |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1282 END |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1283 writefile(import_invalid_string_lines, 'Ximport.vim') |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1284 assert_fails('source Ximport.vim', 'E1071:') |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1285 |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1286 let import_wrong_name_lines =<< trim END |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1287 vim9script |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1288 import name from './XnoExport.vim' |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1289 END |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1290 writefile(import_wrong_name_lines, 'Ximport.vim') |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1291 assert_fails('source Ximport.vim', 'E1053:') |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1292 |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1293 let import_missing_comma_lines =<< trim END |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1294 vim9script |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1295 import {exported name} from './Xexport.vim' |
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1296 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
|
1297 writefile(import_missing_comma_lines, 'Ximport3.vim') |
2fee087c94cb
patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents:
19593
diff
changeset
|
1298 assert_fails('source Ximport3.vim', 'E1046:') |
19511
7e76d5fba19f
patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19509
diff
changeset
|
1299 |
19509
17f0d6dc6a73
patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19507
diff
changeset
|
1300 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
|
1301 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
|
1302 delete('Xexport.vim') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1303 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
1304 # Check that in a Vim9 script 'cpo' is set to the Vim default. |
19507
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1305 set cpo&vi |
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1306 let cpo_before = &cpo |
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1307 let lines =<< trim END |
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1308 vim9script |
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1309 g:cpo_in_vim9script = &cpo |
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1310 END |
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1311 writefile(lines, 'Xvim9_script') |
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1312 source Xvim9_script |
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1313 assert_equal(cpo_before, &cpo) |
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1314 set cpo&vim |
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1315 assert_equal(&cpo, g:cpo_in_vim9script) |
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1316 delete('Xvim9_script') |
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1317 enddef |
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1318 |
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1319 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
|
1320 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
|
1321 CheckScriptFailure(['vim9script', 'scriptversion 2'], 'E1040:') |
19507
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1322 CheckScriptFailure(['export let 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
|
1323 CheckScriptFailure(['import some from "./Xexport.vim"'], 'E1048:') |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
21216
diff
changeset
|
1324 CheckScriptFailure(['vim9script', 'export let g:some'], 'E1022:') |
19507
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1325 CheckScriptFailure(['vim9script', 'export echo 134'], 'E1043:') |
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1326 |
20919
96bf2b304932
patch 8.2.1011: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
20915
diff
changeset
|
1327 CheckScriptFailure(['vim9script', 'let str: string', 'str = 1234'], 'E1013:') |
96bf2b304932
patch 8.2.1011: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
20915
diff
changeset
|
1328 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
|
1329 |
19507
65049a682574
patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents:
19497
diff
changeset
|
1330 assert_fails('vim9script', 'E1038') |
20079
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
1331 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
|
1332 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1333 |
20883
8bc11506d787
patch 8.2.0993: Vim9 script test fails with normal features
Bram Moolenaar <Bram@vim.org>
parents:
20881
diff
changeset
|
1334 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
|
1335 CheckRunVimInTerminal |
58137dbee8da
patch 8.2.0992: Vim9: crash when using :import in the Vim command
Bram Moolenaar <Bram@vim.org>
parents:
20871
diff
changeset
|
1336 |
20885
b70555af8908
patch 8.2.0994: Vim9: missing function causes compilation error
Bram Moolenaar <Bram@vim.org>
parents:
20883
diff
changeset
|
1337 " 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
|
1338 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
|
1339 endfunc |
b70555af8908
patch 8.2.0994: Vim9: missing function causes compilation error
Bram Moolenaar <Bram@vim.org>
parents:
20883
diff
changeset
|
1340 |
21206
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1341 def Run_Test_import_fails_on_command_line() |
20881
58137dbee8da
patch 8.2.0992: Vim9: crash when using :import in the Vim command
Bram Moolenaar <Bram@vim.org>
parents:
20871
diff
changeset
|
1342 let export =<< trim END |
58137dbee8da
patch 8.2.0992: Vim9: crash when using :import in the Vim command
Bram Moolenaar <Bram@vim.org>
parents:
20871
diff
changeset
|
1343 vim9script |
58137dbee8da
patch 8.2.0992: Vim9: crash when using :import in the Vim command
Bram Moolenaar <Bram@vim.org>
parents:
20871
diff
changeset
|
1344 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
|
1345 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
|
1346 enddef |
58137dbee8da
patch 8.2.0992: Vim9: crash when using :import in the Vim command
Bram Moolenaar <Bram@vim.org>
parents:
20871
diff
changeset
|
1347 END |
20885
b70555af8908
patch 8.2.0994: Vim9: missing function causes compilation error
Bram Moolenaar <Bram@vim.org>
parents:
20883
diff
changeset
|
1348 writefile(export, 'Xexport.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
|
1349 |
20885
b70555af8908
patch 8.2.0994: Vim9: missing function causes compilation error
Bram Moolenaar <Bram@vim.org>
parents:
20883
diff
changeset
|
1350 let buf = RunVimInTerminal('-c "import Foo from ''./Xexport.vim''"', #{ |
b70555af8908
patch 8.2.0994: Vim9: missing function causes compilation error
Bram Moolenaar <Bram@vim.org>
parents:
20883
diff
changeset
|
1351 rows: 6, wait_for_ruler: 0}) |
b70555af8908
patch 8.2.0994: Vim9: missing function causes compilation error
Bram Moolenaar <Bram@vim.org>
parents:
20883
diff
changeset
|
1352 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
|
1353 |
20885
b70555af8908
patch 8.2.0994: Vim9: missing function causes compilation error
Bram Moolenaar <Bram@vim.org>
parents:
20883
diff
changeset
|
1354 delete('Xexport.vim') |
b70555af8908
patch 8.2.0994: Vim9: missing function causes compilation error
Bram Moolenaar <Bram@vim.org>
parents:
20883
diff
changeset
|
1355 StopVimInTerminal(buf) |
b70555af8908
patch 8.2.0994: Vim9: missing function causes compilation error
Bram Moolenaar <Bram@vim.org>
parents:
20883
diff
changeset
|
1356 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
|
1357 |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1358 def Test_vim9script_reload_import() |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1359 let lines =<< trim END |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1360 vim9script |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1361 const var = '' |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1362 let valone = 1234 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1363 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
|
1364 valone = 5678 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1365 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1366 END |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1367 let morelines =<< trim END |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1368 let valtwo = 222 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1369 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
|
1370 return valtwo |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1371 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1372 END |
20195
a2447c58da25
patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
1373 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
|
1374 source Xreload.vim |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1375 source Xreload.vim |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1376 source Xreload.vim |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1377 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1378 let testlines =<< trim END |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1379 vim9script |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1380 def TheFunc() |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1381 import GetValtwo from './Xreload.vim' |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1382 assert_equal(222, GetValtwo()) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1383 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1384 TheFunc() |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1385 END |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1386 writefile(testlines, 'Ximport.vim') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1387 source Ximport.vim |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1388 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
1389 # Test that when not using "morelines" GetValtwo() and valtwo are still |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
1390 # defined, because import doesn't reload a script. |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1391 writefile(lines, 'Xreload.vim') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1392 source Ximport.vim |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1393 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
1394 # 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
|
1395 lines =<< trim END |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1396 vim9script |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1397 let valone = 1234 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1398 let valone = 5678 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1399 END |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1400 writefile(lines, 'Xreload.vim') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1401 assert_fails('source Xreload.vim', 'E1041:') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1402 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1403 delete('Xreload.vim') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1404 delete('Ximport.vim') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1405 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1406 |
21202
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1407 " 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
|
1408 " script-local name. |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1409 def Test_vim9script_funcref() |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1410 let sortlines =<< trim END |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1411 vim9script |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1412 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
|
1413 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
|
1414 enddef |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1415 |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1416 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
|
1417 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
|
1418 enddef |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1419 END |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1420 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
|
1421 |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1422 let lines =<< trim END |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1423 vim9script |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1424 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
|
1425 def Test() |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1426 g:result = FastSort() |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1427 enddef |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1428 Test() |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1429 END |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1430 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
|
1431 |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1432 source Xscript.vim |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1433 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
|
1434 |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1435 unlet g:result |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1436 delete('Xsort.vim') |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1437 delete('Xscript.vim') |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1438 enddef |
1a4e22aa2eb3
patch 8.2.1152: Vim9: function reference is missing script prefix
Bram Moolenaar <Bram@vim.org>
parents:
21188
diff
changeset
|
1439 |
21206
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1440 " Check that when searcing for "FilterFunc" it doesn't find the import in the |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1441 " script where FastFilter() is called from. |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1442 def Test_vim9script_funcref_other_script() |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1443 let filterLines =<< trim END |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1444 vim9script |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1445 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
|
1446 return idx % 2 == 1 |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1447 enddef |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1448 export def FastFilter(): list<number> |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1449 return range(10)->filter('FilterFunc') |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1450 enddef |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1451 END |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1452 writefile(filterLines, 'Xfilter.vim') |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1453 |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1454 let lines =<< trim END |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1455 vim9script |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1456 import {FilterFunc, FastFilter} from './Xfilter.vim' |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1457 def Test() |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1458 let x: list<number> = FastFilter() |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1459 enddef |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1460 Test() |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1461 END |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1462 writefile(lines, 'Ximport.vim') |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1463 assert_fails('source Ximport.vim', 'E121:') |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1464 |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1465 delete('Xfilter.vim') |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1466 delete('Ximport.vim') |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1467 enddef |
caab594592cc
patch 8.2.1154: Vim9: crash when using imported function
Bram Moolenaar <Bram@vim.org>
parents:
21204
diff
changeset
|
1468 |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1469 def Test_vim9script_reload_delfunc() |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1470 let first_lines =<< trim END |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1471 vim9script |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1472 def FuncYes(): string |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1473 return 'yes' |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1474 enddef |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1475 END |
20195
a2447c58da25
patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
1476 let 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
|
1477 def FuncNo(): string |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1478 return 'no' |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1479 enddef |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1480 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
|
1481 assert_equal('yes', FuncYes()) |
20195
a2447c58da25
patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
1482 assert_equal('no', FuncNo()) |
a2447c58da25
patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
1483 enddef |
a2447c58da25
patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
1484 END |
a2447c58da25
patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
1485 let nono_lines =<< trim END |
a2447c58da25
patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
1486 def g:DoCheck(no_exists: bool) |
a2447c58da25
patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
1487 assert_equal('yes', FuncYes()) |
a2447c58da25
patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
1488 assert_fails('call FuncNo()', 'E117:') |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1489 enddef |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1490 END |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1491 |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1492 # FuncNo() is defined |
20195
a2447c58da25
patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
1493 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
|
1494 source Xreloaded.vim |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1495 g:DoCheck(true) |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1496 |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1497 # FuncNo() is not redefined |
20195
a2447c58da25
patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
1498 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
|
1499 source Xreloaded.vim |
20195
a2447c58da25
patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
1500 g:DoCheck() |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1501 |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1502 # FuncNo() is back |
20195
a2447c58da25
patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
1503 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
|
1504 source Xreloaded.vim |
20195
a2447c58da25
patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
1505 g:DoCheck() |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1506 |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1507 delete('Xreloaded.vim') |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1508 enddef |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
1509 |
20347
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
1510 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
|
1511 # write the script with a script-local variable |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
1512 let 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
|
1513 vim9script |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
1514 let var = 'string' |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
1515 END |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
1516 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
|
1517 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
|
1518 |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
1519 # 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
|
1520 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
|
1521 vim9script |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
1522 def Func() |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
1523 let var = 'string' |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
1524 enddef |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
1525 END |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
1526 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
|
1527 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
|
1528 |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
1529 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
|
1530 enddef |
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
1531 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1532 def Test_import_absolute() |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1533 let 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
|
1534 'vim9script', |
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
1535 '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
|
1536 'def UseExported()', |
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
1537 ' 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
|
1538 ' exported = 8888', |
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
1539 ' 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
|
1540 'enddef', |
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
1541 'UseExported()', |
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
1542 '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
|
1543 ] |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1544 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
|
1545 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
|
1546 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1547 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
|
1548 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1549 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
|
1550 assert_equal(8888, g:imported_after) |
20019
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
1551 assert_match('<SNR>\d\+_UseExported.*' .. |
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
1552 'g:imported_abs = exported.*' .. |
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
1553 '0 LOADSCRIPT exported from .*Xexport_abs.vim.*' .. |
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
1554 '1 STOREG g:imported_abs.*' .. |
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
1555 'exported = 8888.*' .. |
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
1556 '3 STORESCRIPT exported in .*Xexport_abs.vim.*' .. |
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
1557 'g:imported_after = exported.*' .. |
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
1558 '4 LOADSCRIPT exported from .*Xexport_abs.vim.*' .. |
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
1559 '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
|
1560 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
|
1561 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
|
1562 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
|
1563 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1564 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
|
1565 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
|
1566 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1567 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1568 def Test_import_rtp() |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1569 let 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
|
1570 'vim9script', |
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
1571 '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
|
1572 '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
|
1573 ] |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1574 writefile(import_lines, 'Ximport_rtp.vim') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1575 mkdir('import') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1576 writefile(s:export_script_lines, 'import/Xexport_rtp.vim') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1577 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1578 let save_rtp = &rtp |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1579 &rtp = getcwd() |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1580 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
|
1581 &rtp = save_rtp |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1582 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1583 assert_equal(9876, g:imported_rtp) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1584 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
|
1585 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1586 delete('Ximport_rtp.vim') |
20347
0e1dfff4f294
patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents:
20338
diff
changeset
|
1587 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
|
1588 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1589 |
20538
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1590 def Test_import_compile_error() |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1591 let export_lines = [ |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1592 'vim9script', |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1593 'export def ExpFunc(): string', |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1594 ' return notDefined', |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1595 'enddef', |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1596 ] |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1597 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
|
1598 |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1599 let import_lines = [ |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1600 'vim9script', |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1601 '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
|
1602 'def ImpFunc()', |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1603 ' echo ExpFunc()', |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1604 'enddef', |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1605 'defcompile', |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1606 ] |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1607 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
|
1608 |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1609 try |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1610 source Ximport.vim |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1611 catch /E1001/ |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
1612 # Error should be fore the Xexported.vim file. |
20538
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1613 assert_match('E1001: variable not found: notDefined', v:exception) |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1614 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
|
1615 endtry |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1616 |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1617 delete('Xexported.vim') |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1618 delete('Ximport.vim') |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1619 enddef |
9f921ba86d05
patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents:
20528
diff
changeset
|
1620 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1621 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
|
1622 # will be allocated as one piece of memory, check that changes work |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1623 let l = [1, 2, 3, 4] |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1624 l->remove(0) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1625 l->add(5) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1626 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
|
1627 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
|
1628 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1629 |
21516
c7b2ce90c2de
patch 8.2.1308: Vim9: accidentally using "x" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
21485
diff
changeset
|
1630 def Test_no_insert_xit() |
c7b2ce90c2de
patch 8.2.1308: Vim9: accidentally using "x" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
21485
diff
changeset
|
1631 call CheckDefExecFailure(['a = 1'], 'E1100:') |
21584
d0c76ce48326
patch 8.2.1342: Vim9: accidentally using "t" gives a confusing error
Bram Moolenaar <Bram@vim.org>
parents:
21578
diff
changeset
|
1632 call CheckDefExecFailure(['c = 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
|
1633 call CheckDefExecFailure(['i = 1'], 'E1100:') |
21584
d0c76ce48326
patch 8.2.1342: Vim9: accidentally using "t" gives a confusing error
Bram Moolenaar <Bram@vim.org>
parents:
21578
diff
changeset
|
1634 call CheckDefExecFailure(['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
|
1635 call 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
|
1636 |
c7b2ce90c2de
patch 8.2.1308: Vim9: accidentally using "x" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
21485
diff
changeset
|
1637 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
|
1638 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
|
1639 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
|
1640 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
|
1641 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
|
1642 CheckScriptFailure(['vim9script', 'i'], 'E1100:') |
21584
d0c76ce48326
patch 8.2.1342: Vim9: accidentally using "t" gives a confusing error
Bram Moolenaar <Bram@vim.org>
parents:
21578
diff
changeset
|
1643 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
|
1644 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
|
1645 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
|
1646 enddef |
c7b2ce90c2de
patch 8.2.1308: Vim9: accidentally using "x" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
21485
diff
changeset
|
1647 |
19332
d6e8a9e80be4
patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19330
diff
changeset
|
1648 def IfElse(what: number): string |
d6e8a9e80be4
patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19330
diff
changeset
|
1649 let res = '' |
d6e8a9e80be4
patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19330
diff
changeset
|
1650 if what == 1 |
d6e8a9e80be4
patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19330
diff
changeset
|
1651 res = "one" |
d6e8a9e80be4
patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19330
diff
changeset
|
1652 elseif what == 2 |
d6e8a9e80be4
patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19330
diff
changeset
|
1653 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
|
1654 else |
19332
d6e8a9e80be4
patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19330
diff
changeset
|
1655 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
|
1656 endif |
19332
d6e8a9e80be4
patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19330
diff
changeset
|
1657 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
|
1658 enddef |
a8d2d3c8f0b3
patch 8.2.0185: Vim9 script: cannot use "if has()" to skip lines
Bram Moolenaar <Bram@vim.org>
parents:
19185
diff
changeset
|
1659 |
19332
d6e8a9e80be4
patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19330
diff
changeset
|
1660 def Test_if_elseif_else() |
d6e8a9e80be4
patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19330
diff
changeset
|
1661 assert_equal('one', IfElse(1)) |
d6e8a9e80be4
patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19330
diff
changeset
|
1662 assert_equal('two', IfElse(2)) |
d6e8a9e80be4
patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents:
19330
diff
changeset
|
1663 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
|
1664 enddef |
9fcdeaa18bd1
patch 8.2.0199: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19253
diff
changeset
|
1665 |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1666 def Test_if_elseif_else_fails() |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1667 call CheckDefFailure(['elseif true'], 'E582:') |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1668 call CheckDefFailure(['else'], 'E581:') |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1669 call CheckDefFailure(['endif'], 'E580:') |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1670 call CheckDefFailure(['if true', 'elseif xxx'], 'E1001:') |
19894
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
1671 call CheckDefFailure(['if true', 'echo 1'], 'E171:') |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1672 enddef |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1673 |
19585
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1674 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
|
1675 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
|
1676 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1677 def Test_if_const_expr() |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1678 let res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1679 if true ? true : false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1680 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1681 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1682 assert_equal(true, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1683 |
19894
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
1684 g:glob = 2 |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
1685 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
|
1686 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
|
1687 endif |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
1688 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
|
1689 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
|
1690 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
|
1691 endif |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
1692 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
|
1693 |
19585
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1694 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1695 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
|
1696 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1697 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1698 assert_equal(true, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1699 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1700 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1701 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
|
1702 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1703 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1704 assert_equal(true, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1705 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1706 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1707 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
|
1708 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1709 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1710 assert_equal(true, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1711 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1712 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1713 if true ? false : true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1714 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1715 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1716 assert_equal(false, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1717 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1718 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1719 if false ? false : true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1720 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1721 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1722 assert_equal(true, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1723 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1724 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1725 if false ? true : false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1726 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1727 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1728 assert_equal(false, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1729 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1730 res = false |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1731 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
|
1732 res = true |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1733 endif |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1734 assert_equal(false, res) |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1735 |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1736 res = false |
19585
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1737 if true && true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1738 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1739 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1740 assert_equal(true, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1741 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1742 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1743 if true && false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1744 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1745 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1746 assert_equal(false, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1747 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1748 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1749 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
|
1750 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1751 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1752 assert_equal(false, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1753 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1754 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1755 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
|
1756 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1757 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1758 assert_equal(false, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1759 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1760 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1761 if false && false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1762 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1763 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1764 assert_equal(false, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1765 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1766 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1767 if true || false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1768 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1769 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1770 assert_equal(true, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1771 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1772 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1773 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
|
1774 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1775 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1776 assert_equal(true, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1777 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1778 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1779 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
|
1780 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1781 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1782 assert_equal(true, res) |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1783 |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1784 res = false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1785 if false || false |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1786 res = true |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1787 endif |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1788 assert_equal(false, res) |
19878
dd3c80122a0e
patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19874
diff
changeset
|
1789 enddef |
19585
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1790 |
19878
dd3c80122a0e
patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19874
diff
changeset
|
1791 def Test_if_const_expr_fails() |
dd3c80122a0e
patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19874
diff
changeset
|
1792 call CheckDefFailure(['if "aaa" == "bbb'], 'E114:') |
dd3c80122a0e
patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19874
diff
changeset
|
1793 call CheckDefFailure(["if 'aaa' == 'bbb"], 'E115:') |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1794 call CheckDefFailure(["if has('aaa'"], 'E110:') |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1795 call 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
|
1796 enddef |
0303f920a7d4
patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
1797 |
20899
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
1798 def RunNested(i: number): number |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
1799 let x: number = 0 |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
1800 if i % 2 |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
1801 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
|
1802 # comment |
20899
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
1803 else |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
1804 # comment |
20899
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
1805 endif |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
1806 x += 1 |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
1807 else |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
1808 x += 1000 |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
1809 endif |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
1810 return x |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
1811 enddef |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
1812 |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
1813 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
|
1814 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
|
1815 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
|
1816 enddef |
e76bddcf3341
patch 8.2.1001: Vim9: crash with nested "if" and assignment
Bram Moolenaar <Bram@vim.org>
parents:
20885
diff
changeset
|
1817 |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
1818 def Test_execute_cmd() |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
1819 new |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
1820 setline(1, 'default') |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
1821 execute 'call setline(1, "execute-string")' |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
1822 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
|
1823 |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
1824 execute "call setline(1, 'execute-string')" |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
1825 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
|
1826 |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
1827 let cmd1 = 'call setline(1,' |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
1828 let 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
|
1829 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
|
1830 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
|
1831 |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
1832 execute cmd1 cmd2 '|call setline(1, "execute-var-string")' |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
1833 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
|
1834 |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
1835 let cmd_first = 'call ' |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
1836 let cmd_last = 'setline(1, "execute-var-var")' |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
1837 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
|
1838 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
|
1839 bwipe! |
19894
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
1840 |
21485
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
1841 let n = true |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
1842 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
|
1843 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
|
1844 |
19894
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
1845 call CheckDefFailure(['execute xxx'], 'E1001:') |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
1846 call CheckDefFailure(['execute "cmd"# comment'], 'E488:') |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
1847 enddef |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
1848 |
21098
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1849 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
|
1850 # only checks line continuation |
21098
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1851 let lines =<< trim END |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1852 vim9script |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1853 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
|
1854 .. ' = ' .. |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1855 '28' |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1856 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
|
1857 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
|
1858 END |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1859 CheckScriptSuccess(lines) |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1860 enddef |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1861 |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
1862 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
|
1863 echo 'some' # comment |
19894
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
1864 echon 'thing' |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
1865 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
|
1866 |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
1867 echo "some" # comment |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
1868 echon "thing" |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
1869 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
|
1870 |
19528
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
1871 let str1 = 'some' |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
1872 let str2 = 'more' |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
1873 echo str1 str2 |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
1874 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
|
1875 |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
1876 call 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
|
1877 enddef |
3b026343f398
patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
1878 |
20142
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20138
diff
changeset
|
1879 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
|
1880 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
|
1881 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
|
1882 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
|
1883 :1messages |
20142
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20138
diff
changeset
|
1884 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
|
1885 |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20138
diff
changeset
|
1886 call CheckDefFailure(['echomsg "xxx"# comment'], 'E488:') |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20138
diff
changeset
|
1887 enddef |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20138
diff
changeset
|
1888 |
21098
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1889 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
|
1890 # only checks line continuation |
21098
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1891 let lines =<< trim END |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1892 vim9script |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1893 echomsg 'here' |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1894 .. ' is ' .. |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1895 'a message' |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1896 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
|
1897 END |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1898 CheckScriptSuccess(lines) |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1899 enddef |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1900 |
20142
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20138
diff
changeset
|
1901 def Test_echoerr_cmd() |
20289
208b38bddc36
patch 8.2.0700: Vim9: converting error message to exception not tested
Bram Moolenaar <Bram@vim.org>
parents:
20203
diff
changeset
|
1902 try |
208b38bddc36
patch 8.2.0700: Vim9: converting error message to exception not tested
Bram Moolenaar <Bram@vim.org>
parents:
20203
diff
changeset
|
1903 echoerr 'something' 'wrong' # comment |
208b38bddc36
patch 8.2.0700: Vim9: converting error message to exception not tested
Bram Moolenaar <Bram@vim.org>
parents:
20203
diff
changeset
|
1904 catch |
208b38bddc36
patch 8.2.0700: Vim9: converting error message to exception not tested
Bram Moolenaar <Bram@vim.org>
parents:
20203
diff
changeset
|
1905 assert_match('something wrong', v:exception) |
208b38bddc36
patch 8.2.0700: Vim9: converting error message to exception not tested
Bram Moolenaar <Bram@vim.org>
parents:
20203
diff
changeset
|
1906 endtry |
20142
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20138
diff
changeset
|
1907 enddef |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20138
diff
changeset
|
1908 |
21098
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1909 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
|
1910 # only checks line continuation |
21098
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1911 let lines =<< trim END |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1912 vim9script |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1913 try |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1914 echoerr 'this' |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1915 .. ' is ' .. |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1916 'wrong' |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1917 catch |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1918 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
|
1919 endtry |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1920 END |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1921 CheckScriptSuccess(lines) |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1922 enddef |
e88b0daa2fcb
patch 8.2.1100: Vim9: cannot use line break in :execute argument
Bram Moolenaar <Bram@vim.org>
parents:
21096
diff
changeset
|
1923 |
19568
c0749ad6c699
patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents:
19566
diff
changeset
|
1924 def Test_for_outside_of_function() |
c0749ad6c699
patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents:
19566
diff
changeset
|
1925 let lines =<< trim END |
c0749ad6c699
patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents:
19566
diff
changeset
|
1926 vim9script |
c0749ad6c699
patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents:
19566
diff
changeset
|
1927 new |
c0749ad6c699
patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents:
19566
diff
changeset
|
1928 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
|
1929 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
|
1930 endfor |
c0749ad6c699
patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents:
19566
diff
changeset
|
1931 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
|
1932 bwipe! |
c0749ad6c699
patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents:
19566
diff
changeset
|
1933 END |
c0749ad6c699
patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents:
19566
diff
changeset
|
1934 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
|
1935 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
|
1936 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
|
1937 enddef |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1938 |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1939 def Test_for_loop() |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1940 let result = '' |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1941 for cnt in range(7) |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1942 if cnt == 4 |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1943 break |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1944 endif |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1945 if cnt == 2 |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1946 continue |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1947 endif |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1948 result ..= cnt .. '_' |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1949 endfor |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1950 assert_equal('0_1_3_', result) |
21188
d73b6ba20053
patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents:
21150
diff
changeset
|
1951 |
d73b6ba20053
patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents:
21150
diff
changeset
|
1952 let concat = '' |
d73b6ba20053
patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents:
21150
diff
changeset
|
1953 for str in eval('["one", "two"]') |
d73b6ba20053
patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents:
21150
diff
changeset
|
1954 concat ..= str |
d73b6ba20053
patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents:
21150
diff
changeset
|
1955 endfor |
d73b6ba20053
patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents:
21150
diff
changeset
|
1956 assert_equal('onetwo', concat) |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1957 enddef |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1958 |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1959 def Test_for_loop_fails() |
20019
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
1960 CheckDefFailure(['for # in range(5)'], 'E690:') |
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
1961 CheckDefFailure(['for i In range(5)'], 'E690:') |
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
1962 CheckDefFailure(['let x = 5', 'for x in range(5)'], 'E1023:') |
20528
489cb75c76b6
patch 8.2.0818: Vim9: using a discovery phase doesn't work well
Bram Moolenaar <Bram@vim.org>
parents:
20504
diff
changeset
|
1963 CheckScriptFailure(['def Func(arg: any)', 'for arg in range(5)', 'enddef', 'defcompile'], 'E1006:') |
21188
d73b6ba20053
patch 8.2.1145: Vim9: "for" only accepts a list at compile time
Bram Moolenaar <Bram@vim.org>
parents:
21150
diff
changeset
|
1964 CheckDefFailure(['for i in "text"'], 'E1013:') |
20019
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
1965 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
|
1966 CheckDefFailure(['endfor'], 'E588:') |
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
1967 CheckDefFailure(['for i in range(3)', 'echo 3'], 'E170:') |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1968 enddef |
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1969 |
19593
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
1970 def Test_while_loop() |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
1971 let result = '' |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
1972 let cnt = 0 |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
1973 while cnt < 555 |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
1974 if cnt == 3 |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
1975 break |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
1976 endif |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
1977 cnt += 1 |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
1978 if cnt == 2 |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
1979 continue |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
1980 endif |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
1981 result ..= cnt .. '_' |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
1982 endwhile |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
1983 assert_equal('1_3_', result) |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
1984 enddef |
043989a2f449
patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents:
19585
diff
changeset
|
1985 |
19892
5feb426d2ea1
patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19890
diff
changeset
|
1986 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
|
1987 CheckDefFailure(['while xxx'], 'E1001:') |
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
1988 CheckDefFailure(['endwhile'], 'E588:') |
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
1989 CheckDefFailure(['continue'], 'E586:') |
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
1990 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
|
1991 CheckDefFailure(['break'], 'E587:') |
e9af5a09a55b
patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents:
20011
diff
changeset
|
1992 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
|
1993 CheckDefFailure(['while 1', 'echo 3'], 'E170:') |
19862
846fbbacce3a
patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19860
diff
changeset
|
1994 enddef |
846fbbacce3a
patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19860
diff
changeset
|
1995 |
19730
fe8ba2f82f59
patch 8.2.0421: interrupting with CTRL-C does not always work
Bram Moolenaar <Bram@vim.org>
parents:
19728
diff
changeset
|
1996 def Test_interrupt_loop() |
19736
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
1997 let caught = false |
19730
fe8ba2f82f59
patch 8.2.0421: interrupting with CTRL-C does not always work
Bram Moolenaar <Bram@vim.org>
parents:
19728
diff
changeset
|
1998 let x = 0 |
19736
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
1999 try |
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
2000 while 1 |
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
2001 x += 1 |
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
2002 if x == 100 |
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
2003 feedkeys("\<C-C>", 'Lt') |
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
2004 endif |
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
2005 endwhile |
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
2006 catch |
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
2007 caught = true |
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
2008 assert_equal(100, x) |
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
2009 endtry |
4174c4da6ff7
patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents:
19730
diff
changeset
|
2010 assert_true(caught, 'should have caught an exception') |
19730
fe8ba2f82f59
patch 8.2.0421: interrupting with CTRL-C does not always work
Bram Moolenaar <Bram@vim.org>
parents:
19728
diff
changeset
|
2011 enddef |
19726
ad37a198a708
patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents:
19623
diff
changeset
|
2012 |
19999
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
2013 def Test_automatic_line_continuation() |
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
2014 let mylist = [ |
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
2015 'one', |
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
2016 'two', |
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
2017 'three', |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2018 ] # comment |
19999
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
2019 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
|
2020 |
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
2021 let mydict = { |
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
2022 'one': 1, |
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
2023 'two': 2, |
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
2024 'three': |
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
2025 3, |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2026 } # comment |
19999
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
2027 assert_equal({'one': 1, 'two': 2, 'three': 3}, mydict) |
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
2028 mydict = #{ |
20023
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20019
diff
changeset
|
2029 one: 1, # comment |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20019
diff
changeset
|
2030 two: # comment |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20019
diff
changeset
|
2031 2, # comment |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20019
diff
changeset
|
2032 three: 3 # comment |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20019
diff
changeset
|
2033 } |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20019
diff
changeset
|
2034 assert_equal(#{one: 1, two: 2, three: 3}, mydict) |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20019
diff
changeset
|
2035 mydict = #{ |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20019
diff
changeset
|
2036 one: 1, |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20019
diff
changeset
|
2037 two: |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20019
diff
changeset
|
2038 2, |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20019
diff
changeset
|
2039 three: 3 |
19999
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
2040 } |
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
2041 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
|
2042 |
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
2043 assert_equal( |
628011800942
patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
19999
diff
changeset
|
2044 ['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
|
2045 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
|
2046 ) |
19999
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
2047 enddef |
844c7646f61b
patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents:
19962
diff
changeset
|
2048 |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2049 def Test_vim9_comment() |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2050 CheckScriptSuccess([ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2051 'vim9script', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2052 '# something', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2053 ]) |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2054 CheckScriptFailure([ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2055 'vim9script', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2056 ':# something', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2057 ], 'E488:') |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2058 CheckScriptFailure([ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2059 '# something', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2060 ], 'E488:') |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2061 CheckScriptFailure([ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2062 ':# something', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2063 ], 'E488:') |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2064 |
20061
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2065 { # block start |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2066 } # block end |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2067 CheckDefFailure([ |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2068 '{# comment', |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2069 ], 'E488:') |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2070 CheckDefFailure([ |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2071 '{', |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2072 '}# comment', |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2073 ], 'E488:') |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2074 |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2075 echo "yes" # comment |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2076 CheckDefFailure([ |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2077 'echo "yes"# comment', |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2078 ], 'E488:') |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2079 CheckScriptSuccess([ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2080 'vim9script', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2081 'echo "yes" # something', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2082 ]) |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2083 CheckScriptFailure([ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2084 'vim9script', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2085 'echo "yes"# something', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2086 ], 'E121:') |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2087 CheckScriptFailure([ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2088 'vim9script', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2089 'echo# something', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2090 ], 'E121:') |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2091 CheckScriptFailure([ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2092 'echo "yes" # something', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2093 ], 'E121:') |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2094 |
20061
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2095 exe "echo" # comment |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2096 CheckDefFailure([ |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2097 'exe "echo"# comment', |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2098 ], 'E488:') |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2099 CheckScriptSuccess([ |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2100 'vim9script', |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2101 'exe "echo" # something', |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2102 ]) |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2103 CheckScriptFailure([ |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2104 'vim9script', |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2105 'exe "echo"# something', |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2106 ], 'E121:') |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2107 CheckDefFailure([ |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2108 'exe # comment', |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2109 ], 'E1015:') |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2110 CheckScriptFailure([ |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2111 'vim9script', |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2112 'exe# something', |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2113 ], 'E121:') |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2114 CheckScriptFailure([ |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2115 'exe "echo" # something', |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2116 ], 'E121:') |
6e6a75800884
patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
20059
diff
changeset
|
2117 |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2118 CheckDefFailure([ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2119 'try# comment', |
20113
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2120 ' echo "yes"', |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2121 'catch', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2122 'endtry', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2123 ], 'E488:') |
20113
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2124 CheckScriptFailure([ |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2125 'vim9script', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2126 'try# comment', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2127 'echo "yes"', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2128 ], 'E488:') |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2129 CheckDefFailure([ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2130 'try', |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2131 ' throw#comment', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2132 'catch', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2133 'endtry', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2134 ], 'E1015:') |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2135 CheckDefFailure([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2136 'try', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2137 ' throw "yes"#comment', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2138 'catch', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2139 'endtry', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2140 ], 'E488:') |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2141 CheckDefFailure([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2142 'try', |
20113
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2143 ' echo "yes"', |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2144 'catch# comment', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2145 'endtry', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2146 ], 'E488:') |
20113
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2147 CheckScriptFailure([ |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2148 'vim9script', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2149 'try', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2150 ' echo "yes"', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2151 'catch# comment', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2152 'endtry', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2153 ], 'E654:') |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2154 CheckDefFailure([ |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2155 'try', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2156 ' echo "yes"', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2157 'catch /pat/# comment', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2158 'endtry', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2159 ], 'E488:') |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2160 CheckDefFailure([ |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2161 'try', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2162 'echo "yes"', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2163 'catch', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2164 'endtry# comment', |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2165 ], 'E488:') |
20113
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2166 CheckScriptFailure([ |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2167 'vim9script', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2168 'try', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2169 ' echo "yes"', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2170 'catch', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2171 'endtry# comment', |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
21216
diff
changeset
|
2172 ], 'E488:') |
20113
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2173 |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2174 CheckScriptSuccess([ |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2175 'vim9script', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2176 'hi # comment', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2177 ]) |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2178 CheckScriptFailure([ |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2179 'vim9script', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2180 'hi# comment', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2181 ], 'E416:') |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2182 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2183 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2184 'hi Search # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2185 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2186 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2187 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2188 'hi Search# comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2189 ], 'E416:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2190 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2191 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2192 '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
|
2193 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2194 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2195 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2196 '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
|
2197 ], 'E413:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2198 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2199 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2200 '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
|
2201 'hi clear # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2202 ]) |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2203 # 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
|
2204 # 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
|
2205 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2206 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2207 'hi clear# comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2208 ], 'E416:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2209 |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2210 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2211 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2212 '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
|
2213 '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
|
2214 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2215 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2216 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2217 '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
|
2218 '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
|
2219 ], 'E488:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2220 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2221 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2222 'match # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2223 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2224 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2225 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2226 'match# comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2227 ], 'E475:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2228 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2229 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2230 'match none # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2231 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2232 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2233 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2234 'match none# comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2235 ], 'E475:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2236 |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2237 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2238 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2239 'menutrans clear # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2240 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2241 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2242 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2243 '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
|
2244 ], 'E474:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2245 |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2246 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2247 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2248 'syntax clear # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2249 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2250 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2251 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2252 '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
|
2253 ], 'E28:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2254 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2255 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2256 '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
|
2257 '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
|
2258 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2259 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2260 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2261 '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
|
2262 '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
|
2263 ], 'E28:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2264 |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2265 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2266 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2267 'syntax list # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2268 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2269 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2270 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2271 '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
|
2272 ], 'E28:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2273 |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2274 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2275 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2276 '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
|
2277 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2278 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2279 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2280 '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
|
2281 ], 'E475:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2282 |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2283 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2284 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2285 '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
|
2286 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2287 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2288 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2289 '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
|
2290 ], 'E789:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2291 |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2292 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2293 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2294 '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
|
2295 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2296 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2297 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2298 '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
|
2299 ], 'E402:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2300 |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2301 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2302 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2303 '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
|
2304 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2305 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2306 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2307 '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
|
2308 ], 'E475:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2309 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2310 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2311 '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
|
2312 ], 'E406:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2313 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2314 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2315 '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
|
2316 ], 'E475:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2317 |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2318 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2319 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2320 '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
|
2321 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2322 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2323 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2324 '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
|
2325 ], 'E402:') |
20116
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2326 |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2327 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2328 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2329 'syntax sync # comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2330 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2331 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2332 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2333 'syntax sync# comment', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2334 ], 'E404:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2335 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2336 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2337 '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
|
2338 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2339 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2340 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2341 '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
|
2342 ], 'E404:') |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2343 |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2344 CheckScriptSuccess([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2345 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2346 '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
|
2347 ]) |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2348 CheckScriptFailure([ |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2349 'vim9script', |
513c62184ed8
patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20113
diff
changeset
|
2350 '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
|
2351 ], 'E475:') |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2352 |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2353 CheckScriptSuccess([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2354 'vim9script', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2355 '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
|
2356 'command Echo # comment', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2357 ]) |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2358 CheckScriptFailure([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2359 'vim9script', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2360 '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
|
2361 'Echo', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2362 ], 'E121:') |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2363 CheckScriptFailure([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2364 'vim9script', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2365 'command Echo# comment', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2366 ], 'E182:') |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2367 CheckScriptFailure([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2368 'vim9script', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2369 'command Echo echo', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2370 'command Echo# comment', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2371 ], 'E182:') |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2372 |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2373 CheckScriptSuccess([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2374 'vim9script', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2375 'function # comment', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2376 ]) |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2377 CheckScriptFailure([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2378 'vim9script', |
21528
e0aa9b81f6a9
patch 8.2.1314: Vim9: rule for comment after :function is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21526
diff
changeset
|
2379 'function " comment', |
e0aa9b81f6a9
patch 8.2.1314: Vim9: rule for comment after :function is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21526
diff
changeset
|
2380 ], 'E129:') |
e0aa9b81f6a9
patch 8.2.1314: Vim9: rule for comment after :function is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21526
diff
changeset
|
2381 CheckScriptFailure([ |
e0aa9b81f6a9
patch 8.2.1314: Vim9: rule for comment after :function is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21526
diff
changeset
|
2382 'vim9script', |
20138
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2383 'function# comment', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2384 ], 'E129:') |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2385 CheckScriptSuccess([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2386 'vim9script', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2387 'function CheckScriptSuccess # comment', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2388 ]) |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2389 CheckScriptFailure([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2390 'vim9script', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2391 'function CheckScriptSuccess# comment', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2392 ], 'E488:') |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2393 |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2394 CheckScriptSuccess([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2395 'vim9script', |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2396 '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
|
2397 'endfunc', |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2398 '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
|
2399 ]) |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2400 CheckScriptFailure([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2401 'vim9script', |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2402 '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
|
2403 'endfunc', |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2404 '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
|
2405 ], 'E488:') |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2406 |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2407 CheckScriptSuccess([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2408 'vim9script', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2409 '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
|
2410 ]) |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2411 CheckScriptFailure([ |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2412 'vim9script', |
d0a9766167ab
patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20116
diff
changeset
|
2413 '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
|
2414 ], 'E488:') |
21435
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2415 |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2416 CheckScriptFailure([ |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2417 '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
|
2418 'enddef', |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2419 ], 'E488:') |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2420 CheckScriptFailure([ |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2421 'vim9script', |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2422 '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
|
2423 'enddef', |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2424 ], 'E488:') |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2425 |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2426 CheckScriptSuccess([ |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2427 '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
|
2428 'endfunc', |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2429 ]) |
21528
e0aa9b81f6a9
patch 8.2.1314: Vim9: rule for comment after :function is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21526
diff
changeset
|
2430 CheckScriptSuccess([ |
21435
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2431 'vim9script', |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2432 '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
|
2433 'endfunc', |
21528
e0aa9b81f6a9
patch 8.2.1314: Vim9: rule for comment after :function is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21526
diff
changeset
|
2434 ]) |
21435
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2435 |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2436 CheckScriptSuccess([ |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2437 '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
|
2438 'enddef', |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2439 ]) |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2440 CheckScriptFailure([ |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2441 '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
|
2442 'endfunc', |
8ec9e2b54ce7
patch 8.2.1268: Vim9: no error for using double quote comment
Bram Moolenaar <Bram@vim.org>
parents:
21413
diff
changeset
|
2443 ], 'E488:') |
20113
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2444 enddef |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2445 |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2446 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
|
2447 CheckCanRunGui |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2448 |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2449 CheckScriptFailure([ |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2450 'vim9script', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2451 'gui#comment' |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2452 ], 'E499:') |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2453 CheckScriptFailure([ |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2454 'vim9script', |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2455 'gui -f#comment' |
2c23053c654a
patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20111
diff
changeset
|
2456 ], 'E499:') |
20059
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2457 enddef |
de756b3f4dee
patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents:
20055
diff
changeset
|
2458 |
20079
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
2459 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
|
2460 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
|
2461 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
|
2462 |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
2463 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
|
2464 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
|
2465 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
|
2466 |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
2467 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
|
2468 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
|
2469 |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
2470 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
|
2471 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
|
2472 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
|
2473 |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
2474 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
|
2475 |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
2476 au! TabEnter |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
2477 unlet g:entered |
20091
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
2478 |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
2479 CheckScriptSuccess([ |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
2480 '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
|
2481 '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
|
2482 '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
|
2483 '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
|
2484 't:var = 888', |
20091
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
2485 '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
|
2486 ]) |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
2487 |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
2488 CheckScriptFailure([ |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
2489 'vim9script', |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
2490 'let 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
|
2491 ], '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
|
2492 |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
2493 CheckScriptFailure([ |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
2494 'vim9script', |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
2495 'let b:var = 123', |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
2496 ], '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
|
2497 |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
2498 CheckScriptFailure([ |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
2499 'vim9script', |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
2500 'let w:var = 123', |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
2501 ], '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
|
2502 |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
2503 CheckScriptFailure([ |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
2504 'vim9script', |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
2505 'let t:var = 123', |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
2506 ], '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
|
2507 |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
2508 CheckScriptFailure([ |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
2509 'vim9script', |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
2510 'let v:version = 123', |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
2511 ], '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
|
2512 |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
2513 CheckScriptFailure([ |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
2514 'vim9script', |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
2515 'let $VARIABLE = "text"', |
6b4b887a12f0
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
2516 ], '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
|
2517 |
0653b9b72091
patch 8.2.1024: Vim9: no error for using "let g:var = val"
Bram Moolenaar <Bram@vim.org>
parents:
20921
diff
changeset
|
2518 CheckScriptFailure([ |
0653b9b72091
patch 8.2.1024: Vim9: no error for using "let g:var = val"
Bram Moolenaar <Bram@vim.org>
parents:
20921
diff
changeset
|
2519 'vim9script', |
0653b9b72091
patch 8.2.1024: Vim9: no error for using "let g:var = val"
Bram Moolenaar <Bram@vim.org>
parents:
20921
diff
changeset
|
2520 '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
|
2521 'unlet g:var# comment1', |
20091
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
2522 ], 'E108:') |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
2523 |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
2524 CheckScriptFailure([ |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
2525 'let g:var = 123', |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
2526 'unlet g:var # something', |
a64c16ff98b8
patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
2527 ], 'E488:') |
20111
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2528 |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2529 CheckScriptSuccess([ |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2530 'vim9script', |
20397
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2531 '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
|
2532 ' echo "yes"', |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2533 'elseif 2 #comment', |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2534 ' echo "no"', |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2535 'endif', |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2536 ]) |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2537 |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2538 CheckScriptFailure([ |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2539 'vim9script', |
20397
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2540 '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
|
2541 ' echo "yes"', |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2542 'endif', |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2543 ], 'E15:') |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2544 |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2545 CheckScriptFailure([ |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2546 'vim9script', |
20397
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2547 '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
|
2548 ' echo "yes"', |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2549 'elseif 2#comment', |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2550 ' echo "no"', |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2551 'endif', |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2552 ], 'E15:') |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2553 |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2554 CheckScriptSuccess([ |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2555 'vim9script', |
20397
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2556 'let 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
|
2557 ]) |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2558 |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2559 CheckScriptFailure([ |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2560 'vim9script', |
20397
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2561 'let v = 1# comment6', |
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2562 ], 'E15:') |
20111
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2563 |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2564 CheckScriptSuccess([ |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2565 'vim9script', |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2566 'new' |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2567 'call 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
|
2568 ':$', |
20111
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2569 'dsearch /pat/ #comment', |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2570 'bwipe!', |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2571 ]) |
f40231487a49
patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents:
20099
diff
changeset
|
2572 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2573 CheckScriptFailure([ |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2574 'vim9script', |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2575 'new' |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2576 'call setline(1, ["# define pat", "last"])', |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2577 ':$', |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2578 '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
|
2579 'bwipe!', |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2580 ], 'E488:') |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2581 |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2582 CheckScriptFailure([ |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2583 'vim9script', |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2584 'func! SomeFunc()', |
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2585 ], 'E477:') |
20079
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
2586 enddef |
336483164ca6
patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents:
20061
diff
changeset
|
2587 |
20351
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
2588 def Test_finish() |
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
2589 let lines =<< trim END |
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
2590 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
|
2591 g:res = 'one' |
20351
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
2592 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
|
2593 g:res = 'two' |
20351
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
2594 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
|
2595 g:res = 'three' |
20351
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
2596 END |
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
2597 writefile(lines, 'Xfinished') |
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
2598 source Xfinished |
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
2599 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
|
2600 |
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
2601 unlet g:res |
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
2602 delete('Xfinished') |
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
2603 enddef |
680296770464
patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
2604 |
20397
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2605 def Test_let_func_call() |
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2606 let lines =<< trim END |
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2607 vim9script |
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2608 func GetValue() |
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2609 if exists('g:count') |
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2610 let g:count += 1 |
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2611 else |
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2612 let g:count = 1 |
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2613 endif |
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2614 return 'this' |
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2615 endfunc |
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2616 let val: string = GetValue() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2617 # env var is always a string |
20435
61d2eb1413f2
patch 8.2.0772: Vim9: some variable initializations not tested
Bram Moolenaar <Bram@vim.org>
parents:
20419
diff
changeset
|
2618 let env = $TERM |
20397
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2619 END |
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2620 writefile(lines, 'Xfinished') |
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2621 source Xfinished |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2622 # GetValue() is not called during discovery phase |
20397
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2623 assert_equal(1, g:count) |
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2624 |
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2625 unlet g:count |
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2626 delete('Xfinished') |
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2627 enddef |
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2628 |
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2629 def Test_let_missing_type() |
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2630 let lines =<< trim END |
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2631 vim9script |
20435
61d2eb1413f2
patch 8.2.0772: Vim9: some variable initializations not tested
Bram Moolenaar <Bram@vim.org>
parents:
20419
diff
changeset
|
2632 let var = g:unknown |
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
|
2633 END |
20528
489cb75c76b6
patch 8.2.0818: Vim9: using a discovery phase doesn't work well
Bram Moolenaar <Bram@vim.org>
parents:
20504
diff
changeset
|
2634 CheckScriptFailure(lines, 'E121:') |
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
|
2635 |
918b9a05cf35
patch 8.2.0755: Vim9: No error when variable initializer is not a constant
Bram Moolenaar <Bram@vim.org>
parents:
20399
diff
changeset
|
2636 lines =<< trim END |
918b9a05cf35
patch 8.2.0755: Vim9: No error when variable initializer is not a constant
Bram Moolenaar <Bram@vim.org>
parents:
20399
diff
changeset
|
2637 vim9script |
918b9a05cf35
patch 8.2.0755: Vim9: No error when variable initializer is not a constant
Bram Moolenaar <Bram@vim.org>
parents:
20399
diff
changeset
|
2638 let nr: number = 123 |
918b9a05cf35
patch 8.2.0755: Vim9: No error when variable initializer is not a constant
Bram Moolenaar <Bram@vim.org>
parents:
20399
diff
changeset
|
2639 let var = nr |
918b9a05cf35
patch 8.2.0755: Vim9: No error when variable initializer is not a constant
Bram Moolenaar <Bram@vim.org>
parents:
20399
diff
changeset
|
2640 END |
20528
489cb75c76b6
patch 8.2.0818: Vim9: using a discovery phase doesn't work well
Bram Moolenaar <Bram@vim.org>
parents:
20504
diff
changeset
|
2641 CheckScriptSuccess(lines) |
20397
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2642 enddef |
c225be44692a
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents:
20351
diff
changeset
|
2643 |
20840
0600ab7b9f09
patch 8.2.0972: Vim9 script variable declarations need a type
Bram Moolenaar <Bram@vim.org>
parents:
20816
diff
changeset
|
2644 def Test_let_declaration() |
0600ab7b9f09
patch 8.2.0972: Vim9 script variable declarations need a type
Bram Moolenaar <Bram@vim.org>
parents:
20816
diff
changeset
|
2645 let lines =<< trim END |
0600ab7b9f09
patch 8.2.0972: Vim9 script variable declarations need a type
Bram Moolenaar <Bram@vim.org>
parents:
20816
diff
changeset
|
2646 vim9script |
0600ab7b9f09
patch 8.2.0972: Vim9 script variable declarations need a type
Bram Moolenaar <Bram@vim.org>
parents:
20816
diff
changeset
|
2647 let var: string |
0600ab7b9f09
patch 8.2.0972: Vim9 script variable declarations need a type
Bram Moolenaar <Bram@vim.org>
parents:
20816
diff
changeset
|
2648 g:var_uninit = var |
0600ab7b9f09
patch 8.2.0972: Vim9 script variable declarations need a type
Bram Moolenaar <Bram@vim.org>
parents:
20816
diff
changeset
|
2649 var = 'text' |
0600ab7b9f09
patch 8.2.0972: Vim9 script variable declarations need a type
Bram Moolenaar <Bram@vim.org>
parents:
20816
diff
changeset
|
2650 g:var_test = var |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2651 # prefixing s: is optional |
20846
709379ab5110
patch 8.2.0975: Vim9: script variable does not accept optional s: prefix
Bram Moolenaar <Bram@vim.org>
parents:
20842
diff
changeset
|
2652 s:var = 'prefixed' |
709379ab5110
patch 8.2.0975: Vim9: script variable does not accept optional s: prefix
Bram Moolenaar <Bram@vim.org>
parents:
20842
diff
changeset
|
2653 g:var_prefixed = s:var |
709379ab5110
patch 8.2.0975: Vim9: script variable does not accept optional s: prefix
Bram Moolenaar <Bram@vim.org>
parents:
20842
diff
changeset
|
2654 |
709379ab5110
patch 8.2.0975: Vim9: script variable does not accept optional s: prefix
Bram Moolenaar <Bram@vim.org>
parents:
20842
diff
changeset
|
2655 let s:other: number |
709379ab5110
patch 8.2.0975: Vim9: script variable does not accept optional s: prefix
Bram Moolenaar <Bram@vim.org>
parents:
20842
diff
changeset
|
2656 other = 1234 |
709379ab5110
patch 8.2.0975: Vim9: script variable does not accept optional s: prefix
Bram Moolenaar <Bram@vim.org>
parents:
20842
diff
changeset
|
2657 g:other_var = other |
20840
0600ab7b9f09
patch 8.2.0972: Vim9 script variable declarations need a type
Bram Moolenaar <Bram@vim.org>
parents:
20816
diff
changeset
|
2658 END |
0600ab7b9f09
patch 8.2.0972: Vim9 script variable declarations need a type
Bram Moolenaar <Bram@vim.org>
parents:
20816
diff
changeset
|
2659 CheckScriptSuccess(lines) |
0600ab7b9f09
patch 8.2.0972: Vim9 script variable declarations need a type
Bram Moolenaar <Bram@vim.org>
parents:
20816
diff
changeset
|
2660 assert_equal('', g:var_uninit) |
0600ab7b9f09
patch 8.2.0972: Vim9 script variable declarations need a type
Bram Moolenaar <Bram@vim.org>
parents:
20816
diff
changeset
|
2661 assert_equal('text', g:var_test) |
20846
709379ab5110
patch 8.2.0975: Vim9: script variable does not accept optional s: prefix
Bram Moolenaar <Bram@vim.org>
parents:
20842
diff
changeset
|
2662 assert_equal('prefixed', g:var_prefixed) |
709379ab5110
patch 8.2.0975: Vim9: script variable does not accept optional s: prefix
Bram Moolenaar <Bram@vim.org>
parents:
20842
diff
changeset
|
2663 assert_equal(1234, g:other_var) |
20840
0600ab7b9f09
patch 8.2.0972: Vim9 script variable declarations need a type
Bram Moolenaar <Bram@vim.org>
parents:
20816
diff
changeset
|
2664 |
0600ab7b9f09
patch 8.2.0972: Vim9 script variable declarations need a type
Bram Moolenaar <Bram@vim.org>
parents:
20816
diff
changeset
|
2665 unlet g:var_uninit |
0600ab7b9f09
patch 8.2.0972: Vim9 script variable declarations need a type
Bram Moolenaar <Bram@vim.org>
parents:
20816
diff
changeset
|
2666 unlet g:var_test |
20846
709379ab5110
patch 8.2.0975: Vim9: script variable does not accept optional s: prefix
Bram Moolenaar <Bram@vim.org>
parents:
20842
diff
changeset
|
2667 unlet g:var_prefixed |
709379ab5110
patch 8.2.0975: Vim9: script variable does not accept optional s: prefix
Bram Moolenaar <Bram@vim.org>
parents:
20842
diff
changeset
|
2668 unlet g:other_var |
20840
0600ab7b9f09
patch 8.2.0972: Vim9 script variable declarations need a type
Bram Moolenaar <Bram@vim.org>
parents:
20816
diff
changeset
|
2669 enddef |
0600ab7b9f09
patch 8.2.0972: Vim9 script variable declarations need a type
Bram Moolenaar <Bram@vim.org>
parents:
20816
diff
changeset
|
2670 |
20915
a3853794a768
patch 8.2.1009: Vim9: some failures not checked for
Bram Moolenaar <Bram@vim.org>
parents:
20899
diff
changeset
|
2671 def Test_let_declaration_fails() |
a3853794a768
patch 8.2.1009: Vim9: some failures not checked for
Bram Moolenaar <Bram@vim.org>
parents:
20899
diff
changeset
|
2672 let lines =<< trim END |
a3853794a768
patch 8.2.1009: Vim9: some failures not checked for
Bram Moolenaar <Bram@vim.org>
parents:
20899
diff
changeset
|
2673 vim9script |
a3853794a768
patch 8.2.1009: Vim9: some failures not checked for
Bram Moolenaar <Bram@vim.org>
parents:
20899
diff
changeset
|
2674 const var: string |
a3853794a768
patch 8.2.1009: Vim9: some failures not checked for
Bram Moolenaar <Bram@vim.org>
parents:
20899
diff
changeset
|
2675 END |
a3853794a768
patch 8.2.1009: Vim9: some failures not checked for
Bram Moolenaar <Bram@vim.org>
parents:
20899
diff
changeset
|
2676 CheckScriptFailure(lines, 'E1021:') |
a3853794a768
patch 8.2.1009: Vim9: some failures not checked for
Bram Moolenaar <Bram@vim.org>
parents:
20899
diff
changeset
|
2677 |
a3853794a768
patch 8.2.1009: Vim9: some failures not checked for
Bram Moolenaar <Bram@vim.org>
parents:
20899
diff
changeset
|
2678 lines =<< trim END |
a3853794a768
patch 8.2.1009: Vim9: some failures not checked for
Bram Moolenaar <Bram@vim.org>
parents:
20899
diff
changeset
|
2679 vim9script |
a3853794a768
patch 8.2.1009: Vim9: some failures not checked for
Bram Moolenaar <Bram@vim.org>
parents:
20899
diff
changeset
|
2680 let 9var: string |
a3853794a768
patch 8.2.1009: Vim9: some failures not checked for
Bram Moolenaar <Bram@vim.org>
parents:
20899
diff
changeset
|
2681 END |
a3853794a768
patch 8.2.1009: Vim9: some failures not checked for
Bram Moolenaar <Bram@vim.org>
parents:
20899
diff
changeset
|
2682 CheckScriptFailure(lines, 'E475:') |
a3853794a768
patch 8.2.1009: Vim9: some failures not checked for
Bram Moolenaar <Bram@vim.org>
parents:
20899
diff
changeset
|
2683 enddef |
a3853794a768
patch 8.2.1009: Vim9: some failures not checked for
Bram Moolenaar <Bram@vim.org>
parents:
20899
diff
changeset
|
2684 |
20842
bacc2ab11810
patch 8.2.0973: Vim9: type is not checked when assigning to a script variable
Bram Moolenaar <Bram@vim.org>
parents:
20840
diff
changeset
|
2685 def Test_let_type_check() |
bacc2ab11810
patch 8.2.0973: Vim9: type is not checked when assigning to a script variable
Bram Moolenaar <Bram@vim.org>
parents:
20840
diff
changeset
|
2686 let lines =<< trim END |
bacc2ab11810
patch 8.2.0973: Vim9: type is not checked when assigning to a script variable
Bram Moolenaar <Bram@vim.org>
parents:
20840
diff
changeset
|
2687 vim9script |
bacc2ab11810
patch 8.2.0973: Vim9: type is not checked when assigning to a script variable
Bram Moolenaar <Bram@vim.org>
parents:
20840
diff
changeset
|
2688 let var: string |
bacc2ab11810
patch 8.2.0973: Vim9: type is not checked when assigning to a script variable
Bram Moolenaar <Bram@vim.org>
parents:
20840
diff
changeset
|
2689 var = 1234 |
bacc2ab11810
patch 8.2.0973: Vim9: type is not checked when assigning to a script variable
Bram Moolenaar <Bram@vim.org>
parents:
20840
diff
changeset
|
2690 END |
bacc2ab11810
patch 8.2.0973: Vim9: type is not checked when assigning to a script variable
Bram Moolenaar <Bram@vim.org>
parents:
20840
diff
changeset
|
2691 CheckScriptFailure(lines, 'E1013:') |
20846
709379ab5110
patch 8.2.0975: Vim9: script variable does not accept optional s: prefix
Bram Moolenaar <Bram@vim.org>
parents:
20842
diff
changeset
|
2692 |
709379ab5110
patch 8.2.0975: Vim9: script variable does not accept optional s: prefix
Bram Moolenaar <Bram@vim.org>
parents:
20842
diff
changeset
|
2693 lines =<< trim END |
709379ab5110
patch 8.2.0975: Vim9: script variable does not accept optional s: prefix
Bram Moolenaar <Bram@vim.org>
parents:
20842
diff
changeset
|
2694 vim9script |
709379ab5110
patch 8.2.0975: Vim9: script variable does not accept optional s: prefix
Bram Moolenaar <Bram@vim.org>
parents:
20842
diff
changeset
|
2695 let var:string |
709379ab5110
patch 8.2.0975: Vim9: script variable does not accept optional s: prefix
Bram Moolenaar <Bram@vim.org>
parents:
20842
diff
changeset
|
2696 END |
709379ab5110
patch 8.2.0975: Vim9: script variable does not accept optional s: prefix
Bram Moolenaar <Bram@vim.org>
parents:
20842
diff
changeset
|
2697 CheckScriptFailure(lines, 'E1069:') |
20915
a3853794a768
patch 8.2.1009: Vim9: some failures not checked for
Bram Moolenaar <Bram@vim.org>
parents:
20899
diff
changeset
|
2698 |
a3853794a768
patch 8.2.1009: Vim9: some failures not checked for
Bram Moolenaar <Bram@vim.org>
parents:
20899
diff
changeset
|
2699 lines =<< trim END |
a3853794a768
patch 8.2.1009: Vim9: some failures not checked for
Bram Moolenaar <Bram@vim.org>
parents:
20899
diff
changeset
|
2700 vim9script |
a3853794a768
patch 8.2.1009: Vim9: some failures not checked for
Bram Moolenaar <Bram@vim.org>
parents:
20899
diff
changeset
|
2701 let var: asdf |
a3853794a768
patch 8.2.1009: Vim9: some failures not checked for
Bram Moolenaar <Bram@vim.org>
parents:
20899
diff
changeset
|
2702 END |
a3853794a768
patch 8.2.1009: Vim9: some failures not checked for
Bram Moolenaar <Bram@vim.org>
parents:
20899
diff
changeset
|
2703 CheckScriptFailure(lines, 'E1010:') |
20842
bacc2ab11810
patch 8.2.0973: Vim9: type is not checked when assigning to a script variable
Bram Moolenaar <Bram@vim.org>
parents:
20840
diff
changeset
|
2704 enddef |
bacc2ab11810
patch 8.2.0973: Vim9: type is not checked when assigning to a script variable
Bram Moolenaar <Bram@vim.org>
parents:
20840
diff
changeset
|
2705 |
20399
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
2706 def Test_forward_declaration() |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
2707 let lines =<< trim END |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
2708 vim9script |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
2709 def GetValue(): string |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
2710 return theVal |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
2711 enddef |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
2712 let 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
|
2713 g:initVal = GetValue() |
20399
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
2714 theVal = 'else' |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
2715 g:laterVal = GetValue() |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
2716 END |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
2717 writefile(lines, 'Xforward') |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
2718 source Xforward |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
2719 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
|
2720 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
|
2721 |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
2722 unlet g:initVal |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
2723 unlet g:laterVal |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
2724 delete('Xforward') |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
2725 enddef |
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
2726 |
20816
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
2727 def Test_source_vim9_from_legacy() |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
2728 let legacy_lines =<< trim END |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
2729 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
|
2730 |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
2731 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
|
2732 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
|
2733 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
|
2734 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
|
2735 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
|
2736 |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
2737 " 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
|
2738 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
|
2739 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
|
2740 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
|
2741 |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
2742 " 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
|
2743 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
|
2744 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
|
2745 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
|
2746 END |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
2747 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
|
2748 |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
2749 let vim9_lines =<< trim END |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
2750 vim9script |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
2751 let local = 'local' |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
2752 g:global = 'global' |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
2753 export let exported = 'exported' |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
2754 export def GetText(): string |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
2755 return 'text' |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
2756 enddef |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
2757 END |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
2758 writefile(vim9_lines, 'Xvim9_script.vim') |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
2759 |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
2760 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
|
2761 |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
2762 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
|
2763 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
|
2764 |
9faab49c880f
patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents:
20538
diff
changeset
|
2765 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
|
2766 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
|
2767 enddef |
20399
d1a54d2bd145
patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents:
20397
diff
changeset
|
2768 |
21150
951aad18b1af
patch 8.2.1126: Vim9: using :copen causes an error
Bram Moolenaar <Bram@vim.org>
parents:
21146
diff
changeset
|
2769 def Test_vim9_copen() |
951aad18b1af
patch 8.2.1126: Vim9: using :copen causes an error
Bram Moolenaar <Bram@vim.org>
parents:
21146
diff
changeset
|
2770 # 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
|
2771 copen |
951aad18b1af
patch 8.2.1126: Vim9: using :copen causes an error
Bram Moolenaar <Bram@vim.org>
parents:
21146
diff
changeset
|
2772 quit |
951aad18b1af
patch 8.2.1126: Vim9: using :copen causes an error
Bram Moolenaar <Bram@vim.org>
parents:
21146
diff
changeset
|
2773 enddef |
951aad18b1af
patch 8.2.1126: Vim9: using :copen causes an error
Bram Moolenaar <Bram@vim.org>
parents:
21146
diff
changeset
|
2774 |
21485
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2775 " test using a vim9script that is auto-loaded from an autocmd |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2776 def Test_vim9_autoload() |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2777 let lines =<< trim END |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2778 vim9script |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2779 def foo#test() |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2780 echomsg getreg('"') |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2781 enddef |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2782 END |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2783 |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2784 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
|
2785 writefile(lines, 'Xdir/autoload/foo.vim') |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2786 let save_rtp = &rtp |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2787 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
|
2788 augroup test |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2789 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
|
2790 augroup END |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2791 |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2792 normal Y |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2793 |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2794 augroup test |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2795 autocmd! |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2796 augroup END |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2797 delete('Xdir', 'rf') |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2798 &rtp = save_rtp |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2799 enddef |
afc8cc1a291f
patch 8.2.1293: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents:
21479
diff
changeset
|
2800 |
19894
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2801 " 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
|
2802 def Test_substitute_cmd() |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2803 new |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2804 setline(1, 'something') |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2805 :substitute(some(other( |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2806 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
|
2807 bwipe! |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2808 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
2809 # also when the context is Vim9 script |
19894
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2810 let lines =<< trim END |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2811 vim9script |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2812 new |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2813 setline(1, 'something') |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2814 :substitute(some(other( |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2815 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
|
2816 bwipe! |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2817 END |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2818 writefile(lines, 'Xvim9lines') |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2819 source Xvim9lines |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2820 |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2821 delete('Xvim9lines') |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2822 enddef |
ea4f8e789627
patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19892
diff
changeset
|
2823 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2824 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |