annotate src/testdir/test_vim9_script.vim @ 20846:709379ab5110 v8.2.0975

patch 8.2.0975: Vim9: script variable does not accept optional s: prefix Commit: https://github.com/vim/vim/commit/984dddbef421eda6b8ad60936f380c5f00aebb96 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jun 14 12:50:24 2020 +0200 patch 8.2.0975: Vim9: script variable does not accept optional s: prefix Problem: Vim9: script variable does not accept optional s: prefix. Solution: Adjust the accepted syntax.
author Bram Moolenaar <Bram@vim.org>
date Sun, 14 Jun 2020 13:00:04 +0200
parents bacc2ab11810
children 876e16c48bd1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
19528
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
4 source view_util.vim
20170
0612c64a2b87 patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents: 20142
diff changeset
5 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
6
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 def Test_syntax()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 let var = 234
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 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
10 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11
19326
d1810b726592 patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents: 19320
diff changeset
12 let s:appendToMe = 'xxx'
d1810b726592 patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents: 19320
diff changeset
13 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
14 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
15 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
16 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
17 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
18 let g:astring = 'text'
19326
d1810b726592 patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents: 19320
diff changeset
19
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 def Test_assignment()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 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
22 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
23 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
24 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
25
20142
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20138
diff changeset
26 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
27 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
28 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
29
19860
37c4779ca8f5 patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19822
diff changeset
30 let a: number = 6
37c4779ca8f5 patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19822
diff changeset
31 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
32
19558
8eeec8886c02 patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
33 if has('channel')
8eeec8886c02 patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
34 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
35 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
36 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
37 endif
19564
06f29b6ea04a patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents: 19558
diff changeset
38 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
39 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
40 endif
19912
d4fa9db88d16 patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents: 19904
diff changeset
41 let Funky1: func
d4fa9db88d16 patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents: 19904
diff changeset
42 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
43 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
44
19449
f8408ba21982 patch 8.2.0282: Vim9: setting number option not tested
Bram Moolenaar <Bram@vim.org>
parents: 19445
diff changeset
45 g:newvar = 'new'
f8408ba21982 patch 8.2.0282: Vim9: setting number option not tested
Bram Moolenaar <Bram@vim.org>
parents: 19445
diff changeset
46 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
47
f8408ba21982 patch 8.2.0282: Vim9: setting number option not tested
Bram Moolenaar <Bram@vim.org>
parents: 19445
diff changeset
48 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
49 g:existing = 'no'
f8408ba21982 patch 8.2.0282: Vim9: setting number option not tested
Bram Moolenaar <Bram@vim.org>
parents: 19445
diff changeset
50 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
51
19283
9dc843109c97 patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19281
diff changeset
52 v:char = 'abc'
19326
d1810b726592 patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents: 19320
diff changeset
53 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
54
9dc843109c97 patch 8.2.0200: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19281
diff changeset
55 $ENVVAR = 'foobar'
19326
d1810b726592 patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents: 19320
diff changeset
56 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
57 $ENVVAR = ''
19326
d1810b726592 patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents: 19320
diff changeset
58
19451
b26e96f7c12f patch 8.2.0283: Vim9: failing to load script var not tested
Bram Moolenaar <Bram@vim.org>
parents: 19449
diff changeset
59 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
60 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
61 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
62 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
63 s:newVar = 'new'
655631882288 patch 8.2.0285: unused error message; cannot create s:var
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
64 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
65
8a7bede7b138 patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
66 set ts=7
8a7bede7b138 patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
67 &ts += 1
8a7bede7b138 patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
68 assert_equal(8, &ts)
19878
dd3c80122a0e patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents: 19874
diff changeset
69 &ts -= 3
dd3c80122a0e patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents: 19874
diff changeset
70 assert_equal(5, &ts)
dd3c80122a0e patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents: 19874
diff changeset
71 &ts *= 2
dd3c80122a0e patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents: 19874
diff changeset
72 assert_equal(10, &ts)
dd3c80122a0e patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents: 19874
diff changeset
73 &ts /= 3
dd3c80122a0e patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents: 19874
diff changeset
74 assert_equal(3, &ts)
dd3c80122a0e patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents: 19874
diff changeset
75 set ts=10
dd3c80122a0e patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents: 19874
diff changeset
76 &ts %= 4
dd3c80122a0e patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents: 19874
diff changeset
77 assert_equal(2, &ts)
19872
8a7bede7b138 patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
78 call CheckDefFailure(['&notex += 3'], 'E113:')
8a7bede7b138 patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
79 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
80 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
81 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
82 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
83 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
84 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
85 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
86 # 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
87 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
88 &ts = 8
19872
8a7bede7b138 patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
89
8a7bede7b138 patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
90 g:inc_counter += 1
8a7bede7b138 patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
91 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
92
8a7bede7b138 patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
93 $SOME_ENV_VAR ..= 'more'
8a7bede7b138 patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
94 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
95 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
96 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
97
8a7bede7b138 patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
98 @a = 'areg'
8a7bede7b138 patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
99 @a ..= 'add'
8a7bede7b138 patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
100 assert_equal('aregadd', @a)
8a7bede7b138 patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19862
diff changeset
101 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
102 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
103
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
104 v:errmsg = 'none'
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
105 v:errmsg ..= 'again'
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
106 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
107 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
108 call CheckDefFailure(['v:errmsg += 123'], 'E1013:')
19912
d4fa9db88d16 patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents: 19904
diff changeset
109 enddef
d4fa9db88d16 patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents: 19904
diff changeset
110
20472
1338b4dcb885 patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents: 20435
diff changeset
111 def Test_assignment_list()
1338b4dcb885 patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents: 20435
diff changeset
112 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
113 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
114 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
115 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
116 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
117
1338b4dcb885 patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents: 20435
diff changeset
118 let listS: list<string> = []
1338b4dcb885 patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents: 20435
diff changeset
119 let listN: list<number> = []
1338b4dcb885 patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents: 20435
diff changeset
120
1338b4dcb885 patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents: 20435
diff changeset
121 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
122 list2[-1] = 99
1338b4dcb885 patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents: 20435
diff changeset
123 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
124 list2[-2] = 88
1338b4dcb885 patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents: 20435
diff changeset
125 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
126 list2[-3] = 77
1338b4dcb885 patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents: 20435
diff changeset
127 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
128 call CheckDefExecFailure(['let ll = [1, 2, 3]', 'll[-4] = 6'], 'E684:')
1338b4dcb885 patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents: 20435
diff changeset
129
1338b4dcb885 patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents: 20435
diff changeset
130 # type becomes list<any>
1338b4dcb885 patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents: 20435
diff changeset
131 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
132 enddef
1338b4dcb885 patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents: 20435
diff changeset
133
1338b4dcb885 patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents: 20435
diff changeset
134 def Test_assignment_dict()
1338b4dcb885 patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents: 20435
diff changeset
135 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
136 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
137 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
138 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
139 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
140
1338b4dcb885 patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents: 20435
diff changeset
141 call CheckDefExecFailure(['let dd = {}', 'dd[""] = 6'], 'E713:')
1338b4dcb885 patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents: 20435
diff changeset
142
1338b4dcb885 patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents: 20435
diff changeset
143 # type becomes dict<any>
1338b4dcb885 patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents: 20435
diff changeset
144 let somedict = rand() > 0 ? #{a: 1, b: 2} : #{a: 'a', b: 'b'}
1338b4dcb885 patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents: 20435
diff changeset
145 enddef
1338b4dcb885 patch 8.2.0790: Vim9: list index not well tested
Bram Moolenaar <Bram@vim.org>
parents: 20435
diff changeset
146
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
147 def Test_assignment_local()
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
148 " Test in a separated file in order not to the current buffer/window/tab is
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
149 " changed.
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
150 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
151 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
152 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
153 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
154
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
155 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
156 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
157 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
158 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
159 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
160 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
161 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
162 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
163
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
164 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
165 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
166 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
167 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
168 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
169 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
170 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
171
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
172 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
173 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
174 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
175 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
176 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
177 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
178 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
179 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
180 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
181 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
182 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
183 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
184
19912
d4fa9db88d16 patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents: 19904
diff changeset
185 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
186
20055
686deb5959c2 patch 8.2.0583: Vim9: # comment not recognized in :def function
Bram Moolenaar <Bram@vim.org>
parents: 20029
diff changeset
187 # Test default values.
19874
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
188 let thebool: bool
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
189 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
190
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
191 let thenumber: number
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
192 assert_equal(0, thenumber)
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
193
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
194 if has('float')
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
195 let thefloat: float
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
196 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
197 endif
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
198
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
199 let thestring: string
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
200 assert_equal('', thestring)
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
201
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
202 let theblob: blob
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
203 assert_equal(0z, theblob)
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
204
19912
d4fa9db88d16 patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents: 19904
diff changeset
205 let Thefunc: func
d4fa9db88d16 patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents: 19904
diff changeset
206 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
207
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
208 let thelist: list<any>
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
209 assert_equal([], thelist)
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
210
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
211 let thedict: dict<any>
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
212 assert_equal({}, thedict)
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
213
19890
2b117844f784 patch 8.2.0501: Vim9: script test fails when channel feature is missing
Bram Moolenaar <Bram@vim.org>
parents: 19878
diff changeset
214 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
215 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
216 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
217
19890
2b117844f784 patch 8.2.0501: Vim9: script test fails when channel feature is missing
Bram Moolenaar <Bram@vim.org>
parents: 19878
diff changeset
218 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
219 assert_equal(test_null_channel(), thechannel)
2b117844f784 patch 8.2.0501: Vim9: script test fails when channel feature is missing
Bram Moolenaar <Bram@vim.org>
parents: 19878
diff changeset
220 endif
19894
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
221
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
222 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
223 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
224 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
225
19962
12fa79cac39b patch 8.2.0537: Vim9: no check for sandbox when setting v:var
Bram Moolenaar <Bram@vim.org>
parents: 19932
diff changeset
226 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
227 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
228 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
229 enddef
12fa79cac39b patch 8.2.0537: Vim9: no check for sandbox when setting v:var
Bram Moolenaar <Bram@vim.org>
parents: 19932
diff changeset
230
20091
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
231 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
232 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
233 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
234 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
235
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
236 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
237 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
238
19860
37c4779ca8f5 patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19822
diff changeset
239 call CheckDefFailure(['let [a; b; c] = g:list'], 'E452:')
37c4779ca8f5 patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19822
diff changeset
240
19874
f92435f0f449 patch 8.2.0493: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19872
diff changeset
241 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
242 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
243 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
244
37c4779ca8f5 patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19822
diff changeset
245 call CheckDefFailure(['let $VAR = 5'], 'E1065:')
37c4779ca8f5 patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19822
diff changeset
246
37c4779ca8f5 patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19822
diff changeset
247 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
248 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
249
37c4779ca8f5 patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19822
diff changeset
250 call CheckDefFailure(['let g:var = 5'], 'E1016:')
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
251 call CheckDefFailure(['let w:var = 5'], 'E1079:')
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
252 call CheckDefFailure(['let b:var = 5'], 'E1078:')
7fc5d62fe2a5 patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
253 call CheckDefFailure(['let t:var = 5'], 'E1080:')
19860
37c4779ca8f5 patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19822
diff changeset
254
37c4779ca8f5 patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19822
diff changeset
255 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
256 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
257
20528
489cb75c76b6 patch 8.2.0818: Vim9: using a discovery phase doesn't work well
Bram Moolenaar <Bram@vim.org>
parents: 20504
diff changeset
258 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
259
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
260 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
261 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
262
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
263 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
264 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
265
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
266 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
267 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
268
19904
bd4f91762d0f patch 8.2.0508: Vim9: func and partial types not done yet
Bram Moolenaar <Bram@vim.org>
parents: 19894
diff changeset
269 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
270 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
271
12fa79cac39b patch 8.2.0537: Vim9: no check for sandbox when setting v:var
Bram Moolenaar <Bram@vim.org>
parents: 19932
diff changeset
272 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
273 call CheckDefFailure(['let var: dict<number'], 'E1009:')
20091
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
274 enddef
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
275
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
276 def Test_unlet()
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
277 g:somevar = 'yes'
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
278 assert_true(exists('g:somevar'))
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
279 unlet g:somevar
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
280 assert_false(exists('g:somevar'))
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
281 unlet! g:somevar
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
282
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
283 call CheckScriptFailure([
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
284 'vim9script',
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
285 'let svar = 123',
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
286 'unlet svar',
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
287 ], 'E1081:')
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
288 call CheckScriptFailure([
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
289 'vim9script',
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
290 'let svar = 123',
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
291 'unlet s:svar',
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
292 ], 'E1081:')
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
293 call CheckScriptFailure([
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
294 'vim9script',
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
295 'let svar = 123',
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
296 'def Func()',
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
297 ' unlet svar',
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
298 '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
299 'defcompile',
20091
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
300 ], 'E1081:')
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
301 call CheckScriptFailure([
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
302 'vim9script',
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
303 'let svar = 123',
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
304 'def Func()',
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
305 ' unlet s:svar',
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
306 '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
307 'defcompile',
20091
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
308 ], 'E1081:')
20099
058b41f85bcb patch 8.2.0605: Vim9: cannot unlet an environment variable
Bram Moolenaar <Bram@vim.org>
parents: 20091
diff changeset
309
058b41f85bcb patch 8.2.0605: Vim9: cannot unlet an environment variable
Bram Moolenaar <Bram@vim.org>
parents: 20091
diff changeset
310 $ENVVAR = 'foobar'
058b41f85bcb patch 8.2.0605: Vim9: cannot unlet an environment variable
Bram Moolenaar <Bram@vim.org>
parents: 20091
diff changeset
311 assert_equal('foobar', $ENVVAR)
058b41f85bcb patch 8.2.0605: Vim9: cannot unlet an environment variable
Bram Moolenaar <Bram@vim.org>
parents: 20091
diff changeset
312 unlet $ENVVAR
058b41f85bcb patch 8.2.0605: Vim9: cannot unlet an environment variable
Bram Moolenaar <Bram@vim.org>
parents: 20091
diff changeset
313 assert_equal('', $ENVVAR)
20091
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
314 enddef
19818
c1c88b333481 patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents: 19787
diff changeset
315
20189
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
316 def Test_delfunction()
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
317 " Check function is defined in script namespace
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
318 CheckScriptSuccess([
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
319 'vim9script',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
320 'func CheckMe()',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
321 ' return 123',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
322 'endfunc',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
323 '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
324 ])
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
325
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
326 " Check function in script namespace cannot be deleted
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
327 CheckScriptFailure([
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
328 'vim9script',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
329 'func DeleteMe1()',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
330 'endfunc',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
331 'delfunction DeleteMe1',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
332 ], 'E1084:')
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
333 CheckScriptFailure([
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
334 'vim9script',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
335 'func DeleteMe2()',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
336 'endfunc',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
337 'def DoThat()',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
338 ' delfunction DeleteMe2',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
339 'enddef',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
340 'DoThat()',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
341 ], 'E1084:')
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
342 CheckScriptFailure([
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
343 'vim9script',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
344 'def DeleteMe3()',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
345 'enddef',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
346 'delfunction DeleteMe3',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
347 ], 'E1084:')
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
348 CheckScriptFailure([
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
349 'vim9script',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
350 'def DeleteMe4()',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
351 'enddef',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
352 'def DoThat()',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
353 ' delfunction DeleteMe4',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
354 'enddef',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
355 'DoThat()',
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
356 ], 'E1084:')
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
357 enddef
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
358
19818
c1c88b333481 patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents: 19787
diff changeset
359 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
360 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
361 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
362 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
363 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
364
c1c88b333481 patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents: 19787
diff changeset
365 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
366 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
367
8eeec8886c02 patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents: 19532
diff changeset
368 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
369 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
370 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
371 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
372 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
373 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
374 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
375 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
376 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
377 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
378 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
379
5a397db2c1ed patch 8.2.0657: Vim9: no check if called variable is a FuncRef
Bram Moolenaar <Bram@vim.org>
parents: 20195
diff changeset
380 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
381 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
382 endfunc
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
383
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
384 func Test_const()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
385 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
386 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
387 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
388 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
389 endfunc
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
390
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
391 def Test_block()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
392 let outer = 1
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
393 {
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
394 let inner = 2
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
395 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
396 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
397 }
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
398 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
399 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
400
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
401 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
402 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
403 call CheckDefFailure(['}'], 'E1025:')
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
404 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
405 endfunc
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
406
19894
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
407 def Test_cmd_modifier()
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
408 tab echo '0'
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
409 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
410 enddef
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
411
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
412 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
413 let l = []
20059
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
414 try # comment
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
415 add(l, '1')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
416 throw 'wrong'
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
417 add(l, '2')
20059
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
418 catch # comment
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
419 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
420 finally # comment
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
421 add(l, '3')
20059
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
422 endtry # comment
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
423 assert_equal(['1', 'wrong', '3'], l)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
424 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
425
19445
6e27e1ffa2a6 patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents: 19443
diff changeset
426 def ThrowFromDef()
20138
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
427 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
428 enddef
6e27e1ffa2a6 patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents: 19443
diff changeset
429
6e27e1ffa2a6 patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents: 19443
diff changeset
430 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
431 try
6e27e1ffa2a6 patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents: 19443
diff changeset
432 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
433 catch
6e27e1ffa2a6 patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents: 19443
diff changeset
434 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
435 endtry
6e27e1ffa2a6 patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents: 19443
diff changeset
436 endfunc
6e27e1ffa2a6 patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents: 19443
diff changeset
437
6e27e1ffa2a6 patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents: 19443
diff changeset
438 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
439 try
6e27e1ffa2a6 patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents: 19443
diff changeset
440 ThrowFromDef()
6e27e1ffa2a6 patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents: 19443
diff changeset
441 catch
6e27e1ffa2a6 patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents: 19443
diff changeset
442 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
443 endtry
6e27e1ffa2a6 patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents: 19443
diff changeset
444 enddef
6e27e1ffa2a6 patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents: 19443
diff changeset
445
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
446 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
447 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
448 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
449 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
450 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
451 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
452 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
453 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
454
19445
6e27e1ffa2a6 patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents: 19443
diff changeset
455 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
456 CatchInFunc()
6e27e1ffa2a6 patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents: 19443
diff changeset
457 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
458
6e27e1ffa2a6 patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents: 19443
diff changeset
459 CatchInDef()
6e27e1ffa2a6 patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents: 19443
diff changeset
460 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
461
423b27246383 patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents: 19455
diff changeset
462 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
463 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
464 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
465
423b27246383 patch 8.2.0287: Vim9: return in try block not tested; catch not tested
Bram Moolenaar <Bram@vim.org>
parents: 19455
diff changeset
466 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
467 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
468 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
469 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
470 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
471 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
472 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
473 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
474 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
475 seq ..= 'x'
19892
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
476 catch ?a\?sdf?
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
477 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
478 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
479 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
480 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
481 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
482 enddef
6e27e1ffa2a6 patch 8.2.0280: Vim9: throw in :def function not caught higher up
Bram Moolenaar <Bram@vim.org>
parents: 19443
diff changeset
483
19892
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
484 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
485 call CheckDefFailure(['catch'], 'E603:')
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
486 call CheckDefFailure(['try', 'echo 0', 'catch','catch'], 'E1033:')
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
487 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
488 call CheckDefFailure(['finally'], 'E606:')
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
489 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
490 call CheckDefFailure(['endtry'], 'E602:')
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
491 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
492 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
493 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
494 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
495
20138
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
496 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
497 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
498 enddef
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
499
20291
f7b1e43beb8f patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents: 20289
diff changeset
500 if has('channel')
f7b1e43beb8f patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents: 20289
diff changeset
501 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
502
20291
f7b1e43beb8f patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents: 20289
diff changeset
503 def FuncWithError()
f7b1e43beb8f patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents: 20289
diff changeset
504 echomsg g:someJob
f7b1e43beb8f patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents: 20289
diff changeset
505 enddef
20289
208b38bddc36 patch 8.2.0700: Vim9: converting error message to exception not tested
Bram Moolenaar <Bram@vim.org>
parents: 20203
diff changeset
506
20291
f7b1e43beb8f patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents: 20289
diff changeset
507 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
508 try
f7b1e43beb8f patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents: 20289
diff changeset
509 call FuncWithError()
f7b1e43beb8f patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents: 20289
diff changeset
510 catch
f7b1e43beb8f patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents: 20289
diff changeset
511 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
512 endtry
f7b1e43beb8f patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents: 20289
diff changeset
513 endfunc
f7b1e43beb8f patch 8.2.0701: Vim9 test fails without job feature
Bram Moolenaar <Bram@vim.org>
parents: 20289
diff changeset
514 endif
20289
208b38bddc36 patch 8.2.0700: Vim9: converting error message to exception not tested
Bram Moolenaar <Bram@vim.org>
parents: 20203
diff changeset
515
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
516 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
517 vim9script
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
518 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
519 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
520 return name .. arg
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
521 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
522 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
523 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
524
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
525 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
526 export let exported = 9876
19326
d1810b726592 patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents: 19320
diff changeset
527 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
528 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
529 return 'Exported'
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
530 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
531 END
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
532
19623
2fee087c94cb patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents: 19593
diff changeset
533 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
534 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
535 vim9script
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
536 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
537 g:imported = exported
19326
d1810b726592 patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents: 19320
diff changeset
538 exported += 3
d1810b726592 patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents: 19320
diff changeset
539 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
540 g:imported_func = Exported()
19326
d1810b726592 patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents: 19320
diff changeset
541
d1810b726592 patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents: 19320
diff changeset
542 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
543 g:imported_name = exp_name
d1810b726592 patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents: 19320
diff changeset
544 exp_name ..= ' Doe'
d1810b726592 patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents: 19320
diff changeset
545 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
546 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
547 END
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
548
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
549 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
550 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
551
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
552 source Ximport.vim
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
553
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
554 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
555 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
556 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
557 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
558 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
559 assert_equal('Exported', g:imported_func)
19326
d1810b726592 patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents: 19320
diff changeset
560 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
561 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
562 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
563
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
564 unlet g:result
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
565 unlet g:localname
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
566 unlet g:imported
19326
d1810b726592 patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents: 19320
diff changeset
567 unlet g:imported_added
19583
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19579
diff changeset
568 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
569 unlet g:imported_func
19326
d1810b726592 patch 8.2.0221: no test for Vim9 += and ..=
Bram Moolenaar <Bram@vim.org>
parents: 19320
diff changeset
570 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
571 delete('Ximport.vim')
19509
17f0d6dc6a73 patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19507
diff changeset
572
19583
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19579
diff changeset
573 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
574 vim9script
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19579
diff changeset
575 def ImportInDef()
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19579
diff changeset
576 import exported from './Xexport.vim'
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19579
diff changeset
577 g:imported = exported
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19579
diff changeset
578 exported += 7
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19579
diff changeset
579 g:imported_added = exported
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19579
diff changeset
580 enddef
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19579
diff changeset
581 ImportInDef()
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19579
diff changeset
582 END
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19579
diff changeset
583 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
584 source Ximport2.vim
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19579
diff changeset
585 " TODO: this should be 9879
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19579
diff changeset
586 assert_equal(9876, g:imported)
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19579
diff changeset
587 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
588 unlet g:imported
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19579
diff changeset
589 unlet g:imported_added
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19579
diff changeset
590 delete('Ximport2.vim')
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19579
diff changeset
591
19509
17f0d6dc6a73 patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19507
diff changeset
592 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
593 vim9script
17f0d6dc6a73 patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19507
diff changeset
594 import * as Export from './Xexport.vim'
17f0d6dc6a73 patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19507
diff changeset
595 def UseExport()
17f0d6dc6a73 patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19507
diff changeset
596 g:imported = Export.exported
17f0d6dc6a73 patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19507
diff changeset
597 enddef
17f0d6dc6a73 patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19507
diff changeset
598 UseExport()
17f0d6dc6a73 patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19507
diff changeset
599 END
17f0d6dc6a73 patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19507
diff changeset
600 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
601 source Ximport.vim
19583
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19579
diff changeset
602 assert_equal(9883, g:imported)
19509
17f0d6dc6a73 patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19507
diff changeset
603
19818
c1c88b333481 patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents: 19787
diff changeset
604 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
605 vim9script
c1c88b333481 patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents: 19787
diff changeset
606 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
607 def Func()
c1c88b333481 patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents: 19787
diff changeset
608 let dummy = 1
c1c88b333481 patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents: 19787
diff changeset
609 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
610 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
611 defcompile
19818
c1c88b333481 patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents: 19787
diff changeset
612 END
c1c88b333481 patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents: 19787
diff changeset
613 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
614 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
615
c1c88b333481 patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents: 19787
diff changeset
616 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
617 vim9script
c1c88b333481 patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents: 19787
diff changeset
618 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
619 def Func()
c1c88b333481 patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents: 19787
diff changeset
620 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
621 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
622 defcompile
19818
c1c88b333481 patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents: 19787
diff changeset
623 END
c1c88b333481 patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents: 19787
diff changeset
624 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
625 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
626
c1c88b333481 patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents: 19787
diff changeset
627 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
628 vim9script
c1c88b333481 patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents: 19787
diff changeset
629 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
630 def Func()
c1c88b333481 patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents: 19787
diff changeset
631 let imported = Export.
c1c88b333481 patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents: 19787
diff changeset
632 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
633 defcompile
19818
c1c88b333481 patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents: 19787
diff changeset
634 END
c1c88b333481 patch 8.2.0465: Vim9: dead code and wrong return type
Bram Moolenaar <Bram@vim.org>
parents: 19787
diff changeset
635 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
636 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
637
19509
17f0d6dc6a73 patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19507
diff changeset
638 let import_star_lines =<< trim END
17f0d6dc6a73 patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19507
diff changeset
639 vim9script
17f0d6dc6a73 patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19507
diff changeset
640 import * from './Xexport.vim'
17f0d6dc6a73 patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19507
diff changeset
641 END
17f0d6dc6a73 patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19507
diff changeset
642 writefile(import_star_lines, 'Ximport.vim')
17f0d6dc6a73 patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19507
diff changeset
643 assert_fails('source Ximport.vim', 'E1045:')
17f0d6dc6a73 patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19507
diff changeset
644
19511
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
645 " try to import something that exists but is not exported
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
646 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
647 vim9script
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
648 import name from './Xexport.vim'
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
649 END
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
650 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
651 assert_fails('source Ximport.vim', 'E1049:')
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
652
19623
2fee087c94cb patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents: 19593
diff changeset
653 " try to import something that is already defined
2fee087c94cb patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents: 19593
diff changeset
654 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
655 vim9script
2fee087c94cb patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents: 19593
diff changeset
656 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
657 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
658 END
2fee087c94cb patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents: 19593
diff changeset
659 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
660 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
661
2fee087c94cb patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents: 19593
diff changeset
662 " try to import something that is already defined
2fee087c94cb patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents: 19593
diff changeset
663 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
664 vim9script
2fee087c94cb patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents: 19593
diff changeset
665 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
666 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
667 END
2fee087c94cb patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents: 19593
diff changeset
668 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
669 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
670
2fee087c94cb patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents: 19593
diff changeset
671 " try to import something that is already defined
2fee087c94cb patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents: 19593
diff changeset
672 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
673 vim9script
2fee087c94cb patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents: 19593
diff changeset
674 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
675 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
676 END
2fee087c94cb patch 8.2.0368: Vim9: import that redefines local variable does not fail
Bram Moolenaar <Bram@vim.org>
parents: 19593
diff changeset
677 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
678 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
679
19511
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
680 " import a very long name, requires making a copy
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
681 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
682 vim9script
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
683 import name012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 from './Xexport.vim'
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
684 END
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
685 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
686 assert_fails('source Ximport.vim', 'E1048:')
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
687
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
688 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
689 vim9script
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
690 import name './Xexport.vim'
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
691 END
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
692 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
693 assert_fails('source Ximport.vim', 'E1070:')
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
694
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
695 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
696 vim9script
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
697 import name from Xexport.vim
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
698 END
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
699 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
700 assert_fails('source Ximport.vim', 'E1071:')
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
701
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
702 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
703 vim9script
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
704 import name from './XnoExport.vim'
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
705 END
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
706 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
707 assert_fails('source Ximport.vim', 'E1053:')
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
708
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
709 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
710 vim9script
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
711 import {exported name} from './Xexport.vim'
7e76d5fba19f patch 8.2.0313: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19509
diff changeset
712 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
713 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
714 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
715
19509
17f0d6dc6a73 patch 8.2.0312: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19507
diff changeset
716 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
717 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
718 delete('Xexport.vim')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
719
19507
65049a682574 patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19497
diff changeset
720 " Check that in a Vim9 script 'cpo' is set to the Vim default.
65049a682574 patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19497
diff changeset
721 set cpo&vi
65049a682574 patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19497
diff changeset
722 let cpo_before = &cpo
65049a682574 patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19497
diff changeset
723 let lines =<< trim END
65049a682574 patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19497
diff changeset
724 vim9script
65049a682574 patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19497
diff changeset
725 g:cpo_in_vim9script = &cpo
65049a682574 patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19497
diff changeset
726 END
65049a682574 patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19497
diff changeset
727 writefile(lines, 'Xvim9_script')
65049a682574 patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19497
diff changeset
728 source Xvim9_script
65049a682574 patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19497
diff changeset
729 assert_equal(cpo_before, &cpo)
65049a682574 patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19497
diff changeset
730 set cpo&vim
65049a682574 patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19497
diff changeset
731 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
732 delete('Xvim9_script')
65049a682574 patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19497
diff changeset
733 enddef
65049a682574 patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19497
diff changeset
734
65049a682574 patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19497
diff changeset
735 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
736 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
737 CheckScriptFailure(['vim9script', 'scriptversion 2'], 'E1040:')
19507
65049a682574 patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19497
diff changeset
738 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
739 CheckScriptFailure(['import some from "./Xexport.vim"'], 'E1048:')
19507
65049a682574 patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19497
diff changeset
740 CheckScriptFailure(['vim9script', 'export let g:some'], 'E1044:')
65049a682574 patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19497
diff changeset
741 CheckScriptFailure(['vim9script', 'export echo 134'], 'E1043:')
65049a682574 patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19497
diff changeset
742
65049a682574 patch 8.2.0311: Vim9: insufficient script tests
Bram Moolenaar <Bram@vim.org>
parents: 19497
diff changeset
743 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
744 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
745 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
746
20189
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
747 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
748 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
749 vim9script
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
750 const var = ''
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
751 let valone = 1234
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
752 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
753 valone = 5678
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
754 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
755 END
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
756 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
757 let valtwo = 222
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
758 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
759 return valtwo
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
760 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
761 END
20195
a2447c58da25 patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents: 20189
diff changeset
762 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
763 source Xreload.vim
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
764 source Xreload.vim
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
765 source Xreload.vim
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
766
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
767 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
768 vim9script
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
769 def TheFunc()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
770 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
771 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
772 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
773 TheFunc()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
774 END
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
775 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
776 source Ximport.vim
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
777
20195
a2447c58da25 patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents: 20189
diff changeset
778 " Test that when not using "morelines" GetValtwo() and valtwo are still
a2447c58da25 patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents: 20189
diff changeset
779 " 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
780 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
781 source Ximport.vim
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
782
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
783 " cannot declare a var twice
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
784 lines =<< trim END
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
785 vim9script
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
786 let valone = 1234
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
787 let valone = 5678
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
788 END
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
789 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
790 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
791
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
792 delete('Xreload.vim')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
793 delete('Ximport.vim')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
794 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
795
20189
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
796 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
797 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
798 vim9script
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
799 def FuncYes(): string
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
800 return 'yes'
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
801 enddef
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
802 END
20195
a2447c58da25 patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents: 20189
diff changeset
803 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
804 def FuncNo(): string
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
805 return 'no'
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
806 enddef
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
807 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
808 assert_equal('yes', FuncYes())
20195
a2447c58da25 patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents: 20189
diff changeset
809 assert_equal('no', FuncNo())
a2447c58da25 patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents: 20189
diff changeset
810 enddef
a2447c58da25 patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents: 20189
diff changeset
811 END
a2447c58da25 patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents: 20189
diff changeset
812 let nono_lines =<< trim END
a2447c58da25 patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents: 20189
diff changeset
813 def g:DoCheck(no_exists: bool)
a2447c58da25 patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents: 20189
diff changeset
814 assert_equal('yes', FuncYes())
a2447c58da25 patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents: 20189
diff changeset
815 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
816 enddef
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
817 END
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
818
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
819 # FuncNo() is defined
20195
a2447c58da25 patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents: 20189
diff changeset
820 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
821 source Xreloaded.vim
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
822 g:DoCheck(true)
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
823
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
824 # FuncNo() is not redefined
20195
a2447c58da25 patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents: 20189
diff changeset
825 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
826 source Xreloaded.vim
20195
a2447c58da25 patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents: 20189
diff changeset
827 g:DoCheck()
20189
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
828
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
829 # FuncNo() is back
20195
a2447c58da25 patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents: 20189
diff changeset
830 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
831 source Xreloaded.vim
20195
a2447c58da25 patch 8.2.0653: using uninitialized pointer
Bram Moolenaar <Bram@vim.org>
parents: 20189
diff changeset
832 g:DoCheck()
20189
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
833
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
834 delete('Xreloaded.vim')
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
835 enddef
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
836
20347
0e1dfff4f294 patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents: 20338
diff changeset
837 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
838 # 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
839 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
840 vim9script
0e1dfff4f294 patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents: 20338
diff changeset
841 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
842 END
0e1dfff4f294 patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents: 20338
diff changeset
843 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
844 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
845
0e1dfff4f294 patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents: 20338
diff changeset
846 # 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
847 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
848 vim9script
0e1dfff4f294 patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents: 20338
diff changeset
849 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
850 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
851 enddef
0e1dfff4f294 patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents: 20338
diff changeset
852 END
0e1dfff4f294 patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents: 20338
diff changeset
853 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
854 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
855
0e1dfff4f294 patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents: 20338
diff changeset
856 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
857 enddef
0e1dfff4f294 patch 8.2.0729: Vim9: When reloading a script variables are not cleared
Bram Moolenaar <Bram@vim.org>
parents: 20338
diff changeset
858
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
859 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
860 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
861 'vim9script',
628011800942 patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents: 19999
diff changeset
862 '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
863 'def UseExported()',
628011800942 patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents: 19999
diff changeset
864 ' 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
865 ' exported = 8888',
628011800942 patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents: 19999
diff changeset
866 ' 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
867 'enddef',
628011800942 patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents: 19999
diff changeset
868 'UseExported()',
628011800942 patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents: 19999
diff changeset
869 '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
870 ]
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
871 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
872 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
873
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
874 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
875
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
876 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
877 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
878 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
879 'g:imported_abs = exported.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 20011
diff changeset
880 '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
881 '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
882 'exported = 8888.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 20011
diff changeset
883 '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
884 'g:imported_after = exported.*' ..
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 20011
diff changeset
885 '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
886 '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
887 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
888 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
889 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
890
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
891 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
892 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
893 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
894
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
895 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
896 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
897 'vim9script',
628011800942 patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents: 19999
diff changeset
898 '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
899 '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
900 ]
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
901 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
902 mkdir('import')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
903 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
904
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
905 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
906 &rtp = getcwd()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
907 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
908 &rtp = save_rtp
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
909
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
910 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
911 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
912
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
913 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
914 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
915 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
916
20538
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
917 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
918 let export_lines = [
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
919 'vim9script',
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
920 'export def ExpFunc(): string',
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
921 ' return notDefined',
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
922 'enddef',
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
923 ]
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
924 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
925
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
926 let import_lines = [
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
927 'vim9script',
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
928 '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
929 'def ImpFunc()',
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
930 ' echo ExpFunc()',
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
931 'enddef',
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
932 'defcompile',
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
933 ]
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
934 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
935
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
936 try
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
937 source Ximport.vim
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
938 catch /E1001/
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
939 " Error should be fore the Xexported.vim file.
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
940 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
941 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
942 endtry
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
943
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
944 delete('Xexported.vim')
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
945 delete('Ximport.vim')
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
946 enddef
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20528
diff changeset
947
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
948 def Test_fixed_size_list()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
949 " will be allocated as one piece of memory, check that changes work
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
950 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
951 l->remove(0)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
952 l->add(5)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
953 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
954 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
955 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
956
19332
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
957 def IfElse(what: number): string
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
958 let res = ''
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
959 if what == 1
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
960 res = "one"
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
961 elseif what == 2
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
962 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
963 else
19332
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
964 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
965 endif
19332
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
966 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
967 enddef
a8d2d3c8f0b3 patch 8.2.0185: Vim9 script: cannot use "if has()" to skip lines
Bram Moolenaar <Bram@vim.org>
parents: 19185
diff changeset
968
19332
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
969 def Test_if_elseif_else()
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
970 assert_equal('one', IfElse(1))
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
971 assert_equal('two', IfElse(2))
d6e8a9e80be4 patch 8.2.0224: compiling :elseif not tested yet
Bram Moolenaar <Bram@vim.org>
parents: 19330
diff changeset
972 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
973 enddef
9fcdeaa18bd1 patch 8.2.0199: Vim9 script commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19253
diff changeset
974
19892
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
975 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
976 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
977 call CheckDefFailure(['else'], 'E581:')
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
978 call CheckDefFailure(['endif'], 'E580:')
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
979 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
980 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
981 enddef
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
982
19585
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
983 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
984 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
985
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
986 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
987 let res = false
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
988 if true ? true : false
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
989 res = true
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
990 endif
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
991 assert_equal(true, res)
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
992
19894
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
993 g:glob = 2
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
994 if false
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
995 execute('let g:glob = 3')
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
996 endif
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
997 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
998 if true
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
999 execute('let g:glob = 3')
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1000 endif
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1001 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
1002
19585
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1003 res = false
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1004 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
1005 res = true
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1006 endif
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1007 assert_equal(true, res)
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1008
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1009 res = false
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1010 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
1011 res = true
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1012 endif
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1013 assert_equal(true, res)
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1014
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1015 res = false
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1016 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
1017 res = true
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1018 endif
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1019 assert_equal(true, res)
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1020
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1021 res = false
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1022 if true ? false : true
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1023 res = true
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1024 endif
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1025 assert_equal(false, res)
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1026
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1027 res = false
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1028 if false ? false : true
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1029 res = true
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1030 endif
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1031 assert_equal(true, res)
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1032
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1033 res = false
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1034 if false ? true : false
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1035 res = true
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1036 endif
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1037 assert_equal(false, res)
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1038
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1039 res = false
19892
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
1040 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
1041 res = true
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
1042 endif
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
1043 assert_equal(false, res)
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
1044
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
1045 res = false
19585
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1046 if true && true
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1047 res = true
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1048 endif
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1049 assert_equal(true, res)
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1050
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1051 res = false
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1052 if true && false
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1053 res = true
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1054 endif
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1055 assert_equal(false, res)
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1056
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1057 res = false
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1058 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
1059 res = true
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1060 endif
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1061 assert_equal(false, res)
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1062
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1063 res = false
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1064 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
1065 res = true
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1066 endif
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1067 assert_equal(false, res)
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1068
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1069 res = false
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1070 if false && false
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1071 res = true
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1072 endif
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1073 assert_equal(false, res)
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1074
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1075 res = false
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1076 if true || false
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1077 res = true
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1078 endif
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1079 assert_equal(true, res)
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1080
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1081 res = false
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1082 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
1083 res = true
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1084 endif
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1085 assert_equal(true, res)
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1086
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1087 res = false
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1088 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
1089 res = true
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1090 endif
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1091 assert_equal(true, res)
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1092
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1093 res = false
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1094 if false || false
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1095 res = true
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1096 endif
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1097 assert_equal(false, res)
19878
dd3c80122a0e patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents: 19874
diff changeset
1098 enddef
19585
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1099
19878
dd3c80122a0e patch 8.2.0495: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents: 19874
diff changeset
1100 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
1101 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
1102 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
1103 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
1104 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
1105 enddef
0303f920a7d4 patch 8.2.0349: Vim9: constant expression not well tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
1106
19528
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
1107 def Test_execute_cmd()
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
1108 new
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
1109 setline(1, 'default')
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
1110 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
1111 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
1112
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1113 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
1114 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
1115
19528
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
1116 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
1117 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
1118 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
1119 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
1120
19528
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
1121 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
1122 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
1123
19528
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
1124 let cmd_first = 'call '
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
1125 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
1126 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
1127 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
1128 bwipe!
19894
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1129
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1130 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
1131 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
1132 enddef
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
1133
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
1134 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
1135 echo 'some' # comment
19894
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1136 echon 'thing'
19528
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
1137 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
1138
20138
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1139 echo "some" # comment
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1140 echon "thing"
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1141 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
1142
19528
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
1143 let str1 = 'some'
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
1144 let str2 = 'more'
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
1145 echo str1 str2
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
1146 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
1147
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1148 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
1149 enddef
3b026343f398 patch 8.2.0321: Vim9: ":execute" does not work yet
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
1150
20142
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20138
diff changeset
1151 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
1152 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
1153 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
1154 echo 'clear'
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20138
diff changeset
1155 1messages
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20138
diff changeset
1156 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
1157
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20138
diff changeset
1158 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
1159 enddef
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20138
diff changeset
1160
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20138
diff changeset
1161 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
1162 try
208b38bddc36 patch 8.2.0700: Vim9: converting error message to exception not tested
Bram Moolenaar <Bram@vim.org>
parents: 20203
diff changeset
1163 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
1164 catch
208b38bddc36 patch 8.2.0700: Vim9: converting error message to exception not tested
Bram Moolenaar <Bram@vim.org>
parents: 20203
diff changeset
1165 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
1166 endtry
20142
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20138
diff changeset
1167 enddef
fe8d0a4344df patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 20138
diff changeset
1168
19568
c0749ad6c699 patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents: 19566
diff changeset
1169 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
1170 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
1171 vim9script
c0749ad6c699 patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents: 19566
diff changeset
1172 new
c0749ad6c699 patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents: 19566
diff changeset
1173 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
1174 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
1175 endfor
c0749ad6c699 patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents: 19566
diff changeset
1176 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
1177 bwipe!
c0749ad6c699 patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents: 19566
diff changeset
1178 END
c0749ad6c699 patch 8.2.0341: using ":for" in Vim9 script gives an error
Bram Moolenaar <Bram@vim.org>
parents: 19566
diff changeset
1179 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
1180 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
1181 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
1182 enddef
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1183
19892
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
1184 def Test_for_loop()
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
1185 let result = ''
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
1186 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
1187 if cnt == 4
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
1188 break
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
1189 endif
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
1190 if cnt == 2
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
1191 continue
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
1192 endif
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
1193 result ..= cnt .. '_'
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
1194 endfor
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
1195 assert_equal('0_1_3_', result)
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
1196 enddef
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
1197
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
1198 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
1199 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
1200 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
1201 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
1202 CheckScriptFailure(['def Func(arg: any)', 'for arg in range(5)', 'enddef', 'defcompile'], 'E1006:')
20019
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 20011
diff changeset
1203 CheckDefFailure(['for i in "text"'], 'E1024:')
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 20011
diff changeset
1204 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
1205 CheckDefFailure(['endfor'], 'E588:')
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 20011
diff changeset
1206 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
1207 enddef
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
1208
19593
043989a2f449 patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19585
diff changeset
1209 def Test_while_loop()
043989a2f449 patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19585
diff changeset
1210 let result = ''
043989a2f449 patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19585
diff changeset
1211 let cnt = 0
043989a2f449 patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19585
diff changeset
1212 while cnt < 555
043989a2f449 patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19585
diff changeset
1213 if cnt == 3
043989a2f449 patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19585
diff changeset
1214 break
043989a2f449 patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19585
diff changeset
1215 endif
043989a2f449 patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19585
diff changeset
1216 cnt += 1
043989a2f449 patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19585
diff changeset
1217 if cnt == 2
043989a2f449 patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19585
diff changeset
1218 continue
043989a2f449 patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19585
diff changeset
1219 endif
043989a2f449 patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19585
diff changeset
1220 result ..= cnt .. '_'
043989a2f449 patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19585
diff changeset
1221 endwhile
043989a2f449 patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19585
diff changeset
1222 assert_equal('1_3_', result)
043989a2f449 patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19585
diff changeset
1223 enddef
043989a2f449 patch 8.2.0353: Vim9: while loop not tested
Bram Moolenaar <Bram@vim.org>
parents: 19585
diff changeset
1224
19892
5feb426d2ea1 patch 8.2.0502: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19890
diff changeset
1225 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
1226 CheckDefFailure(['while xxx'], 'E1001:')
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 20011
diff changeset
1227 CheckDefFailure(['endwhile'], 'E588:')
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 20011
diff changeset
1228 CheckDefFailure(['continue'], 'E586:')
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 20011
diff changeset
1229 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
1230 CheckDefFailure(['break'], 'E587:')
e9af5a09a55b patch 8.2.0565: Vim9: tests contain superfluous line continuation
Bram Moolenaar <Bram@vim.org>
parents: 20011
diff changeset
1231 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
1232 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
1233 enddef
846fbbacce3a patch 8.2.0487: Vim9: compiling not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19860
diff changeset
1234
19730
fe8ba2f82f59 patch 8.2.0421: interrupting with CTRL-C does not always work
Bram Moolenaar <Bram@vim.org>
parents: 19728
diff changeset
1235 def Test_interrupt_loop()
19736
4174c4da6ff7 patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
1236 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
1237 let x = 0
19736
4174c4da6ff7 patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
1238 try
4174c4da6ff7 patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
1239 while 1
4174c4da6ff7 patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
1240 x += 1
4174c4da6ff7 patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
1241 if x == 100
4174c4da6ff7 patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
1242 feedkeys("\<C-C>", 'Lt')
4174c4da6ff7 patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
1243 endif
4174c4da6ff7 patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
1244 endwhile
4174c4da6ff7 patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
1245 catch
4174c4da6ff7 patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
1246 caught = true
4174c4da6ff7 patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
1247 assert_equal(100, x)
4174c4da6ff7 patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
1248 endtry
4174c4da6ff7 patch 8.2.0424: checking for wrong return value
Bram Moolenaar <Bram@vim.org>
parents: 19730
diff changeset
1249 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
1250 enddef
19726
ad37a198a708 patch 8.2.0419: various memory leaks in Vim9 script code
Bram Moolenaar <Bram@vim.org>
parents: 19623
diff changeset
1251
19999
844c7646f61b patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents: 19962
diff changeset
1252 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
1253 let mylist = [
844c7646f61b patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents: 19962
diff changeset
1254 'one',
844c7646f61b patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents: 19962
diff changeset
1255 'two',
844c7646f61b patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents: 19962
diff changeset
1256 'three',
844c7646f61b patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents: 19962
diff changeset
1257 ] " comment
844c7646f61b patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents: 19962
diff changeset
1258 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
1259
844c7646f61b patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents: 19962
diff changeset
1260 let mydict = {
844c7646f61b patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents: 19962
diff changeset
1261 'one': 1,
844c7646f61b patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents: 19962
diff changeset
1262 'two': 2,
844c7646f61b patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents: 19962
diff changeset
1263 'three':
844c7646f61b patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents: 19962
diff changeset
1264 3,
844c7646f61b patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents: 19962
diff changeset
1265 } " comment
844c7646f61b patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents: 19962
diff changeset
1266 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
1267 mydict = #{
20023
c85d4e173cc9 patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents: 20019
diff changeset
1268 one: 1, # comment
c85d4e173cc9 patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents: 20019
diff changeset
1269 two: # comment
c85d4e173cc9 patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents: 20019
diff changeset
1270 2, # comment
c85d4e173cc9 patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents: 20019
diff changeset
1271 three: 3 # comment
c85d4e173cc9 patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents: 20019
diff changeset
1272 }
c85d4e173cc9 patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents: 20019
diff changeset
1273 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
1274 mydict = #{
c85d4e173cc9 patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents: 20019
diff changeset
1275 one: 1,
c85d4e173cc9 patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents: 20019
diff changeset
1276 two:
c85d4e173cc9 patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents: 20019
diff changeset
1277 2,
c85d4e173cc9 patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents: 20019
diff changeset
1278 three: 3
19999
844c7646f61b patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents: 19962
diff changeset
1279 }
844c7646f61b patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents: 19962
diff changeset
1280 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
1281
628011800942 patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents: 19999
diff changeset
1282 assert_equal(
628011800942 patch 8.2.0561: Vim9: cannot split function call in multiple lines
Bram Moolenaar <Bram@vim.org>
parents: 19999
diff changeset
1283 ['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
1284 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
1285 )
19999
844c7646f61b patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents: 19962
diff changeset
1286 enddef
844c7646f61b patch 8.2.0555: Vim9: line continuation is not always needed
Bram Moolenaar <Bram@vim.org>
parents: 19962
diff changeset
1287
20059
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1288 def Test_vim9_comment()
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1289 CheckScriptSuccess([
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1290 'vim9script',
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1291 '# something',
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1292 ])
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1293 CheckScriptFailure([
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1294 'vim9script',
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1295 ':# something',
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1296 ], 'E488:')
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1297 CheckScriptFailure([
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1298 '# something',
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1299 ], 'E488:')
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1300 CheckScriptFailure([
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1301 ':# something',
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1302 ], 'E488:')
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1303
20061
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1304 { # block start
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1305 } # block end
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1306 CheckDefFailure([
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1307 '{# comment',
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1308 ], 'E488:')
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1309 CheckDefFailure([
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1310 '{',
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1311 '}# comment',
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1312 ], 'E488:')
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1313
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1314 echo "yes" # comment
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1315 CheckDefFailure([
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1316 'echo "yes"# comment',
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1317 ], 'E488:')
20059
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1318 CheckScriptSuccess([
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1319 'vim9script',
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1320 'echo "yes" # something',
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1321 ])
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1322 CheckScriptFailure([
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1323 'vim9script',
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1324 'echo "yes"# something',
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1325 ], 'E121:')
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1326 CheckScriptFailure([
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1327 'vim9script',
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1328 'echo# something',
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1329 ], 'E121:')
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1330 CheckScriptFailure([
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1331 'echo "yes" # something',
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1332 ], 'E121:')
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1333
20061
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1334 exe "echo" # comment
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1335 CheckDefFailure([
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1336 'exe "echo"# comment',
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1337 ], 'E488:')
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1338 CheckScriptSuccess([
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1339 'vim9script',
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1340 'exe "echo" # something',
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1341 ])
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1342 CheckScriptFailure([
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1343 'vim9script',
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1344 'exe "echo"# something',
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1345 ], 'E121:')
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1346 CheckDefFailure([
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1347 'exe # comment',
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1348 ], 'E1015:')
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1349 CheckScriptFailure([
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1350 'vim9script',
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1351 'exe# something',
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1352 ], 'E121:')
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1353 CheckScriptFailure([
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1354 'exe "echo" # something',
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1355 ], 'E121:')
6e6a75800884 patch 8.2.0586: Vim9: # comment not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
1356
20059
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1357 CheckDefFailure([
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1358 'try# comment',
20113
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1359 ' echo "yes"',
20059
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1360 'catch',
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1361 'endtry',
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1362 ], 'E488:')
20113
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1363 CheckScriptFailure([
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1364 'vim9script',
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1365 'try# comment',
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1366 'echo "yes"',
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1367 ], 'E488:')
20059
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1368 CheckDefFailure([
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1369 'try',
20138
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1370 ' throw#comment',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1371 'catch',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1372 'endtry',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1373 ], 'E1015:')
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1374 CheckDefFailure([
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1375 'try',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1376 ' throw "yes"#comment',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1377 'catch',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1378 'endtry',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1379 ], 'E488:')
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1380 CheckDefFailure([
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1381 'try',
20113
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1382 ' echo "yes"',
20059
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1383 'catch# comment',
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1384 'endtry',
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1385 ], 'E488:')
20113
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1386 CheckScriptFailure([
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1387 'vim9script',
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1388 'try',
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1389 ' echo "yes"',
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1390 'catch# comment',
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1391 'endtry',
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1392 ], 'E654:')
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1393 CheckDefFailure([
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1394 'try',
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1395 ' echo "yes"',
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1396 'catch /pat/# comment',
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1397 'endtry',
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1398 ], 'E488:')
20059
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1399 CheckDefFailure([
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1400 'try',
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1401 'echo "yes"',
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1402 'catch',
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1403 'endtry# comment',
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1404 ], 'E488:')
20113
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1405 CheckScriptFailure([
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1406 'vim9script',
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1407 'try',
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1408 ' echo "yes"',
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1409 'catch',
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1410 'endtry# comment',
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1411 ], 'E600:')
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1412
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1413 CheckScriptSuccess([
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1414 'vim9script',
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1415 'hi # comment',
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1416 ])
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1417 CheckScriptFailure([
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1418 'vim9script',
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1419 'hi# comment',
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1420 ], 'E416:')
20116
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1421 CheckScriptSuccess([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1422 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1423 'hi Search # comment',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1424 ])
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1425 CheckScriptFailure([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1426 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1427 'hi Search# comment',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1428 ], 'E416:')
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1429 CheckScriptSuccess([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1430 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1431 '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
1432 ])
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1433 CheckScriptFailure([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1434 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1435 '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
1436 ], 'E413:')
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1437 CheckScriptSuccess([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1438 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1439 '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
1440 'hi clear # comment',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1441 ])
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1442 " not tested, because it doesn't give an error but a warning:
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1443 " 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
1444 CheckScriptFailure([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1445 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1446 'hi clear# comment',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1447 ], 'E416:')
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1448
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1449 CheckScriptSuccess([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1450 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1451 '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
1452 '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
1453 ])
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1454 CheckScriptFailure([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1455 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1456 '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
1457 '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
1458 ], 'E488:')
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1459 CheckScriptSuccess([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1460 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1461 'match # comment',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1462 ])
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1463 CheckScriptFailure([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1464 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1465 'match# comment',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1466 ], 'E475:')
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1467 CheckScriptSuccess([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1468 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1469 'match none # comment',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1470 ])
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1471 CheckScriptFailure([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1472 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1473 'match none# comment',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1474 ], 'E475:')
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1475
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1476 CheckScriptSuccess([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1477 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1478 'menutrans clear # comment',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1479 ])
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1480 CheckScriptFailure([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1481 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1482 '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
1483 ], 'E474:')
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1484
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1485 CheckScriptSuccess([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1486 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1487 'syntax clear # comment',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1488 ])
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1489 CheckScriptFailure([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1490 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1491 '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
1492 ], 'E28:')
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1493 CheckScriptSuccess([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1494 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1495 '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
1496 '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
1497 ])
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1498 CheckScriptFailure([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1499 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1500 '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
1501 '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
1502 ], 'E28:')
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1503
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1504 CheckScriptSuccess([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1505 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1506 'syntax list # comment',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1507 ])
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1508 CheckScriptFailure([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1509 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1510 '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
1511 ], 'E28:')
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1512
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1513 CheckScriptSuccess([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1514 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1515 '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
1516 ])
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1517 CheckScriptFailure([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1518 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1519 '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
1520 ], 'E475:')
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1521
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1522 CheckScriptSuccess([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1523 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1524 '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
1525 ])
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1526 CheckScriptFailure([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1527 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1528 '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
1529 ], 'E789:')
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1530
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1531 CheckScriptSuccess([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1532 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1533 '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
1534 ])
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1535 CheckScriptFailure([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1536 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1537 '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
1538 ], 'E402:')
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1539
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1540 CheckScriptSuccess([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1541 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1542 '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
1543 ])
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1544 CheckScriptFailure([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1545 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1546 '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
1547 ], 'E475:')
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1548 CheckScriptFailure([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1549 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1550 '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
1551 ], 'E406:')
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1552 CheckScriptFailure([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1553 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1554 '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
1555 ], 'E475:')
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1556
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1557 CheckScriptSuccess([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1558 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1559 '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
1560 ])
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1561 CheckScriptFailure([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1562 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1563 '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
1564 ], 'E475:')
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1565
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1566 CheckScriptSuccess([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1567 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1568 'syntax sync # comment',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1569 ])
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1570 CheckScriptFailure([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1571 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1572 'syntax sync# comment',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1573 ], 'E404:')
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1574 CheckScriptSuccess([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1575 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1576 '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
1577 ])
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1578 CheckScriptFailure([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1579 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1580 '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
1581 ], 'E404:')
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1582
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1583 CheckScriptSuccess([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1584 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1585 '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
1586 ])
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1587 CheckScriptFailure([
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1588 'vim9script',
513c62184ed8 patch 8.2.0613: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20113
diff changeset
1589 '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
1590 ], 'E475:')
20138
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1591
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1592 CheckScriptSuccess([
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1593 'vim9script',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1594 '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
1595 'command Echo # comment',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1596 ])
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1597 CheckScriptFailure([
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1598 'vim9script',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1599 '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
1600 'Echo',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1601 ], 'E121:')
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1602 CheckScriptFailure([
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1603 'vim9script',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1604 'command Echo# comment',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1605 ], 'E182:')
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1606 CheckScriptFailure([
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1607 'vim9script',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1608 'command Echo echo',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1609 'command Echo# comment',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1610 ], 'E182:')
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1611
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1612 CheckScriptSuccess([
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1613 'vim9script',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1614 'function # comment',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1615 ])
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1616 CheckScriptFailure([
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1617 'vim9script',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1618 'function# comment',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1619 ], 'E129:')
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1620 CheckScriptSuccess([
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1621 'vim9script',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1622 'function CheckScriptSuccess # comment',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1623 ])
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1624 CheckScriptFailure([
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1625 'vim9script',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1626 'function CheckScriptSuccess# comment',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1627 ], 'E488:')
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1628
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1629 CheckScriptSuccess([
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1630 'vim9script',
20189
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
1631 '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
1632 'endfunc',
20189
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
1633 '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
1634 ])
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1635 CheckScriptFailure([
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1636 'vim9script',
20189
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
1637 '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
1638 'endfunc',
20189
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
1639 '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
1640 ], 'E488:')
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1641
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1642 CheckScriptSuccess([
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1643 'vim9script',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1644 '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
1645 ])
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1646 CheckScriptFailure([
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1647 'vim9script',
d0a9766167ab patch 8.2.0624: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20116
diff changeset
1648 '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
1649 ], 'E488:')
20113
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1650 enddef
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1651
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1652 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
1653 CheckCanRunGui
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1654
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1655 CheckScriptFailure([
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1656 'vim9script',
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1657 'gui#comment'
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1658 ], 'E499:')
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1659 CheckScriptFailure([
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1660 'vim9script',
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1661 'gui -f#comment'
2c23053c654a patch 8.2.0612: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
1662 ], 'E499:')
20059
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1663 enddef
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20055
diff changeset
1664
20079
336483164ca6 patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents: 20061
diff changeset
1665 def Test_vim9_comment_not_compiled()
336483164ca6 patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents: 20061
diff changeset
1666 au TabEnter *.vim let g:entered = 1
336483164ca6 patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents: 20061
diff changeset
1667 au TabEnter *.x let g:entered = 2
336483164ca6 patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents: 20061
diff changeset
1668
336483164ca6 patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents: 20061
diff changeset
1669 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
1670 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
1671 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
1672
336483164ca6 patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents: 20061
diff changeset
1673 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
1674 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
1675
336483164ca6 patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents: 20061
diff changeset
1676 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
1677 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
1678 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
1679
336483164ca6 patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents: 20061
diff changeset
1680 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
1681
336483164ca6 patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents: 20061
diff changeset
1682 au! TabEnter
336483164ca6 patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents: 20061
diff changeset
1683 unlet g:entered
20091
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
1684
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
1685 CheckScriptSuccess([
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
1686 'vim9script',
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
1687 'let g:var = 123',
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
1688 'let w:var = 777',
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
1689 '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
1690 ])
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
1691
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
1692 CheckScriptFailure([
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
1693 'vim9script',
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
1694 'let 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
1695 'unlet g:var# comment1',
20091
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
1696 ], 'E108:')
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
1697
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
1698 CheckScriptFailure([
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
1699 'let g:var = 123',
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
1700 'unlet g:var # something',
a64c16ff98b8 patch 8.2.0601: Vim9: :unlet is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 20089
diff changeset
1701 ], 'E488:')
20111
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1702
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1703 CheckScriptSuccess([
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1704 'vim9script',
20397
c225be44692a patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents: 20351
diff changeset
1705 '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
1706 ' echo "yes"',
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1707 'elseif 2 #comment',
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1708 ' echo "no"',
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1709 'endif',
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1710 ])
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1711
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1712 CheckScriptFailure([
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1713 'vim9script',
20397
c225be44692a patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents: 20351
diff changeset
1714 '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
1715 ' echo "yes"',
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1716 'endif',
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1717 ], 'E15:')
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1718
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1719 CheckScriptFailure([
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1720 'vim9script',
20397
c225be44692a patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents: 20351
diff changeset
1721 '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
1722 ' echo "yes"',
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1723 'elseif 2#comment',
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1724 ' echo "no"',
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1725 'endif',
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1726 ], 'E15:')
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1727
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1728 CheckScriptSuccess([
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1729 'vim9script',
20397
c225be44692a patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents: 20351
diff changeset
1730 '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
1731 ])
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1732
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1733 CheckScriptFailure([
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1734 'vim9script',
20397
c225be44692a patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents: 20351
diff changeset
1735 '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
1736 ], 'E15:')
20111
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1737
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1738 CheckScriptSuccess([
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1739 'vim9script',
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1740 'new'
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1741 'call setline(1, ["# define pat", "last"])',
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1742 '$',
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1743 'dsearch /pat/ #comment',
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1744 'bwipe!',
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1745 ])
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1746
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1747 CheckScriptFailure([
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1748 'vim9script',
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1749 'new'
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1750 'call setline(1, ["# define pat", "last"])',
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1751 '$',
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1752 'dsearch /pat/#comment',
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1753 'bwipe!',
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20099
diff changeset
1754 ], 'E488:')
20504
7fb80f486aad patch 8.2.0806: using "func!" after vim9script gives confusing error
Bram Moolenaar <Bram@vim.org>
parents: 20472
diff changeset
1755
7fb80f486aad patch 8.2.0806: using "func!" after vim9script gives confusing error
Bram Moolenaar <Bram@vim.org>
parents: 20472
diff changeset
1756 CheckScriptFailure([
7fb80f486aad patch 8.2.0806: using "func!" after vim9script gives confusing error
Bram Moolenaar <Bram@vim.org>
parents: 20472
diff changeset
1757 'vim9script',
7fb80f486aad patch 8.2.0806: using "func!" after vim9script gives confusing error
Bram Moolenaar <Bram@vim.org>
parents: 20472
diff changeset
1758 'func! SomeFunc()',
7fb80f486aad patch 8.2.0806: using "func!" after vim9script gives confusing error
Bram Moolenaar <Bram@vim.org>
parents: 20472
diff changeset
1759 ], 'E477:')
20079
336483164ca6 patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents: 20061
diff changeset
1760 enddef
336483164ca6 patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents: 20061
diff changeset
1761
20351
680296770464 patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents: 20349
diff changeset
1762 def Test_finish()
680296770464 patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents: 20349
diff changeset
1763 let lines =<< trim END
680296770464 patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents: 20349
diff changeset
1764 vim9script
680296770464 patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents: 20349
diff changeset
1765 let g:res = 'one'
680296770464 patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents: 20349
diff changeset
1766 if v:false | finish | endif
680296770464 patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents: 20349
diff changeset
1767 let g:res = 'two'
680296770464 patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents: 20349
diff changeset
1768 finish
680296770464 patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents: 20349
diff changeset
1769 let g:res = 'three'
680296770464 patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents: 20349
diff changeset
1770 END
680296770464 patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents: 20349
diff changeset
1771 writefile(lines, 'Xfinished')
680296770464 patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents: 20349
diff changeset
1772 source Xfinished
680296770464 patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents: 20349
diff changeset
1773 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
1774
680296770464 patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents: 20349
diff changeset
1775 unlet g:res
680296770464 patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents: 20349
diff changeset
1776 delete('Xfinished')
680296770464 patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents: 20349
diff changeset
1777 enddef
680296770464 patch 8.2.0731: Vim9: parsing declarations continues after :finish
Bram Moolenaar <Bram@vim.org>
parents: 20349
diff changeset
1778
20397
c225be44692a patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents: 20351
diff changeset
1779 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
1780 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
1781 vim9script
c225be44692a patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents: 20351
diff changeset
1782 func GetValue()
c225be44692a patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents: 20351
diff changeset
1783 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
1784 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
1785 else
c225be44692a patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents: 20351
diff changeset
1786 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
1787 endif
c225be44692a patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents: 20351
diff changeset
1788 return 'this'
c225be44692a patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents: 20351
diff changeset
1789 endfunc
c225be44692a patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents: 20351
diff changeset
1790 let val: string = GetValue()
20435
61d2eb1413f2 patch 8.2.0772: Vim9: some variable initializations not tested
Bram Moolenaar <Bram@vim.org>
parents: 20419
diff changeset
1791 " env var is always a string
61d2eb1413f2 patch 8.2.0772: Vim9: some variable initializations not tested
Bram Moolenaar <Bram@vim.org>
parents: 20419
diff changeset
1792 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
1793 END
c225be44692a patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents: 20351
diff changeset
1794 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
1795 source Xfinished
20399
d1a54d2bd145 patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1796 " 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
1797 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
1798
c225be44692a patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents: 20351
diff changeset
1799 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
1800 delete('Xfinished')
c225be44692a patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents: 20351
diff changeset
1801 enddef
c225be44692a patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents: 20351
diff changeset
1802
c225be44692a patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents: 20351
diff changeset
1803 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
1804 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
1805 vim9script
20435
61d2eb1413f2 patch 8.2.0772: Vim9: some variable initializations not tested
Bram Moolenaar <Bram@vim.org>
parents: 20419
diff changeset
1806 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
1807 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
1808 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
1809
918b9a05cf35 patch 8.2.0755: Vim9: No error when variable initializer is not a constant
Bram Moolenaar <Bram@vim.org>
parents: 20399
diff changeset
1810 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
1811 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
1812 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
1813 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
1814 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
1815 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
1816 enddef
c225be44692a patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Bram Moolenaar <Bram@vim.org>
parents: 20351
diff changeset
1817
20840
0600ab7b9f09 patch 8.2.0972: Vim9 script variable declarations need a type
Bram Moolenaar <Bram@vim.org>
parents: 20816
diff changeset
1818 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
1819 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
1820 vim9script
0600ab7b9f09 patch 8.2.0972: Vim9 script variable declarations need a type
Bram Moolenaar <Bram@vim.org>
parents: 20816
diff changeset
1821 let var: string
0600ab7b9f09 patch 8.2.0972: Vim9 script variable declarations need a type
Bram Moolenaar <Bram@vim.org>
parents: 20816
diff changeset
1822 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
1823 var = 'text'
0600ab7b9f09 patch 8.2.0972: Vim9 script variable declarations need a type
Bram Moolenaar <Bram@vim.org>
parents: 20816
diff changeset
1824 g:var_test = var
20846
709379ab5110 patch 8.2.0975: Vim9: script variable does not accept optional s: prefix
Bram Moolenaar <Bram@vim.org>
parents: 20842
diff changeset
1825 " prefixing s: is optional
709379ab5110 patch 8.2.0975: Vim9: script variable does not accept optional s: prefix
Bram Moolenaar <Bram@vim.org>
parents: 20842
diff changeset
1826 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
1827 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
1828
709379ab5110 patch 8.2.0975: Vim9: script variable does not accept optional s: prefix
Bram Moolenaar <Bram@vim.org>
parents: 20842
diff changeset
1829 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
1830 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
1831 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
1832 END
0600ab7b9f09 patch 8.2.0972: Vim9 script variable declarations need a type
Bram Moolenaar <Bram@vim.org>
parents: 20816
diff changeset
1833 CheckScriptSuccess(lines)
0600ab7b9f09 patch 8.2.0972: Vim9 script variable declarations need a type
Bram Moolenaar <Bram@vim.org>
parents: 20816
diff changeset
1834 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
1835 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
1836 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
1837 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
1838
0600ab7b9f09 patch 8.2.0972: Vim9 script variable declarations need a type
Bram Moolenaar <Bram@vim.org>
parents: 20816
diff changeset
1839 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
1840 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
1841 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
1842 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
1843 enddef
0600ab7b9f09 patch 8.2.0972: Vim9 script variable declarations need a type
Bram Moolenaar <Bram@vim.org>
parents: 20816
diff changeset
1844
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
1845 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
1846 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
1847 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
1848 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
1849 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
1850 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
1851 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
1852
709379ab5110 patch 8.2.0975: Vim9: script variable does not accept optional s: prefix
Bram Moolenaar <Bram@vim.org>
parents: 20842
diff changeset
1853 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
1854 vim9script
709379ab5110 patch 8.2.0975: Vim9: script variable does not accept optional s: prefix
Bram Moolenaar <Bram@vim.org>
parents: 20842
diff changeset
1855 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
1856 END
709379ab5110 patch 8.2.0975: Vim9: script variable does not accept optional s: prefix
Bram Moolenaar <Bram@vim.org>
parents: 20842
diff changeset
1857 CheckScriptFailure(lines, 'E1069:')
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
1858 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
1859
20399
d1a54d2bd145 patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1860 def Test_forward_declaration()
d1a54d2bd145 patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1861 let lines =<< trim END
d1a54d2bd145 patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1862 vim9script
d1a54d2bd145 patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1863 def GetValue(): string
d1a54d2bd145 patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1864 return theVal
d1a54d2bd145 patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1865 enddef
d1a54d2bd145 patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1866 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
1867 g:initVal = GetValue()
20399
d1a54d2bd145 patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1868 theVal = 'else'
d1a54d2bd145 patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1869 g:laterVal = GetValue()
d1a54d2bd145 patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1870 END
d1a54d2bd145 patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1871 writefile(lines, 'Xforward')
d1a54d2bd145 patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1872 source Xforward
d1a54d2bd145 patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1873 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
1874 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
1875
d1a54d2bd145 patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1876 unlet g:initVal
d1a54d2bd145 patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1877 unlet g:laterVal
d1a54d2bd145 patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1878 delete('Xforward')
d1a54d2bd145 patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1879 enddef
d1a54d2bd145 patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1880
20816
9faab49c880f patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents: 20538
diff changeset
1881 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
1882 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
1883 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
1884
9faab49c880f patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents: 20538
diff changeset
1885 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
1886 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
1887 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
1888 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
1889 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
1890
9faab49c880f patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents: 20538
diff changeset
1891 " 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
1892 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
1893 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
1894 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
1895
9faab49c880f patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents: 20538
diff changeset
1896 " 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
1897 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
1898 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
1899 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
1900 END
9faab49c880f patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents: 20538
diff changeset
1901 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
1902
9faab49c880f patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents: 20538
diff changeset
1903 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
1904 vim9script
9faab49c880f patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents: 20538
diff changeset
1905 let local = 'local'
9faab49c880f patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents: 20538
diff changeset
1906 g:global = 'global'
9faab49c880f patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents: 20538
diff changeset
1907 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
1908 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
1909 return 'text'
9faab49c880f patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents: 20538
diff changeset
1910 enddef
9faab49c880f patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents: 20538
diff changeset
1911 END
9faab49c880f patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents: 20538
diff changeset
1912 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
1913
9faab49c880f patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents: 20538
diff changeset
1914 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
1915
9faab49c880f patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents: 20538
diff changeset
1916 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
1917 " unlet g:global
9faab49c880f patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents: 20538
diff changeset
1918
9faab49c880f patch 8.2.0960: cannot use :import in legacy Vim script
Bram Moolenaar <Bram@vim.org>
parents: 20538
diff changeset
1919 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
1920 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
1921 enddef
20399
d1a54d2bd145 patch 8.2.0754: Vim9: No test for forward declaration
Bram Moolenaar <Bram@vim.org>
parents: 20397
diff changeset
1922
19894
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1923 " 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
1924 def Test_substitute_cmd()
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1925 new
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1926 setline(1, 'something')
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1927 :substitute(some(other(
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1928 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
1929 bwipe!
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1930
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1931 " also when the context is Vim9 script
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1932 let lines =<< trim END
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1933 vim9script
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1934 new
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1935 setline(1, 'something')
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1936 :substitute(some(other(
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1937 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
1938 bwipe!
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1939 END
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1940 writefile(lines, 'Xvim9lines')
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1941 source Xvim9lines
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1942
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1943 delete('Xvim9lines')
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1944 enddef
ea4f8e789627 patch 8.2.0503: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1945
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1946 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker