Mercurial > vim
annotate src/testdir/test_vim9_expr.vim @ 22625:0afa30d6dc72 v8.2.1861
patch 8.2.1861: Vim9: no specific error when parsing lambda fails
Commit: https://github.com/vim/vim/commit/a2c026d0fd470d68d679616fddfc285cb4834412
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Oct 18 18:03:17 2020 +0200
patch 8.2.1861: Vim9: no specific error when parsing lambda fails
Problem: Vim9: no specific error when parsing lambda fails.
Solution: Also give syntax errors when not evaluating. (closes https://github.com/vim/vim/issues/7154)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 18 Oct 2020 18:15:03 +0200 |
parents | 336ac63fb987 |
children | 5bd53bf63836 |
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 " Tests for Vim9 script expressions |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 source check.vim |
20170
0612c64a2b87
patch 8.2.0640: Vim9: expanding does not work
Bram Moolenaar <Bram@vim.org>
parents:
20089
diff
changeset
|
4 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
|
5 |
21421
0f0fee4122d3
patch 8.2.1261: Vim9: common type of function not tested
Bram Moolenaar <Bram@vim.org>
parents:
21411
diff
changeset
|
6 let g:cond = v:false |
0f0fee4122d3
patch 8.2.1261: Vim9: common type of function not tested
Bram Moolenaar <Bram@vim.org>
parents:
21411
diff
changeset
|
7 def FuncOne(arg: number): string |
0f0fee4122d3
patch 8.2.1261: Vim9: common type of function not tested
Bram Moolenaar <Bram@vim.org>
parents:
21411
diff
changeset
|
8 return 'yes' |
0f0fee4122d3
patch 8.2.1261: Vim9: common type of function not tested
Bram Moolenaar <Bram@vim.org>
parents:
21411
diff
changeset
|
9 enddef |
0f0fee4122d3
patch 8.2.1261: Vim9: common type of function not tested
Bram Moolenaar <Bram@vim.org>
parents:
21411
diff
changeset
|
10 def FuncTwo(arg: number): number |
0f0fee4122d3
patch 8.2.1261: Vim9: common type of function not tested
Bram Moolenaar <Bram@vim.org>
parents:
21411
diff
changeset
|
11 return 123 |
0f0fee4122d3
patch 8.2.1261: Vim9: common type of function not tested
Bram Moolenaar <Bram@vim.org>
parents:
21411
diff
changeset
|
12 enddef |
0f0fee4122d3
patch 8.2.1261: Vim9: common type of function not tested
Bram Moolenaar <Bram@vim.org>
parents:
21411
diff
changeset
|
13 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 " test cond ? expr : expr |
22492
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
15 def Test_expr1_trinary() |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 assert_equal('one', true ? 'one' : 'two') |
20013
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
17 assert_equal('one', 1 ? |
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
18 'one' : |
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
19 'two') |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
19219
diff
changeset
|
20 if has('float') |
22500
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
21 assert_equal('one', !!0.1 ? 'one' : 'two') |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
19219
diff
changeset
|
22 endif |
22500
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
23 assert_equal('one', !!'x' ? 'one' : 'two') |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
24 assert_equal('one', !!'x' |
20988
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
25 ? 'one' |
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
26 : 'two') |
22500
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
27 assert_equal('one', !!0z1234 ? 'one' : 'two') |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
28 assert_equal('one', !![0] ? 'one' : 'two') |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
29 assert_equal('one', !!#{x: 0} ? 'one' : 'two') |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
30 var name = 1 |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
31 assert_equal('one', name ? 'one' : 'two') |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 assert_equal('two', false ? 'one' : 'two') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 assert_equal('two', 0 ? 'one' : 'two') |
19259
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
35 if has('float') |
22500
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
36 assert_equal('two', !!0.0 ? 'one' : 'two') |
19259
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
37 endif |
22500
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
38 assert_equal('two', !!'' ? 'one' : 'two') |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
39 assert_equal('two', !!0z ? 'one' : 'two') |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
40 assert_equal('two', !![] ? 'one' : 'two') |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
41 assert_equal('two', !!{} ? 'one' : 'two') |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
42 name = 0 |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
43 assert_equal('two', name ? 'one' : 'two') |
20207
3c247d9cd6f9
patch 8.2.0659: Vim9: no test for equal func type
Bram Moolenaar <Bram@vim.org>
parents:
20203
diff
changeset
|
44 |
21959
67d4be2757b0
patch 8.2.1529: Vim9: :elseif may be compiled when not needed
Bram Moolenaar <Bram@vim.org>
parents:
21955
diff
changeset
|
45 # with constant condition expression is not evaluated |
67d4be2757b0
patch 8.2.1529: Vim9: :elseif may be compiled when not needed
Bram Moolenaar <Bram@vim.org>
parents:
21955
diff
changeset
|
46 assert_equal('one', 1 ? 'one' : xxx) |
67d4be2757b0
patch 8.2.1529: Vim9: :elseif may be compiled when not needed
Bram Moolenaar <Bram@vim.org>
parents:
21955
diff
changeset
|
47 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
48 var Some: func = function('len') |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
49 var Other: func = function('winnr') |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
50 var Res: func = g:atrue ? Some : Other |
20207
3c247d9cd6f9
patch 8.2.0659: Vim9: no test for equal func type
Bram Moolenaar <Bram@vim.org>
parents:
20203
diff
changeset
|
51 assert_equal(function('len'), Res) |
3c247d9cd6f9
patch 8.2.0659: Vim9: no test for equal func type
Bram Moolenaar <Bram@vim.org>
parents:
20203
diff
changeset
|
52 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
53 var RetOne: func(string): number = function('len') |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
54 var RetTwo: func(string): number = function('winnr') |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
55 var RetThat: func = g:atrue ? RetOne : RetTwo |
20207
3c247d9cd6f9
patch 8.2.0659: Vim9: no test for equal func type
Bram Moolenaar <Bram@vim.org>
parents:
20203
diff
changeset
|
56 assert_equal(function('len'), RetThat) |
21421
0f0fee4122d3
patch 8.2.1261: Vim9: common type of function not tested
Bram Moolenaar <Bram@vim.org>
parents:
21411
diff
changeset
|
57 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
58 var X = FuncOne |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
59 var Y = FuncTwo |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
60 var Z = g:cond ? FuncOne : FuncTwo |
21421
0f0fee4122d3
patch 8.2.1261: Vim9: common type of function not tested
Bram Moolenaar <Bram@vim.org>
parents:
21411
diff
changeset
|
61 assert_equal(123, Z(3)) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 |
22492
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
64 def Test_expr1_trinary_vimscript() |
21644
7d3ba70a03f1
patch 8.2.1372: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21642
diff
changeset
|
65 # check line continuation |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
66 var lines =<< trim END |
21022
9d8634e91d1b
patch 8.2.1062: Vim9: no line break allowed inside "cond ? val1 : val2"
Bram Moolenaar <Bram@vim.org>
parents:
20992
diff
changeset
|
67 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
68 var name = 1 |
21022
9d8634e91d1b
patch 8.2.1062: Vim9: no line break allowed inside "cond ? val1 : val2"
Bram Moolenaar <Bram@vim.org>
parents:
20992
diff
changeset
|
69 ? 'yes' |
9d8634e91d1b
patch 8.2.1062: Vim9: no line break allowed inside "cond ? val1 : val2"
Bram Moolenaar <Bram@vim.org>
parents:
20992
diff
changeset
|
70 : 'no' |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
71 assert_equal('yes', name) |
21022
9d8634e91d1b
patch 8.2.1062: Vim9: no line break allowed inside "cond ? val1 : val2"
Bram Moolenaar <Bram@vim.org>
parents:
20992
diff
changeset
|
72 END |
9d8634e91d1b
patch 8.2.1062: Vim9: no line break allowed inside "cond ? val1 : val2"
Bram Moolenaar <Bram@vim.org>
parents:
20992
diff
changeset
|
73 CheckScriptSuccess(lines) |
9d8634e91d1b
patch 8.2.1062: Vim9: no line break allowed inside "cond ? val1 : val2"
Bram Moolenaar <Bram@vim.org>
parents:
20992
diff
changeset
|
74 |
9d8634e91d1b
patch 8.2.1062: Vim9: no line break allowed inside "cond ? val1 : val2"
Bram Moolenaar <Bram@vim.org>
parents:
20992
diff
changeset
|
75 lines =<< trim END |
9d8634e91d1b
patch 8.2.1062: Vim9: no line break allowed inside "cond ? val1 : val2"
Bram Moolenaar <Bram@vim.org>
parents:
20992
diff
changeset
|
76 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
77 var name = v:false |
21022
9d8634e91d1b
patch 8.2.1062: Vim9: no line break allowed inside "cond ? val1 : val2"
Bram Moolenaar <Bram@vim.org>
parents:
20992
diff
changeset
|
78 ? 'yes' |
9d8634e91d1b
patch 8.2.1062: Vim9: no line break allowed inside "cond ? val1 : val2"
Bram Moolenaar <Bram@vim.org>
parents:
20992
diff
changeset
|
79 : 'no' |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
80 assert_equal('no', name) |
21022
9d8634e91d1b
patch 8.2.1062: Vim9: no line break allowed inside "cond ? val1 : val2"
Bram Moolenaar <Bram@vim.org>
parents:
20992
diff
changeset
|
81 END |
9d8634e91d1b
patch 8.2.1062: Vim9: no line break allowed inside "cond ? val1 : val2"
Bram Moolenaar <Bram@vim.org>
parents:
20992
diff
changeset
|
82 CheckScriptSuccess(lines) |
21046
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
83 |
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
84 lines =<< trim END |
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
85 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
86 var name = v:false ? |
21046
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
87 'yes' : |
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
88 'no' |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
89 assert_equal('no', name) |
21046
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
90 END |
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
91 CheckScriptSuccess(lines) |
21644
7d3ba70a03f1
patch 8.2.1372: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21642
diff
changeset
|
92 |
22580
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
93 lines =<< trim END |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
94 vim9script |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
95 var name = v:false ? # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
96 'yes' : |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
97 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
98 'no' # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
99 assert_equal('no', name) |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
100 END |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
101 CheckScriptSuccess(lines) |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
102 |
21644
7d3ba70a03f1
patch 8.2.1372: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21642
diff
changeset
|
103 # check white space |
7d3ba70a03f1
patch 8.2.1372: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21642
diff
changeset
|
104 lines =<< trim END |
7d3ba70a03f1
patch 8.2.1372: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21642
diff
changeset
|
105 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
106 var name = v:true?1:2 |
21644
7d3ba70a03f1
patch 8.2.1372: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21642
diff
changeset
|
107 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
108 CheckScriptFailure(lines, 'E1004:', 2) |
21644
7d3ba70a03f1
patch 8.2.1372: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21642
diff
changeset
|
109 lines =<< trim END |
7d3ba70a03f1
patch 8.2.1372: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21642
diff
changeset
|
110 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
111 var name = v:true? 1 : 2 |
21644
7d3ba70a03f1
patch 8.2.1372: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21642
diff
changeset
|
112 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
113 CheckScriptFailure(lines, 'E1004:', 2) |
21644
7d3ba70a03f1
patch 8.2.1372: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21642
diff
changeset
|
114 lines =<< trim END |
7d3ba70a03f1
patch 8.2.1372: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21642
diff
changeset
|
115 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
116 var name = v:true ?1 : 2 |
21644
7d3ba70a03f1
patch 8.2.1372: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21642
diff
changeset
|
117 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
118 CheckScriptFailure(lines, 'E1004:', 2) |
21644
7d3ba70a03f1
patch 8.2.1372: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21642
diff
changeset
|
119 lines =<< trim END |
7d3ba70a03f1
patch 8.2.1372: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21642
diff
changeset
|
120 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
121 var name = v:true ? 1: 2 |
21644
7d3ba70a03f1
patch 8.2.1372: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21642
diff
changeset
|
122 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
123 CheckScriptFailure(lines, 'E1004:', 2) |
21644
7d3ba70a03f1
patch 8.2.1372: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21642
diff
changeset
|
124 lines =<< trim END |
7d3ba70a03f1
patch 8.2.1372: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21642
diff
changeset
|
125 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
126 var name = v:true ? 1 :2 |
21644
7d3ba70a03f1
patch 8.2.1372: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21642
diff
changeset
|
127 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
128 CheckScriptFailure(lines, 'E1004:', 2) |
21925
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
129 |
22500
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
130 lines =<< trim END |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
131 vim9script |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
132 var name = 'x' ? 1 : 2 |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
133 END |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
134 CheckScriptFailure(lines, 'E1030:', 2) |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
135 |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
136 lines =<< trim END |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
137 vim9script |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
138 var name = [] ? 1 : 2 |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
139 END |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
140 CheckScriptFailure(lines, 'E745:', 2) |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
141 |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
142 lines =<< trim END |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
143 vim9script |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
144 var name = {} ? 1 : 2 |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
145 END |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
146 CheckScriptFailure(lines, 'E728:', 2) |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
147 |
21925
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
148 # check after failure eval_flags is reset |
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
149 lines =<< trim END |
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
150 vim9script |
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
151 try |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22119
diff
changeset
|
152 eval('0 ? 1: 2') |
21925
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
153 catch |
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
154 endtry |
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
155 assert_equal(v:true, eval(string(v:true))) |
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
156 END |
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
157 CheckScriptSuccess(lines) |
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
158 |
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
159 lines =<< trim END |
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
160 vim9script |
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
161 try |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22119
diff
changeset
|
162 eval('0 ? 1 :2') |
21925
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
163 catch |
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
164 endtry |
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
165 assert_equal(v:true, eval(string(v:true))) |
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
166 END |
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
167 CheckScriptSuccess(lines) |
21022
9d8634e91d1b
patch 8.2.1062: Vim9: no line break allowed inside "cond ? val1 : val2"
Bram Moolenaar <Bram@vim.org>
parents:
20992
diff
changeset
|
168 enddef |
9d8634e91d1b
patch 8.2.1062: Vim9: no line break allowed inside "cond ? val1 : val2"
Bram Moolenaar <Bram@vim.org>
parents:
20992
diff
changeset
|
169 |
22492
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
170 func Test_expr1_trinary_fails() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
171 call CheckDefFailure(["var x = 1 ? 'one'"], "Missing ':' after '?'", 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
172 |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
173 let msg = "White space required before and after '?'" |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
174 call CheckDefFailure(["var x = 1? 'one' : 'two'"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
175 call CheckDefFailure(["var x = 1 ?'one' : 'two'"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
176 call CheckDefFailure(["var x = 1?'one' : 'two'"], msg, 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
177 |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
178 let msg = "White space required before and after ':'" |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
179 call CheckDefFailure(["var x = 1 ? 'one': 'two'"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
180 call CheckDefFailure(["var x = 1 ? 'one' :'two'"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
181 call CheckDefFailure(["var x = 1 ? 'one':'two'"], msg, 1) |
21421
0f0fee4122d3
patch 8.2.1261: Vim9: common type of function not tested
Bram Moolenaar <Bram@vim.org>
parents:
21411
diff
changeset
|
182 |
22500
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
183 call CheckDefFailure(["var x = 'x' ? 'one' : 'two'"], 'E1030:', 1) |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
184 call CheckDefFailure(["var x = 0z1234 ? 'one' : 'two'"], 'E974:', 1) |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
185 call CheckDefExecFailure(["var x = [] ? 'one' : 'two'"], 'E745:', 1) |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
186 call CheckDefExecFailure(["var x = {} ? 'one' : 'two'"], 'E728:', 1) |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
187 |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
188 if has('float') |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
189 call CheckDefFailure(["var x = 0.1 ? 'one' : 'two'"], 'E805:', 1) |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
190 endif |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
191 |
21421
0f0fee4122d3
patch 8.2.1261: Vim9: common type of function not tested
Bram Moolenaar <Bram@vim.org>
parents:
21411
diff
changeset
|
192 " missing argument detected even when common type is used |
0f0fee4122d3
patch 8.2.1261: Vim9: common type of function not tested
Bram Moolenaar <Bram@vim.org>
parents:
21411
diff
changeset
|
193 call CheckDefFailure([ |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
194 \ 'var X = FuncOne', |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
195 \ 'var Y = FuncTwo', |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
196 \ 'var Z = g:cond ? FuncOne : FuncTwo', |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
197 \ 'Z()'], 'E119:', 4) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
198 endfunc |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
199 |
22492
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
200 def Test_expr1_falsy() |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
201 var lines =<< trim END |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
202 assert_equal(v:true, v:true ?? 456) |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
203 assert_equal(123, 123 ?? 456) |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
204 assert_equal('yes', 'yes' ?? 456) |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
205 assert_equal([1], [1] ?? 456) |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
206 assert_equal(#{one: 1}, #{one: 1} ?? 456) |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
207 if has('float') |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
208 assert_equal(0.1, 0.1 ?? 456) |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
209 endif |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
210 |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
211 assert_equal(456, v:false ?? 456) |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
212 assert_equal(456, 0 ?? 456) |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
213 assert_equal(456, '' ?? 456) |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
214 assert_equal(456, [] ?? 456) |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
215 assert_equal(456, {} ?? 456) |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
216 if has('float') |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
217 assert_equal(456, 0.0 ?? 456) |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
218 endif |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
219 END |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
220 CheckDefAndScriptSuccess(lines) |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
221 |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
222 var msg = "White space required before and after '??'" |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
223 call CheckDefFailure(["var x = 1?? 'one' : 'two'"], msg, 1) |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
224 call CheckDefFailure(["var x = 1 ??'one' : 'two'"], msg, 1) |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
225 call CheckDefFailure(["var x = 1??'one' : 'two'"], msg, 1) |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
226 enddef |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
227 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
228 " TODO: define inside test function |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
229 def Record(val: any): any |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
230 g:vals->add(val) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
231 return val |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
232 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
233 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
234 " test || |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
235 def Test_expr2() |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
236 assert_equal(true, 1 || 0) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
237 assert_equal(true, 0 || |
20013
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
238 0 || |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
239 1) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
240 assert_equal(false, 0 || 0) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
241 assert_equal(false, 0 |
20988
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
242 || 0) |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
243 assert_equal(false, 0 || false) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
244 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
245 g:vals = [] |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
246 assert_equal(true, Record(1) || Record(3)) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
247 assert_equal([1], g:vals) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
248 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
249 g:vals = [] |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
250 assert_equal(true, Record(0) || Record(1)) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
251 assert_equal([0, 1], g:vals) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
252 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
253 g:vals = [] |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
254 assert_equal(true, Record(0) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
255 || Record(1) |
20988
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
256 || Record(0)) |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
257 assert_equal([0, 1], g:vals) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
258 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
259 g:vals = [] |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
260 assert_equal(false, Record(0) || Record(false) || Record(0)) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
261 assert_equal([0, false, 0], g:vals) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
262 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
263 |
21024
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
264 def Test_expr2_vimscript() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
265 # check line continuation |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
266 var lines =<< trim END |
21024
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
267 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
268 var name = 0 |
21024
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
269 || 1 |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
270 assert_equal(true, name) |
21024
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
271 END |
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
272 CheckScriptSuccess(lines) |
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
273 |
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
274 lines =<< trim END |
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
275 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
276 var name = v:false |
21024
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
277 || v:true |
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
278 || v:false |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
279 assert_equal(v:true, name) |
21024
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
280 END |
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
281 CheckScriptSuccess(lines) |
21046
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
282 |
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
283 lines =<< trim END |
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
284 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
285 var name = v:false || |
21046
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
286 v:true || |
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
287 v:false |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
288 assert_equal(v:true, name) |
21309
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
289 END |
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
290 CheckScriptSuccess(lines) |
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
291 |
22580
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
292 lines =<< trim END |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
293 vim9script |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
294 var name = v:false || # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
295 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
296 v:true || |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
297 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
298 v:false # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
299 assert_equal(v:true, name) |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
300 END |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
301 CheckScriptSuccess(lines) |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
302 |
21642
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
303 # check white space |
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
304 lines =<< trim END |
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
305 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
306 var name = v:true||v:true |
21642
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
307 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
308 CheckScriptFailure(lines, 'E1004:', 2) |
21642
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
309 lines =<< trim END |
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
310 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
311 var name = v:true ||v:true |
21642
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
312 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
313 CheckScriptFailure(lines, 'E1004:', 2) |
21642
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
314 lines =<< trim END |
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
315 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
316 var name = v:true|| v:true |
21642
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
317 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
318 CheckScriptFailure(lines, 'E1004:', 2) |
21642
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
319 |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
320 # check evaluating to bool |
21309
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
321 lines =<< trim END |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
322 assert_equal(true, 1 || 0) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
323 assert_equal(true, 0 || |
21309
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
324 0 || |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
325 !!7) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
326 assert_equal(false, 0 || 0) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
327 assert_equal(false, 0 |
21309
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
328 || 0) |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
329 assert_equal(false, 0 || false) |
21309
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
330 |
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
331 g:vals = [] |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
332 assert_equal(true, Record(true) || Record(false)) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
333 assert_equal([true], g:vals) |
21309
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
334 |
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
335 g:vals = [] |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
336 assert_equal(true, Record(0) || Record(true)) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
337 assert_equal([0, true], g:vals) |
21309
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
338 |
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
339 g:vals = [] |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
340 assert_equal(true, Record(0) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
341 || Record(true) |
21309
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
342 || Record(0)) |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
343 assert_equal([0, true], g:vals) |
21309
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
344 |
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
345 g:vals = [] |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
346 assert_equal(false, Record(0) || Record(false) || Record(0)) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
347 assert_equal([0, false, 0], g:vals) |
21046
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
348 END |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
349 CheckDefAndScriptSuccess(lines) |
21024
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
350 enddef |
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
351 |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
352 def Test_expr2_fails() |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
353 var msg = "White space required before and after '||'" |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
354 call CheckDefFailure(["var x = 1||2"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
355 call CheckDefFailure(["var x = 1 ||2"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
356 call CheckDefFailure(["var x = 1|| 2"], msg, 1) |
19872
8a7bede7b138
patch 8.2.0492: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19860
diff
changeset
|
357 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
358 call CheckDefFailure(["var x = 1 || xxx"], 'E1001:', 1) |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
359 |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
360 # TODO: should fail at compile time |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
361 call CheckDefExecFailure(["var x = 3 || 7"], 'E1023:', 1) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
362 call CheckScriptFailure(["vim9script", "var x = 3 || 7"], 'E1023:', 2) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
363 call CheckDefExecFailure(["var x = [] || false"], 'E745:', 1) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
364 call CheckScriptFailure(["vim9script", "var x = [] || false"], 'E745:', 2) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
365 enddef |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
366 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
367 " test && |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
368 def Test_expr3() |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
369 assert_equal(false, 1 && 0) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
370 assert_equal(false, 0 && |
20013
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
371 0 && |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
372 1) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
373 assert_equal(true, 1 |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
374 && true |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
375 && 1) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
376 assert_equal(false, 0 && 0) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
377 assert_equal(false, 0 && false) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
378 assert_equal(true, 1 && true) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
379 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
380 g:vals = [] |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
381 assert_equal(true, Record(true) && Record(1)) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
382 assert_equal([true, 1], g:vals) |
19181
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 g:vals = [] |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
385 assert_equal(false, Record(0) && Record(1)) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
386 assert_equal([0], g:vals) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
387 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
388 g:vals = [] |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
389 assert_equal(false, Record(0) && Record(4) && Record(0)) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
390 assert_equal([0], g:vals) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
391 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
392 g:vals = [] |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
393 assert_equal(false, Record(1) && Record(true) && Record(0)) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
394 assert_equal([1, true, 0], g:vals) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
395 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
396 g:vals = [] |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
397 assert_equal(false, Record(1) && Record(true) && Record(0)) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
398 assert_equal([1, true, 0], g:vals) |
19181
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 |
21024
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
401 def Test_expr3_vimscript() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
402 # check line continuation |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
403 var lines =<< trim END |
21024
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
404 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
405 var name = 0 |
21024
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
406 && 1 |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
407 assert_equal(false, name) |
21024
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
408 END |
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
409 CheckScriptSuccess(lines) |
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
410 |
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
411 lines =<< trim END |
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
412 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
413 var name = v:true |
21024
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
414 && v:true |
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
415 && v:true |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
416 assert_equal(v:true, name) |
21024
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
417 END |
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
418 CheckScriptSuccess(lines) |
21046
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
419 |
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
420 lines =<< trim END |
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
421 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
422 var name = v:true && |
21046
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
423 v:true && |
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
424 v:true |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
425 assert_equal(v:true, name) |
21309
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
426 END |
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
427 CheckScriptSuccess(lines) |
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
428 |
22580
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
429 lines =<< trim END |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
430 vim9script |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
431 var name = v:true && # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
432 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
433 v:true && |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
434 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
435 v:true |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
436 assert_equal(v:true, name) |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
437 END |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
438 CheckScriptSuccess(lines) |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
439 |
21642
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
440 # check white space |
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
441 lines =<< trim END |
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
442 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
443 var name = v:true&&v:true |
21642
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
444 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
445 CheckScriptFailure(lines, 'E1004:', 2) |
21642
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
446 lines =<< trim END |
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
447 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
448 var name = v:true &&v:true |
21642
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
449 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
450 CheckScriptFailure(lines, 'E1004:', 2) |
21642
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
451 lines =<< trim END |
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
452 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
453 var name = v:true&& v:true |
21642
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
454 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
455 CheckScriptFailure(lines, 'E1004:', 2) |
21642
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
456 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
457 # check keeping the value |
21309
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
458 lines =<< trim END |
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
459 vim9script |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
460 assert_equal(false, 1 && 0) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
461 assert_equal(false, 0 && |
21309
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
462 0 && |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
463 1) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
464 assert_equal(true, 1 |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
465 && true |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
466 && 1) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
467 assert_equal(false, 0 && 0) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
468 assert_equal(false, 0 && false) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
469 assert_equal(false, 1 && 0) |
21309
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
470 |
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
471 g:vals = [] |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
472 assert_equal(true, Record(1) && Record(true)) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
473 assert_equal([1, true], g:vals) |
21309
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
474 |
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
475 g:vals = [] |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
476 assert_equal(false, Record(0) && Record(1)) |
21309
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
477 assert_equal([0], g:vals) |
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
478 |
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
479 g:vals = [] |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
480 assert_equal(false, Record(0) && Record(1) && Record(0)) |
21309
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
481 assert_equal([0], g:vals) |
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
482 |
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
483 g:vals = [] |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
484 assert_equal(false, Record(1) && Record(true) && Record(0)) |
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
485 assert_equal([1, true, 0], g:vals) |
21046
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
486 END |
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
487 CheckScriptSuccess(lines) |
21024
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
488 enddef |
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
489 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
490 func Test_expr3_fails() |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
491 let msg = "White space required before and after '&&'" |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
492 call CheckDefFailure(["var x = 1&&2"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
493 call CheckDefFailure(["var x = 1 &&2"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
494 call CheckDefFailure(["var x = 1&& 2"], msg, 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
495 endfunc |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
496 |
21831
d8422de73113
patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
21828
diff
changeset
|
497 " global variables to use for tests with the "any" type |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
498 let atrue = v:true |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
499 let afalse = v:false |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
500 let anone = v:none |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
501 let anull = v:null |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
502 let anint = 10 |
21831
d8422de73113
patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
21828
diff
changeset
|
503 let theone = 1 |
d8422de73113
patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
21828
diff
changeset
|
504 let thefour = 4 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
505 if has('float') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
506 let afloat = 0.1 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
507 endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
508 let astring = 'asdf' |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
509 let ablob = 0z01ab |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
510 let alist = [2, 3, 4] |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
511 let adict = #{aaa: 2, bbb: 8} |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
512 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
513 " test == comperator |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
514 def Test_expr4_equal() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
515 var trueVar = true |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
516 var falseVar = false |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
517 assert_equal(true, true == true) |
20013
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
518 assert_equal(false, true == |
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
519 false) |
20988
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
520 assert_equal(true, true |
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
521 == trueVar) |
20470
fafa48fd3461
patch 8.2.0789: Vim9: expression testing lost coverage using constants
Bram Moolenaar <Bram@vim.org>
parents:
20413
diff
changeset
|
522 assert_equal(false, true == falseVar) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
523 assert_equal(true, true == g:atrue) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
524 assert_equal(false, g:atrue == false) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
525 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
526 assert_equal(true, v:none == v:none) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
527 assert_equal(false, v:none == v:null) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
528 assert_equal(true, g:anone == v:none) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
529 assert_equal(false, v:none == g:anull) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
530 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
531 var nr0 = 0 |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
532 var nr61 = 61 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
533 assert_equal(false, 2 == 0) |
20470
fafa48fd3461
patch 8.2.0789: Vim9: expression testing lost coverage using constants
Bram Moolenaar <Bram@vim.org>
parents:
20413
diff
changeset
|
534 assert_equal(false, 2 == nr0) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
535 assert_equal(true, 61 == 61) |
20470
fafa48fd3461
patch 8.2.0789: Vim9: expression testing lost coverage using constants
Bram Moolenaar <Bram@vim.org>
parents:
20413
diff
changeset
|
536 assert_equal(true, 61 == nr61) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
537 assert_equal(true, g:anint == 10) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
538 assert_equal(false, 61 == g:anint) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
539 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
540 if has('float') |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
541 var ff = 0.3 |
20413
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
542 assert_equal(true, ff == 0.3) |
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
543 assert_equal(false, 0.4 == ff) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
544 assert_equal(true, 0.1 == g:afloat) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
545 assert_equal(false, g:afloat == 0.3) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
546 |
20413
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
547 ff = 3.0 |
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
548 assert_equal(true, ff == 3) |
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
549 assert_equal(true, 3 == ff) |
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
550 ff = 3.1 |
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
551 assert_equal(false, ff == 3) |
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
552 assert_equal(false, 3 == ff) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
553 endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
554 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
555 assert_equal(true, 'abc' == 'abc') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
556 assert_equal(false, 'xyz' == 'abc') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
557 assert_equal(true, g:astring == 'asdf') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
558 assert_equal(false, 'xyz' == g:astring) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
559 |
19860
37c4779ca8f5
patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19856
diff
changeset
|
560 assert_equal(false, 'abc' == 'aBc') |
37c4779ca8f5
patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19856
diff
changeset
|
561 assert_equal(false, 'abc' ==# 'aBc') |
37c4779ca8f5
patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19856
diff
changeset
|
562 assert_equal(true, 'abc' ==? 'aBc') |
37c4779ca8f5
patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19856
diff
changeset
|
563 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
564 assert_equal(false, 'abc' == 'ABC') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
565 set ignorecase |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
566 assert_equal(false, 'abc' == 'ABC') |
19860
37c4779ca8f5
patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19856
diff
changeset
|
567 assert_equal(false, 'abc' ==# 'ABC') |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
568 set noignorecase |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
569 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
570 CheckDefFailure(["var x = 'a' == xxx"], 'E1001:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
571 CheckDefExecFailure(['var items: any', 'eval 1', 'eval 2', 'if items == []', 'endif'], 'E691:', 4) |
19860
37c4779ca8f5
patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19856
diff
changeset
|
572 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
573 var bb = 0z3f |
20413
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
574 assert_equal(true, 0z3f == bb) |
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
575 assert_equal(false, bb == 0z4f) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
576 assert_equal(true, g:ablob == 0z01ab) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
577 assert_equal(false, 0z3f == g:ablob) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
578 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
579 assert_equal(true, [1, 2, 3] == [1, 2, 3]) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
580 assert_equal(false, [1, 2, 3] == [2, 3, 1]) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
581 assert_equal(true, [2, 3, 4] == g:alist) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
582 assert_equal(false, g:alist == [2, 3, 1]) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
583 assert_equal(false, [1, 2, 3] == []) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
584 assert_equal(false, [1, 2, 3] == ['1', '2', '3']) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
585 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
586 assert_equal(true, #{one: 1, two: 2} == #{one: 1, two: 2}) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
587 assert_equal(false, #{one: 1, two: 2} == #{one: 2, two: 2}) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
588 assert_equal(false, #{one: 1, two: 2} == #{two: 2}) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
589 assert_equal(false, #{one: 1, two: 2} == #{}) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
590 assert_equal(true, g:adict == #{bbb: 8, aaa: 2}) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
591 assert_equal(false, #{ccc: 9, aaa: 2} == g:adict) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
592 |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
593 assert_equal(true, function('g:Test_expr4_equal') == function('g:Test_expr4_equal')) |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
594 assert_equal(false, function('g:Test_expr4_equal') == function('g:Test_expr4_is')) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
595 |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
596 assert_equal(true, function('g:Test_expr4_equal', [123]) == function('g:Test_expr4_equal', [123])) |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
597 assert_equal(false, function('g:Test_expr4_equal', [123]) == function('g:Test_expr4_is', [123])) |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
598 assert_equal(false, function('g:Test_expr4_equal', [123]) == function('g:Test_expr4_equal', [999])) |
20203
5a397db2c1ed
patch 8.2.0657: Vim9: no check if called variable is a FuncRef
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
599 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
600 var OneFunc: func |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
601 var TwoFunc: func |
20203
5a397db2c1ed
patch 8.2.0657: Vim9: no check if called variable is a FuncRef
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
602 OneFunc = function('len') |
5a397db2c1ed
patch 8.2.0657: Vim9: no check if called variable is a FuncRef
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
603 TwoFunc = function('len') |
5a397db2c1ed
patch 8.2.0657: Vim9: no check if called variable is a FuncRef
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
604 assert_equal(true, OneFunc('abc') == TwoFunc('123')) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
605 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
606 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
607 " test != comperator |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
608 def Test_expr4_notequal() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
609 var trueVar = true |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
610 var falseVar = false |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
611 assert_equal(false, true != true) |
20013
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
612 assert_equal(true, true != |
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
613 false) |
20988
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
614 assert_equal(false, true |
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
615 != trueVar) |
20470
fafa48fd3461
patch 8.2.0789: Vim9: expression testing lost coverage using constants
Bram Moolenaar <Bram@vim.org>
parents:
20413
diff
changeset
|
616 assert_equal(true, true != falseVar) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
617 assert_equal(false, true != g:atrue) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
618 assert_equal(true, g:atrue != false) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
619 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
620 assert_equal(false, v:none != v:none) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
621 assert_equal(true, v:none != v:null) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
622 assert_equal(false, g:anone != v:none) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
623 assert_equal(true, v:none != g:anull) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
624 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
625 var nr55 = 55 |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
626 var nr0 = 55 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
627 assert_equal(true, 2 != 0) |
20470
fafa48fd3461
patch 8.2.0789: Vim9: expression testing lost coverage using constants
Bram Moolenaar <Bram@vim.org>
parents:
20413
diff
changeset
|
628 assert_equal(true, 2 != nr0) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
629 assert_equal(false, 55 != 55) |
20470
fafa48fd3461
patch 8.2.0789: Vim9: expression testing lost coverage using constants
Bram Moolenaar <Bram@vim.org>
parents:
20413
diff
changeset
|
630 assert_equal(false, 55 != nr55) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
631 assert_equal(false, g:anint != 10) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
632 assert_equal(true, 61 != g:anint) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
633 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
634 if has('float') |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
635 var ff = 0.3 |
20413
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
636 assert_equal(false, 0.3 != ff) |
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
637 assert_equal(true, 0.4 != ff) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
638 assert_equal(false, 0.1 != g:afloat) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
639 assert_equal(true, g:afloat != 0.3) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
640 |
20413
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
641 ff = 3.0 |
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
642 assert_equal(false, ff != 3) |
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
643 assert_equal(false, 3 != ff) |
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
644 ff = 3.1 |
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
645 assert_equal(true, ff != 3) |
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
646 assert_equal(true, 3 != ff) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
647 endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
648 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
649 assert_equal(false, 'abc' != 'abc') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
650 assert_equal(true, 'xyz' != 'abc') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
651 assert_equal(false, g:astring != 'asdf') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
652 assert_equal(true, 'xyz' != g:astring) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
653 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
654 assert_equal(true, 'abc' != 'ABC') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
655 set ignorecase |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
656 assert_equal(true, 'abc' != 'ABC') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
657 set noignorecase |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
658 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
659 var bb = 0z3f |
20413
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
660 assert_equal(false, 0z3f != bb) |
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
661 assert_equal(true, bb != 0z4f) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
662 assert_equal(false, g:ablob != 0z01ab) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
663 assert_equal(true, 0z3f != g:ablob) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
664 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
665 assert_equal(false, [1, 2, 3] != [1, 2, 3]) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
666 assert_equal(true, [1, 2, 3] != [2, 3, 1]) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
667 assert_equal(false, [2, 3, 4] != g:alist) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
668 assert_equal(true, g:alist != [2, 3, 1]) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
669 assert_equal(true, [1, 2, 3] != []) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
670 assert_equal(true, [1, 2, 3] != ['1', '2', '3']) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
671 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
672 assert_equal(false, #{one: 1, two: 2} != #{one: 1, two: 2}) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
673 assert_equal(true, #{one: 1, two: 2} != #{one: 2, two: 2}) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
674 assert_equal(true, #{one: 1, two: 2} != #{two: 2}) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
675 assert_equal(true, #{one: 1, two: 2} != #{}) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
676 assert_equal(false, g:adict != #{bbb: 8, aaa: 2}) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
677 assert_equal(true, #{ccc: 9, aaa: 2} != g:adict) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
678 |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
679 assert_equal(false, function('g:Test_expr4_equal') != function('g:Test_expr4_equal')) |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
680 assert_equal(true, function('g:Test_expr4_equal') != function('g:Test_expr4_is')) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
681 |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
682 assert_equal(false, function('g:Test_expr4_equal', [123]) != function('g:Test_expr4_equal', [123])) |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
683 assert_equal(true, function('g:Test_expr4_equal', [123]) != function('g:Test_expr4_is', [123])) |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
684 assert_equal(true, function('g:Test_expr4_equal', [123]) != function('g:Test_expr4_equal', [999])) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
685 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
686 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
687 " test > comperator |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
688 def Test_expr4_greater() |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
689 assert_true(2 > 0) |
20013
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
690 assert_true(2 > |
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
691 1) |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
692 assert_false(2 > 2) |
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
693 assert_false(2 > 3) |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
694 var nr2 = 2 |
20470
fafa48fd3461
patch 8.2.0789: Vim9: expression testing lost coverage using constants
Bram Moolenaar <Bram@vim.org>
parents:
20413
diff
changeset
|
695 assert_true(nr2 > 0) |
fafa48fd3461
patch 8.2.0789: Vim9: expression testing lost coverage using constants
Bram Moolenaar <Bram@vim.org>
parents:
20413
diff
changeset
|
696 assert_true(nr2 > |
fafa48fd3461
patch 8.2.0789: Vim9: expression testing lost coverage using constants
Bram Moolenaar <Bram@vim.org>
parents:
20413
diff
changeset
|
697 1) |
fafa48fd3461
patch 8.2.0789: Vim9: expression testing lost coverage using constants
Bram Moolenaar <Bram@vim.org>
parents:
20413
diff
changeset
|
698 assert_false(nr2 > 2) |
20988
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
699 assert_false(nr2 |
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
700 > 3) |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
701 if has('float') |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
702 var ff = 2.0 |
20413
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
703 assert_true(ff > 0.0) |
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
704 assert_true(ff > 1.0) |
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
705 assert_false(ff > 2.0) |
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
706 assert_false(ff > 3.0) |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
707 endif |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
708 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
709 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
710 " test >= comperator |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
711 def Test_expr4_greaterequal() |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
712 assert_true(2 >= 0) |
20013
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
713 assert_true(2 >= |
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
714 2) |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
715 assert_false(2 >= 3) |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
716 var nr2 = 2 |
20470
fafa48fd3461
patch 8.2.0789: Vim9: expression testing lost coverage using constants
Bram Moolenaar <Bram@vim.org>
parents:
20413
diff
changeset
|
717 assert_true(nr2 >= 0) |
fafa48fd3461
patch 8.2.0789: Vim9: expression testing lost coverage using constants
Bram Moolenaar <Bram@vim.org>
parents:
20413
diff
changeset
|
718 assert_true(nr2 >= 2) |
fafa48fd3461
patch 8.2.0789: Vim9: expression testing lost coverage using constants
Bram Moolenaar <Bram@vim.org>
parents:
20413
diff
changeset
|
719 assert_false(nr2 >= 3) |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
720 if has('float') |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
721 var ff = 2.0 |
20413
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
722 assert_true(ff >= 0.0) |
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
723 assert_true(ff >= 2.0) |
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
724 assert_false(ff >= 3.0) |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
725 endif |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
726 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
727 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
728 " test < comperator |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
729 def Test_expr4_smaller() |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
730 assert_false(2 < 0) |
20013
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
731 assert_false(2 < |
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
732 2) |
20988
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
733 assert_true(2 |
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
734 < 3) |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
735 var nr2 = 2 |
20470
fafa48fd3461
patch 8.2.0789: Vim9: expression testing lost coverage using constants
Bram Moolenaar <Bram@vim.org>
parents:
20413
diff
changeset
|
736 assert_false(nr2 < 0) |
fafa48fd3461
patch 8.2.0789: Vim9: expression testing lost coverage using constants
Bram Moolenaar <Bram@vim.org>
parents:
20413
diff
changeset
|
737 assert_false(nr2 < 2) |
fafa48fd3461
patch 8.2.0789: Vim9: expression testing lost coverage using constants
Bram Moolenaar <Bram@vim.org>
parents:
20413
diff
changeset
|
738 assert_true(nr2 < 3) |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
739 if has('float') |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
740 var ff = 2.0 |
20413
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
741 assert_false(ff < 0.0) |
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
742 assert_false(ff < 2.0) |
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
743 assert_true(ff < 3.0) |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
744 endif |
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 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
747 " test <= comperator |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
748 def Test_expr4_smallerequal() |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
749 assert_false(2 <= 0) |
20013
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
750 assert_false(2 <= |
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
751 1) |
20988
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
752 assert_true(2 |
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
753 <= 2) |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
754 assert_true(2 <= 3) |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
755 var nr2 = 2 |
20470
fafa48fd3461
patch 8.2.0789: Vim9: expression testing lost coverage using constants
Bram Moolenaar <Bram@vim.org>
parents:
20413
diff
changeset
|
756 assert_false(nr2 <= 0) |
fafa48fd3461
patch 8.2.0789: Vim9: expression testing lost coverage using constants
Bram Moolenaar <Bram@vim.org>
parents:
20413
diff
changeset
|
757 assert_false(nr2 <= 1) |
fafa48fd3461
patch 8.2.0789: Vim9: expression testing lost coverage using constants
Bram Moolenaar <Bram@vim.org>
parents:
20413
diff
changeset
|
758 assert_true(nr2 <= 2) |
fafa48fd3461
patch 8.2.0789: Vim9: expression testing lost coverage using constants
Bram Moolenaar <Bram@vim.org>
parents:
20413
diff
changeset
|
759 assert_true(nr2 <= 3) |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
760 if has('float') |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
761 var ff = 2.0 |
20413
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
762 assert_false(ff <= 0.0) |
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
763 assert_false(ff <= 1.0) |
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
764 assert_true(ff <= 2.0) |
92826050c45e
patch 8.2.0761: Vim9: instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
20411
diff
changeset
|
765 assert_true(ff <= 3.0) |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
766 endif |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
767 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
768 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
769 " test =~ comperator |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
770 def Test_expr4_match() |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
771 assert_equal(false, '2' =~ '0') |
20988
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
772 assert_equal(false, '' |
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
773 =~ '0') |
20013
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
774 assert_equal(true, '2' =~ |
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
775 '[0-9]') |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
776 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
777 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
778 " test !~ comperator |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
779 def Test_expr4_nomatch() |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
780 assert_equal(true, '2' !~ '0') |
20988
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
781 assert_equal(true, '' |
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
782 !~ '0') |
20013
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
783 assert_equal(false, '2' !~ |
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
784 '[0-9]') |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
785 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
786 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
787 " test is comperator |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
788 def Test_expr4_is() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
789 var mylist = [2] |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
790 assert_false(mylist is [2]) |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
791 var other = mylist |
20013
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
792 assert_true(mylist is |
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
793 other) |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
794 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
795 var myblob = 0z1234 |
20988
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
796 assert_false(myblob |
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
797 is 0z1234) |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
798 var otherblob = myblob |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
799 assert_true(myblob is otherblob) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
800 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
801 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
802 " test isnot comperator |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
803 def Test_expr4_isnot() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
804 var mylist = [2] |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
805 assert_true('2' isnot '0') |
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
806 assert_true(mylist isnot [2]) |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
807 var other = mylist |
20013
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
808 assert_false(mylist isnot |
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
809 other) |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
810 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
811 var myblob = 0z1234 |
20988
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
812 assert_true(myblob |
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
813 isnot 0z1234) |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
814 var otherblob = myblob |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
815 assert_false(myblob isnot otherblob) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
816 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
817 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
818 def RetVoid() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
819 var x = 1 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
820 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
821 |
21737
a849c984b485
patch 8.2.1418: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
21733
diff
changeset
|
822 def Test_expr4_vim9script() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
823 # check line continuation |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
824 var lines =<< trim END |
21026
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
825 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
826 var name = 0 |
21026
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
827 < 1 |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
828 assert_equal(true, name) |
21026
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
829 END |
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
830 CheckScriptSuccess(lines) |
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
831 |
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
832 lines =<< trim END |
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
833 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
834 var name = 123 |
22580
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
835 # comment |
21026
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
836 != 123 |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
837 assert_equal(false, name) |
21026
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
838 END |
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
839 CheckScriptSuccess(lines) |
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
840 |
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
841 lines =<< trim END |
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
842 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
843 var name = 123 == |
21046
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
844 123 |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
845 assert_equal(true, name) |
21046
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
846 END |
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
847 CheckScriptSuccess(lines) |
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
848 |
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
849 lines =<< trim END |
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
850 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
851 var list = [1, 2, 3] |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
852 var name = list |
21026
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
853 is list |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
854 assert_equal(true, name) |
21026
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
855 END |
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
856 CheckScriptSuccess(lines) |
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
857 |
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
858 lines =<< trim END |
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
859 vim9script |
22580
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
860 var list = [1, 2, 3] |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
861 var name = list # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
862 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
863 is list |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
864 assert_equal(true, name) |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
865 END |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
866 CheckScriptSuccess(lines) |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
867 |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
868 lines =<< trim END |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
869 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
870 var myblob = 0z1234 |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
871 var name = myblob |
21026
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
872 isnot 0z11 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
873 assert_equal(true, name) |
21026
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
874 END |
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
875 CheckScriptSuccess(lines) |
21251
d1215fcdbca8
patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21248
diff
changeset
|
876 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
877 # spot check mismatching types |
21251
d1215fcdbca8
patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21248
diff
changeset
|
878 lines =<< trim END |
d1215fcdbca8
patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21248
diff
changeset
|
879 vim9script |
d1215fcdbca8
patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21248
diff
changeset
|
880 echo '' == 0 |
d1215fcdbca8
patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21248
diff
changeset
|
881 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
882 CheckScriptFailure(lines, 'E1072:', 2) |
21251
d1215fcdbca8
patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21248
diff
changeset
|
883 |
d1215fcdbca8
patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21248
diff
changeset
|
884 lines =<< trim END |
d1215fcdbca8
patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21248
diff
changeset
|
885 vim9script |
d1215fcdbca8
patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21248
diff
changeset
|
886 echo v:true > v:false |
d1215fcdbca8
patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21248
diff
changeset
|
887 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
888 CheckScriptFailure(lines, 'Cannot compare bool with bool', 2) |
21251
d1215fcdbca8
patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21248
diff
changeset
|
889 |
d1215fcdbca8
patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21248
diff
changeset
|
890 lines =<< trim END |
d1215fcdbca8
patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21248
diff
changeset
|
891 vim9script |
d1215fcdbca8
patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21248
diff
changeset
|
892 echo 123 is 123 |
d1215fcdbca8
patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21248
diff
changeset
|
893 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
894 CheckScriptFailure(lines, 'Cannot use "is" with number', 2) |
21425
a6c316ef161a
patch 8.2.1263: Vim9: comperators use 'ignorecase' in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21421
diff
changeset
|
895 |
a6c316ef161a
patch 8.2.1263: Vim9: comperators use 'ignorecase' in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21421
diff
changeset
|
896 # check 'ignorecase' not being used |
a6c316ef161a
patch 8.2.1263: Vim9: comperators use 'ignorecase' in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21421
diff
changeset
|
897 lines =<< trim END |
a6c316ef161a
patch 8.2.1263: Vim9: comperators use 'ignorecase' in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21421
diff
changeset
|
898 vim9script |
a6c316ef161a
patch 8.2.1263: Vim9: comperators use 'ignorecase' in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21421
diff
changeset
|
899 set ignorecase |
a6c316ef161a
patch 8.2.1263: Vim9: comperators use 'ignorecase' in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21421
diff
changeset
|
900 assert_equal(false, 'abc' == 'ABC') |
a6c316ef161a
patch 8.2.1263: Vim9: comperators use 'ignorecase' in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21421
diff
changeset
|
901 assert_equal(false, 'abc' ==# 'ABC') |
a6c316ef161a
patch 8.2.1263: Vim9: comperators use 'ignorecase' in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21421
diff
changeset
|
902 assert_equal(true, 'abc' ==? 'ABC') |
a6c316ef161a
patch 8.2.1263: Vim9: comperators use 'ignorecase' in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21421
diff
changeset
|
903 |
a6c316ef161a
patch 8.2.1263: Vim9: comperators use 'ignorecase' in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21421
diff
changeset
|
904 assert_equal(true, 'abc' != 'ABC') |
a6c316ef161a
patch 8.2.1263: Vim9: comperators use 'ignorecase' in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21421
diff
changeset
|
905 assert_equal(true, 'abc' !=# 'ABC') |
a6c316ef161a
patch 8.2.1263: Vim9: comperators use 'ignorecase' in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21421
diff
changeset
|
906 assert_equal(false, 'abc' !=? 'ABC') |
a6c316ef161a
patch 8.2.1263: Vim9: comperators use 'ignorecase' in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21421
diff
changeset
|
907 |
a6c316ef161a
patch 8.2.1263: Vim9: comperators use 'ignorecase' in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21421
diff
changeset
|
908 assert_equal(false, 'abc' =~ 'ABC') |
a6c316ef161a
patch 8.2.1263: Vim9: comperators use 'ignorecase' in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21421
diff
changeset
|
909 assert_equal(false, 'abc' =~# 'ABC') |
a6c316ef161a
patch 8.2.1263: Vim9: comperators use 'ignorecase' in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21421
diff
changeset
|
910 assert_equal(true, 'abc' =~? 'ABC') |
a6c316ef161a
patch 8.2.1263: Vim9: comperators use 'ignorecase' in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21421
diff
changeset
|
911 set noignorecase |
a6c316ef161a
patch 8.2.1263: Vim9: comperators use 'ignorecase' in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21421
diff
changeset
|
912 END |
a6c316ef161a
patch 8.2.1263: Vim9: comperators use 'ignorecase' in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21421
diff
changeset
|
913 CheckScriptSuccess(lines) |
21636
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
914 |
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
915 # check missing white space |
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
916 lines =<< trim END |
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
917 vim9script |
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
918 echo 2>3 |
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
919 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
920 CheckScriptFailure(lines, 'E1004:', 2) |
21636
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
921 lines =<< trim END |
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
922 vim9script |
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
923 echo 2 >3 |
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
924 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
925 CheckScriptFailure(lines, 'E1004:', 2) |
21636
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
926 lines =<< trim END |
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
927 vim9script |
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
928 echo 2> 3 |
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
929 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
930 CheckScriptFailure(lines, 'E1004:', 2) |
21636
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
931 lines =<< trim END |
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
932 vim9script |
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
933 echo 2!=3 |
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
934 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
935 CheckScriptFailure(lines, 'E1004:', 2) |
21636
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
936 lines =<< trim END |
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
937 vim9script |
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
938 echo 2 !=3 |
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
939 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
940 CheckScriptFailure(lines, 'E1004:', 2) |
21636
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
941 lines =<< trim END |
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
942 vim9script |
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
943 echo 2!= 3 |
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
944 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
945 CheckScriptFailure(lines, 'E1004:', 2) |
21737
a849c984b485
patch 8.2.1418: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
21733
diff
changeset
|
946 |
a849c984b485
patch 8.2.1418: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
21733
diff
changeset
|
947 lines =<< trim END |
a849c984b485
patch 8.2.1418: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
21733
diff
changeset
|
948 vim9script |
a849c984b485
patch 8.2.1418: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
21733
diff
changeset
|
949 echo len('xxx') == 3 |
a849c984b485
patch 8.2.1418: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
21733
diff
changeset
|
950 END |
a849c984b485
patch 8.2.1418: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
21733
diff
changeset
|
951 CheckScriptSuccess(lines) |
21837
2b941fbab4d9
patch 8.2.1468: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
952 |
2b941fbab4d9
patch 8.2.1468: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
953 lines =<< trim END |
2b941fbab4d9
patch 8.2.1468: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
954 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
955 var line = 'abc' |
21837
2b941fbab4d9
patch 8.2.1468: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
956 echo line[1] =~ '\w' |
2b941fbab4d9
patch 8.2.1468: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
957 END |
2b941fbab4d9
patch 8.2.1468: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
958 CheckScriptSuccess(lines) |
21026
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
959 enddef |
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
960 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
961 func Test_expr4_fails() |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
962 let msg = "White space required before and after '>'" |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
963 call CheckDefFailure(["var x = 1>2"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
964 call CheckDefFailure(["var x = 1 >2"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
965 call CheckDefFailure(["var x = 1> 2"], msg, 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
966 |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
967 let msg = "White space required before and after '=='" |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
968 call CheckDefFailure(["var x = 1==2"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
969 call CheckDefFailure(["var x = 1 ==2"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
970 call CheckDefFailure(["var x = 1== 2"], msg, 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
971 |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
972 let msg = "White space required before and after 'is'" |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
973 call CheckDefFailure(["var x = '1'is'2'"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
974 call CheckDefFailure(["var x = '1' is'2'"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
975 call CheckDefFailure(["var x = '1'is '2'"], msg, 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
976 |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
977 let msg = "White space required before and after 'isnot'" |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
978 call CheckDefFailure(["var x = '1'isnot'2'"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
979 call CheckDefFailure(["var x = '1' isnot'2'"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
980 call CheckDefFailure(["var x = '1'isnot '2'"], msg, 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
981 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
982 call CheckDefFailure(["var x = 1 is# 2"], 'E15:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
983 call CheckDefFailure(["var x = 1 is? 2"], 'E15:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
984 call CheckDefFailure(["var x = 1 isnot# 2"], 'E15:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
985 call CheckDefFailure(["var x = 1 isnot? 2"], 'E15:', 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
986 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
987 call CheckDefFailure(["var x = 1 == '2'"], 'Cannot compare number with string', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
988 call CheckDefFailure(["var x = '1' == 2"], 'Cannot compare string with number', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
989 call CheckDefFailure(["var x = 1 == RetVoid()"], 'Cannot compare number with void', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
990 call CheckDefFailure(["var x = RetVoid() == 1"], 'Cannot compare void with number', 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
991 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
992 call CheckDefFailure(["var x = true > false"], 'Cannot compare bool with bool', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
993 call CheckDefFailure(["var x = true >= false"], 'Cannot compare bool with bool', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
994 call CheckDefFailure(["var x = true < false"], 'Cannot compare bool with bool', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
995 call CheckDefFailure(["var x = true <= false"], 'Cannot compare bool with bool', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
996 call CheckDefFailure(["var x = true =~ false"], 'Cannot compare bool with bool', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
997 call CheckDefFailure(["var x = true !~ false"], 'Cannot compare bool with bool', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
998 call CheckDefFailure(["var x = true is false"], 'Cannot use "is" with bool', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
999 call CheckDefFailure(["var x = true isnot false"], 'Cannot use "isnot" with bool', 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1000 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1001 call CheckDefFailure(["var x = v:none is v:null"], 'Cannot use "is" with special', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1002 call CheckDefFailure(["var x = v:none isnot v:null"], 'Cannot use "isnot" with special', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1003 call CheckDefFailure(["var x = 123 is 123"], 'Cannot use "is" with number', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1004 call CheckDefFailure(["var x = 123 isnot 123"], 'Cannot use "isnot" with number', 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1005 if has('float') |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1006 call CheckDefFailure(["var x = 1.3 is 1.3"], 'Cannot use "is" with float', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1007 call CheckDefFailure(["var x = 1.3 isnot 1.3"], 'Cannot use "isnot" with float', 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1008 endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1009 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1010 call CheckDefFailure(["var x = 0za1 > 0z34"], 'Cannot compare blob with blob', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1011 call CheckDefFailure(["var x = 0za1 >= 0z34"], 'Cannot compare blob with blob', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1012 call CheckDefFailure(["var x = 0za1 < 0z34"], 'Cannot compare blob with blob', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1013 call CheckDefFailure(["var x = 0za1 <= 0z34"], 'Cannot compare blob with blob', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1014 call CheckDefFailure(["var x = 0za1 =~ 0z34"], 'Cannot compare blob with blob', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1015 call CheckDefFailure(["var x = 0za1 !~ 0z34"], 'Cannot compare blob with blob', 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1016 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1017 call CheckDefFailure(["var x = [13] > [88]"], 'Cannot compare list with list', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1018 call CheckDefFailure(["var x = [13] >= [88]"], 'Cannot compare list with list', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1019 call CheckDefFailure(["var x = [13] < [88]"], 'Cannot compare list with list', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1020 call CheckDefFailure(["var x = [13] <= [88]"], 'Cannot compare list with list', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1021 call CheckDefFailure(["var x = [13] =~ [88]"], 'Cannot compare list with list', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1022 call CheckDefFailure(["var x = [13] !~ [88]"], 'Cannot compare list with list', 1) |
19583
ba35daca6553
patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents:
19558
diff
changeset
|
1023 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1024 call CheckDefFailure(['var j: job', 'var chan: channel', 'var r = j == chan'], 'Cannot compare job with channel', 3) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1025 call CheckDefFailure(['var j: job', 'var x: list<any>', 'var r = j == x'], 'Cannot compare job with list', 3) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1026 call CheckDefFailure(['var j: job', 'var Xx: func', 'var r = j == Xx'], 'Cannot compare job with func', 3) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1027 call CheckDefFailure(['var j: job', 'var Xx: func', 'var r = j == Xx'], 'Cannot compare job with func', 3) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1028 endfunc |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1029 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1030 " test addition, subtraction, concatenation |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1031 def Test_expr5() |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1032 assert_equal(66, 60 + 6) |
20013
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
1033 assert_equal(70, 60 + |
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
1034 g:anint) |
21831
d8422de73113
patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
21828
diff
changeset
|
1035 assert_equal(9, g:thefour |
20988
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
1036 + 5) |
21831
d8422de73113
patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
21828
diff
changeset
|
1037 assert_equal(14, g:thefour + g:anint) |
20919
96bf2b304932
patch 8.2.1011: Vim9: some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
20470
diff
changeset
|
1038 assert_equal([1, 2, 3, 4], [1] + g:alist) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1039 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1040 assert_equal(54, 60 - 6) |
20013
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
1041 assert_equal(50, 60 - |
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
1042 g:anint) |
21831
d8422de73113
patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
21828
diff
changeset
|
1043 assert_equal(-1, g:thefour |
20988
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
1044 - 5) |
21831
d8422de73113
patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
21828
diff
changeset
|
1045 assert_equal(-6, g:thefour - g:anint) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1046 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1047 assert_equal('hello', 'hel' .. 'lo') |
20318
3cbcee39fc5c
patch 8.2.0714: Vim9: handling constant expression does not scale
Bram Moolenaar <Bram@vim.org>
parents:
20305
diff
changeset
|
1048 assert_equal('hello 123', 'hello ' .. |
3cbcee39fc5c
patch 8.2.0714: Vim9: handling constant expression does not scale
Bram Moolenaar <Bram@vim.org>
parents:
20305
diff
changeset
|
1049 123) |
20988
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
1050 assert_equal('hello 123', 'hello ' |
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
1051 .. 123) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1052 assert_equal('123 hello', 123 .. ' hello') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1053 assert_equal('123456', 123 .. 456) |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
1054 |
21771
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1055 assert_equal('av:true', 'a' .. true) |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1056 assert_equal('av:false', 'a' .. false) |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1057 assert_equal('av:null', 'a' .. v:null) |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1058 assert_equal('av:none', 'a' .. v:none) |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1059 if has('float') |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1060 assert_equal('a0.123', 'a' .. 0.123) |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1061 endif |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1062 |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
1063 assert_equal([1, 2, 3, 4], [1, 2] + [3, 4]) |
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
1064 assert_equal(0z11223344, 0z1122 + 0z3344) |
20988
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
1065 assert_equal(0z112201ab, 0z1122 |
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
1066 + g:ablob) |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
1067 assert_equal(0z01ab3344, g:ablob + 0z3344) |
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
1068 assert_equal(0z01ab01ab, g:ablob + g:ablob) |
21903
1fc2ffadf412
patch 8.2.1501: Vim9: concatenating to constant reverses order
Bram Moolenaar <Bram@vim.org>
parents:
21865
diff
changeset
|
1069 |
1fc2ffadf412
patch 8.2.1501: Vim9: concatenating to constant reverses order
Bram Moolenaar <Bram@vim.org>
parents:
21865
diff
changeset
|
1070 # concatenate non-constant to constant |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1071 var save_path = &path |
21903
1fc2ffadf412
patch 8.2.1501: Vim9: concatenating to constant reverses order
Bram Moolenaar <Bram@vim.org>
parents:
21865
diff
changeset
|
1072 &path = 'b' |
1fc2ffadf412
patch 8.2.1501: Vim9: concatenating to constant reverses order
Bram Moolenaar <Bram@vim.org>
parents:
21865
diff
changeset
|
1073 assert_equal('ab', 'a' .. &path) |
1fc2ffadf412
patch 8.2.1501: Vim9: concatenating to constant reverses order
Bram Moolenaar <Bram@vim.org>
parents:
21865
diff
changeset
|
1074 &path = save_path |
1fc2ffadf412
patch 8.2.1501: Vim9: concatenating to constant reverses order
Bram Moolenaar <Bram@vim.org>
parents:
21865
diff
changeset
|
1075 |
1fc2ffadf412
patch 8.2.1501: Vim9: concatenating to constant reverses order
Bram Moolenaar <Bram@vim.org>
parents:
21865
diff
changeset
|
1076 @b = 'b' |
1fc2ffadf412
patch 8.2.1501: Vim9: concatenating to constant reverses order
Bram Moolenaar <Bram@vim.org>
parents:
21865
diff
changeset
|
1077 assert_equal('ab', 'a' .. @b) |
1fc2ffadf412
patch 8.2.1501: Vim9: concatenating to constant reverses order
Bram Moolenaar <Bram@vim.org>
parents:
21865
diff
changeset
|
1078 |
1fc2ffadf412
patch 8.2.1501: Vim9: concatenating to constant reverses order
Bram Moolenaar <Bram@vim.org>
parents:
21865
diff
changeset
|
1079 $ENVVAR = 'env' |
1fc2ffadf412
patch 8.2.1501: Vim9: concatenating to constant reverses order
Bram Moolenaar <Bram@vim.org>
parents:
21865
diff
changeset
|
1080 assert_equal('aenv', 'a' .. $ENVVAR) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1081 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1082 |
20992
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1083 def Test_expr5_vim9script() |
21546
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1084 # check line continuation |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1085 var lines =<< trim END |
20992
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1086 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1087 var name = 11 |
20992
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1088 + 77 |
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1089 - 22 |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1090 assert_equal(66, name) |
20992
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1091 END |
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1092 CheckScriptSuccess(lines) |
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1093 |
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1094 lines =<< trim END |
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1095 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1096 var name = 11 + |
21634
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1097 77 - |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1098 22 |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1099 assert_equal(66, name) |
21634
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1100 END |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1101 CheckScriptSuccess(lines) |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1102 |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1103 lines =<< trim END |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1104 vim9script |
22580
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1105 var name = 11 + # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1106 77 - |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1107 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1108 22 |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1109 assert_equal(66, name) |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1110 END |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1111 CheckScriptSuccess(lines) |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1112 |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1113 lines =<< trim END |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1114 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1115 var name = 'one' |
20992
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1116 .. 'two' |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1117 assert_equal('onetwo', name) |
20992
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1118 END |
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1119 CheckScriptSuccess(lines) |
21546
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1120 |
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1121 lines =<< trim END |
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1122 vim9script |
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1123 echo 'abc' is# 'abc' |
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1124 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1125 CheckScriptFailure(lines, 'E15:', 2) |
21546
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1126 |
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1127 lines =<< trim END |
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1128 vim9script |
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1129 echo 'abc' is? 'abc' |
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1130 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1131 CheckScriptFailure(lines, 'E15:', 2) |
21546
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1132 |
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1133 lines =<< trim END |
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1134 vim9script |
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1135 echo 'abc' isnot# 'abc' |
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1136 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1137 CheckScriptFailure(lines, 'E15:', 2) |
21546
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1138 |
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1139 lines =<< trim END |
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1140 vim9script |
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1141 echo 'abc' isnot? 'abc' |
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1142 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1143 CheckScriptFailure(lines, 'E15:', 2) |
21630
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1144 |
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1145 # check white space |
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1146 lines =<< trim END |
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1147 vim9script |
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1148 echo 5+6 |
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1149 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1150 CheckScriptFailure(lines, 'E1004:', 2) |
21630
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1151 lines =<< trim END |
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1152 vim9script |
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1153 echo 5 +6 |
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1154 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1155 CheckScriptFailure(lines, 'E1004:', 2) |
21630
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1156 lines =<< trim END |
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1157 vim9script |
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1158 echo 5+ 6 |
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1159 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1160 CheckScriptFailure(lines, 'E1004:', 2) |
21630
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1161 |
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1162 lines =<< trim END |
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1163 vim9script |
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1164 echo 'a'..'b' |
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1165 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1166 CheckScriptFailure(lines, 'E1004:', 2) |
21630
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1167 lines =<< trim END |
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1168 vim9script |
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1169 echo 'a' ..'b' |
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1170 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1171 CheckScriptFailure(lines, 'E1004:', 2) |
21630
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1172 lines =<< trim END |
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1173 vim9script |
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1174 echo 'a'.. 'b' |
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1175 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1176 CheckScriptFailure(lines, 'E1004:', 2) |
21771
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1177 |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1178 # check valid string concatenation |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1179 lines =<< trim END |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1180 vim9script |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1181 assert_equal('one123', 'one' .. 123) |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1182 assert_equal('onev:true', 'one' .. true) |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1183 assert_equal('onev:null', 'one' .. v:null) |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1184 assert_equal('onev:none', 'one' .. v:none) |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1185 if has('float') |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1186 assert_equal('a0.123', 'a' .. 0.123) |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1187 endif |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1188 END |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1189 CheckScriptSuccess(lines) |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1190 |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1191 # check invalid string concatenation |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1192 lines =<< trim END |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1193 vim9script |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1194 echo 'a' .. [1] |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1195 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1196 CheckScriptFailure(lines, 'E730:', 2) |
21771
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1197 lines =<< trim END |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1198 vim9script |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1199 echo 'a' .. #{a: 1} |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1200 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1201 CheckScriptFailure(lines, 'E731:', 2) |
21771
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1202 lines =<< trim END |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1203 vim9script |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1204 echo 'a' .. test_void() |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1205 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1206 CheckScriptFailure(lines, 'E908:', 2) |
21771
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1207 lines =<< trim END |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1208 vim9script |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1209 echo 'a' .. 0z33 |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1210 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1211 CheckScriptFailure(lines, 'E976:', 2) |
21771
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1212 lines =<< trim END |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1213 vim9script |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1214 echo 'a' .. function('len') |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1215 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1216 CheckScriptFailure(lines, 'E729:', 2) |
22119
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1217 enddef |
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1218 |
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1219 def Test_expr5_vim9script_channel() |
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1220 if !has('channel') |
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1221 MissingFeature 'float' |
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1222 else |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1223 var lines =<< trim END |
22119
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1224 vim9script |
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1225 echo 'a' .. test_null_job() |
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1226 END |
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1227 CheckScriptFailure(lines, 'E908:', 2) |
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1228 lines =<< trim END |
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1229 vim9script |
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1230 echo 'a' .. test_null_channel() |
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1231 END |
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1232 CheckScriptFailure(lines, 'E908:', 2) |
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1233 endif |
20992
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1234 enddef |
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1235 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1236 def Test_expr5_float() |
19259
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1237 if !has('float') |
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1238 MissingFeature 'float' |
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1239 else |
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1240 assert_equal(66.0, 60.0 + 6.0) |
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1241 assert_equal(66.0, 60.0 + 6) |
20013
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
1242 assert_equal(66.0, 60 + |
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
1243 6.0) |
20988
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
1244 assert_equal(5.1, g:afloat |
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
1245 + 5) |
19259
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1246 assert_equal(8.1, 8 + g:afloat) |
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1247 assert_equal(10.1, g:anint + g:afloat) |
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1248 assert_equal(10.1, g:afloat + g:anint) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1249 |
19259
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1250 assert_equal(54.0, 60.0 - 6.0) |
20988
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
1251 assert_equal(54.0, 60.0 |
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
1252 - 6) |
19259
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1253 assert_equal(54.0, 60 - 6.0) |
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1254 assert_equal(-4.9, g:afloat - 5) |
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1255 assert_equal(7.9, 8 - g:afloat) |
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1256 assert_equal(9.9, g:anint - g:afloat) |
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1257 assert_equal(-9.9, g:afloat - g:anint) |
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1258 endif |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1259 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1260 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1261 func Test_expr5_fails() |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1262 let msg = "White space required before and after '+'" |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1263 call CheckDefFailure(["var x = 1+2"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1264 call CheckDefFailure(["var x = 1 +2"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1265 call CheckDefFailure(["var x = 1+ 2"], msg, 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1266 |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1267 let msg = "White space required before and after '-'" |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1268 call CheckDefFailure(["var x = 1-2"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1269 call CheckDefFailure(["var x = 1 -2"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1270 call CheckDefFailure(["var x = 1- 2"], msg, 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1271 |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1272 let msg = "White space required before and after '..'" |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1273 call CheckDefFailure(["var x = '1'..'2'"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1274 call CheckDefFailure(["var x = '1' ..'2'"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1275 call CheckDefFailure(["var x = '1'.. '2'"], msg, 1) |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
1276 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1277 call CheckDefFailure(["var x = 0z1122 + 33"], 'E1051', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1278 call CheckDefFailure(["var x = 0z1122 + [3]"], 'E1051', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1279 call CheckDefFailure(["var x = 0z1122 + 'asd'"], 'E1051', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1280 call CheckDefFailure(["var x = 33 + 0z1122"], 'E1051', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1281 call CheckDefFailure(["var x = [3] + 0z1122"], 'E1051', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1282 call CheckDefFailure(["var x = 'asdf' + 0z1122"], 'E1051', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1283 call CheckDefFailure(["var x = 6 + xxx"], 'E1001', 1) |
21771
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1284 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1285 call CheckDefFailure(["var x = 'a' .. [1]"], 'E1105', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1286 call CheckDefFailure(["var x = 'a' .. #{a: 1}"], 'E1105', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1287 call CheckDefFailure(["var x = 'a' .. test_void()"], 'E1105', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1288 call CheckDefFailure(["var x = 'a' .. 0z32"], 'E1105', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1289 call CheckDefFailure(["var x = 'a' .. function('len')"], 'E1105', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1290 call CheckDefFailure(["var x = 'a' .. function('len', ['a'])"], 'E1105', 1) |
22119
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1291 endfunc |
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1292 |
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1293 func Test_expr5_fails_channel() |
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1294 CheckFeature channel |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1295 call CheckDefFailure(["var x = 'a' .. test_null_job()"], 'E1105', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1296 call CheckDefFailure(["var x = 'a' .. test_null_channel()"], 'E1105', 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1297 endfunc |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1298 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1299 " test multiply, divide, modulo |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1300 def Test_expr6() |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1301 assert_equal(36, 6 * 6) |
20013
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
1302 assert_equal(24, 6 * |
21831
d8422de73113
patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
21828
diff
changeset
|
1303 g:thefour) |
d8422de73113
patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
21828
diff
changeset
|
1304 assert_equal(24, g:thefour |
20988
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
1305 * 6) |
21831
d8422de73113
patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
21828
diff
changeset
|
1306 assert_equal(40, g:anint * g:thefour) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1307 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1308 assert_equal(10, 60 / 6) |
20013
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
1309 assert_equal(6, 60 / |
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
1310 g:anint) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1311 assert_equal(1, g:anint / 6) |
20988
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
1312 assert_equal(2, g:anint |
21831
d8422de73113
patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
21828
diff
changeset
|
1313 / g:thefour) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1314 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1315 assert_equal(5, 11 % 6) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1316 assert_equal(4, g:anint % 6) |
20013
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
1317 assert_equal(3, 13 % |
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
1318 g:anint) |
20988
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
1319 assert_equal(2, g:anint |
21831
d8422de73113
patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
21828
diff
changeset
|
1320 % g:thefour) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1321 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1322 assert_equal(4, 6 * 4 / 6) |
19423
f3e8e74cb747
patch 8.2.0269: Vim9: operator after list index does not work
Bram Moolenaar <Bram@vim.org>
parents:
19259
diff
changeset
|
1323 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1324 var x = [2] |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1325 var y = [3] |
19423
f3e8e74cb747
patch 8.2.0269: Vim9: operator after list index does not work
Bram Moolenaar <Bram@vim.org>
parents:
19259
diff
changeset
|
1326 assert_equal(5, x[0] + y[0]) |
f3e8e74cb747
patch 8.2.0269: Vim9: operator after list index does not work
Bram Moolenaar <Bram@vim.org>
parents:
19259
diff
changeset
|
1327 assert_equal(6, x[0] * y[0]) |
f3e8e74cb747
patch 8.2.0269: Vim9: operator after list index does not work
Bram Moolenaar <Bram@vim.org>
parents:
19259
diff
changeset
|
1328 if has('float') |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1329 var xf = [2.0] |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1330 var yf = [3.0] |
20988
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
1331 assert_equal(5.0, xf[0] |
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
1332 + yf[0]) |
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
1333 assert_equal(6.0, xf[0] |
ae4b1d497a06
patch 8.2.1045: Vim9: line break before operator does not work
Bram Moolenaar <Bram@vim.org>
parents:
20982
diff
changeset
|
1334 * yf[0]) |
19423
f3e8e74cb747
patch 8.2.0269: Vim9: operator after list index does not work
Bram Moolenaar <Bram@vim.org>
parents:
19259
diff
changeset
|
1335 endif |
19856
90eec641cc8c
patch 8.2.0484: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19854
diff
changeset
|
1336 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1337 CheckDefFailure(["var x = 6 * xxx"], 'E1001', 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1338 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1339 |
20992
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1340 def Test_expr6_vim9script() |
21634
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1341 # check line continuation |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1342 var lines =<< trim END |
20992
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1343 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1344 var name = 11 |
20992
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1345 * 22 |
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1346 / 3 |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1347 assert_equal(80, name) |
20992
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1348 END |
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1349 CheckScriptSuccess(lines) |
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1350 |
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1351 lines =<< trim END |
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1352 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1353 var name = 25 |
20992
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1354 % 10 |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1355 assert_equal(5, name) |
20992
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1356 END |
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1357 CheckScriptSuccess(lines) |
21634
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1358 |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1359 lines =<< trim END |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1360 vim9script |
22580
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1361 var name = 25 |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1362 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1363 |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1364 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1365 % 10 |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1366 assert_equal(5, name) |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1367 END |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1368 CheckScriptSuccess(lines) |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1369 |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1370 lines =<< trim END |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1371 vim9script |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1372 var name = 11 * |
21634
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1373 22 / |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1374 3 |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1375 assert_equal(80, name) |
21634
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1376 END |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1377 CheckScriptSuccess(lines) |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1378 |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1379 # check white space |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1380 lines =<< trim END |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1381 vim9script |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1382 echo 5*6 |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1383 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1384 CheckScriptFailure(lines, 'E1004:', 2) |
21634
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1385 lines =<< trim END |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1386 vim9script |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1387 echo 5 *6 |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1388 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1389 CheckScriptFailure(lines, 'E1004:', 2) |
21634
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1390 lines =<< trim END |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1391 vim9script |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1392 echo 5* 6 |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1393 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1394 CheckScriptFailure(lines, 'E1004:', 2) |
20992
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1395 enddef |
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1396 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1397 def Test_expr6_float() |
19259
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1398 if !has('float') |
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1399 MissingFeature 'float' |
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1400 else |
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1401 assert_equal(36.0, 6.0 * 6) |
20013
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
1402 assert_equal(36.0, 6 * |
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
1403 6.0) |
19259
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1404 assert_equal(36.0, 6.0 * 6.0) |
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1405 assert_equal(1.0, g:afloat * g:anint) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1406 |
19259
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1407 assert_equal(10.0, 60 / 6.0) |
20013
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
1408 assert_equal(10.0, 60.0 / |
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
1409 6) |
19259
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1410 assert_equal(10.0, 60.0 / 6.0) |
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1411 assert_equal(0.01, g:afloat / g:anint) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1412 |
19259
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1413 assert_equal(4.0, 6.0 * 4 / 6) |
20013
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
1414 assert_equal(4.0, 6 * |
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
1415 4.0 / |
bf377a9ffccb
patch 8.2.0562: Vim9: cannot split an expression into multiple lines
Bram Moolenaar <Bram@vim.org>
parents:
20005
diff
changeset
|
1416 6) |
19259
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1417 assert_equal(4.0, 6 * 4 / 6.0) |
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1418 assert_equal(4.0, 6.0 * 4.0 / 6) |
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1419 assert_equal(4.0, 6 * 4.0 / 6.0) |
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1420 assert_equal(4.0, 6.0 * 4 / 6.0) |
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1421 assert_equal(4.0, 6.0 * 4.0 / 6.0) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1422 |
19259
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1423 assert_equal(4.0, 6.0 * 4.0 / 6.0) |
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1424 endif |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1425 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1426 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1427 func Test_expr6_fails() |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1428 let msg = "White space required before and after '*'" |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1429 call CheckDefFailure(["var x = 1*2"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1430 call CheckDefFailure(["var x = 1 *2"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1431 call CheckDefFailure(["var x = 1* 2"], msg, 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1432 |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1433 let msg = "White space required before and after '/'" |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1434 call CheckDefFailure(["var x = 1/2"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1435 call CheckDefFailure(["var x = 1 /2"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1436 call CheckDefFailure(["var x = 1/ 2"], msg, 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1437 |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1438 let msg = "White space required before and after '%'" |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1439 call CheckDefFailure(["var x = 1%2"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1440 call CheckDefFailure(["var x = 1 %2"], msg, 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1441 call CheckDefFailure(["var x = 1% 2"], msg, 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1442 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1443 call CheckDefFailure(["var x = '1' * '2'"], 'E1036:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1444 call CheckDefFailure(["var x = '1' / '2'"], 'E1036:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1445 call CheckDefFailure(["var x = '1' % '2'"], 'E1035:', 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1446 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1447 call CheckDefFailure(["var x = 0z01 * 0z12"], 'E1036:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1448 call CheckDefFailure(["var x = 0z01 / 0z12"], 'E1036:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1449 call CheckDefFailure(["var x = 0z01 % 0z12"], 'E1035:', 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1450 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1451 call CheckDefFailure(["var x = [1] * [2]"], 'E1036:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1452 call CheckDefFailure(["var x = [1] / [2]"], 'E1036:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1453 call CheckDefFailure(["var x = [1] % [2]"], 'E1035:', 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1454 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1455 call CheckDefFailure(["var x = #{one: 1} * #{two: 2}"], 'E1036:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1456 call CheckDefFailure(["var x = #{one: 1} / #{two: 2}"], 'E1036:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1457 call CheckDefFailure(["var x = #{one: 1} % #{two: 2}"], 'E1035:', 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1458 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1459 call CheckDefFailure(["var x = 0xff[1]"], 'E1107:', 1) |
19423
f3e8e74cb747
patch 8.2.0269: Vim9: operator after list index does not work
Bram Moolenaar <Bram@vim.org>
parents:
19259
diff
changeset
|
1460 if has('float') |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1461 call CheckDefFailure(["var x = 0.7[1]"], 'E1107:', 1) |
19423
f3e8e74cb747
patch 8.2.0269: Vim9: operator after list index does not work
Bram Moolenaar <Bram@vim.org>
parents:
19259
diff
changeset
|
1462 endif |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1463 endfunc |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1464 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1465 func Test_expr6_float_fails() |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1466 CheckFeature float |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1467 call CheckDefFailure(["var x = 1.0 % 2"], 'E1035:', 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1468 endfunc |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1469 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1470 " define here to use old style parsing |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1471 if has('float') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1472 let g:float_zero = 0.0 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1473 let g:float_neg = -9.8 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1474 let g:float_big = 9.9e99 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1475 endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1476 let g:blob_empty = 0z |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1477 let g:blob_one = 0z01 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1478 let g:blob_long = 0z0102.0304 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1479 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1480 let g:string_empty = '' |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1481 let g:string_short = 'x' |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1482 let g:string_long = 'abcdefghijklm' |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1483 let g:string_special = "ab\ncd\ref\ekk" |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1484 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1485 let g:special_true = v:true |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1486 let g:special_false = v:false |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1487 let g:special_null = v:null |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1488 let g:special_none = v:none |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1489 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1490 let g:list_empty = [] |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1491 let g:list_mixed = [1, 'b', v:false] |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1492 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1493 let g:dict_empty = {} |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1494 let g:dict_one = #{one: 1} |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1495 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1496 let $TESTVAR = 'testvar' |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1497 |
21717
ef3b31d510d2
patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents:
21715
diff
changeset
|
1498 " type casts |
ef3b31d510d2
patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents:
21715
diff
changeset
|
1499 def Test_expr7t() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1500 var ls: list<string> = ['a', <string>g:string_empty] |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1501 var ln: list<number> = [<number>g:anint, <number>g:thefour] |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1502 var nr = <number>234 |
21811
3261e28c638a
patch 8.2.1455: Vim9: crash when using typecast before constant
Bram Moolenaar <Bram@vim.org>
parents:
21809
diff
changeset
|
1503 assert_equal(234, nr) |
3261e28c638a
patch 8.2.1455: Vim9: crash when using typecast before constant
Bram Moolenaar <Bram@vim.org>
parents:
21809
diff
changeset
|
1504 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1505 CheckDefFailure(["var x = <nr>123"], 'E1010:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1506 CheckDefFailure(["var x = <number >123"], 'E1068:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1507 CheckDefFailure(["var x = <number 123"], 'E1104:', 1) |
21717
ef3b31d510d2
patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents:
21715
diff
changeset
|
1508 enddef |
ef3b31d510d2
patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents:
21715
diff
changeset
|
1509 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1510 " test low level expression |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1511 def Test_expr7_number() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
1512 # number constant |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1513 assert_equal(0, 0) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1514 assert_equal(654, 0654) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1515 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1516 assert_equal(6, 0x6) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1517 assert_equal(15, 0xf) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1518 assert_equal(255, 0xff) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1519 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1520 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1521 def Test_expr7_float() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
1522 # float constant |
19259
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1523 if !has('float') |
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1524 MissingFeature 'float' |
77cce0439714
patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1525 else |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1526 assert_equal(g:float_zero, .0) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1527 assert_equal(g:float_zero, 0.0) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1528 assert_equal(g:float_neg, -9.8) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1529 assert_equal(g:float_big, 9.9e99) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1530 endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1531 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1532 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1533 def Test_expr7_blob() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
1534 # blob constant |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1535 assert_equal(g:blob_empty, 0z) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1536 assert_equal(g:blob_one, 0z01) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1537 assert_equal(g:blob_long, 0z0102.0304) |
19856
90eec641cc8c
patch 8.2.0484: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19854
diff
changeset
|
1538 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1539 CheckDefFailure(["var x = 0z123"], 'E973:', 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1540 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1541 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1542 def Test_expr7_string() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
1543 # string constant |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1544 assert_equal(g:string_empty, '') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1545 assert_equal(g:string_empty, "") |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1546 assert_equal(g:string_short, 'x') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1547 assert_equal(g:string_short, "x") |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1548 assert_equal(g:string_long, 'abcdefghijklm') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1549 assert_equal(g:string_long, "abcdefghijklm") |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1550 assert_equal(g:string_special, "ab\ncd\ref\ekk") |
19856
90eec641cc8c
patch 8.2.0484: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19854
diff
changeset
|
1551 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1552 CheckDefFailure(['var x = "abc'], 'E114:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1553 CheckDefFailure(["var x = 'abc"], 'E115:', 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1554 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1555 |
19960
3c11b9f6fa03
patch 8.2.0536: Vim9: some compilation code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19912
diff
changeset
|
1556 def Test_expr7_vimvar() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1557 var old: list<string> = v:oldfiles |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1558 var compl: dict<any> = v:completed_item |
19960
3c11b9f6fa03
patch 8.2.0536: Vim9: some compilation code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19912
diff
changeset
|
1559 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1560 CheckDefFailure(["var old: list<number> = v:oldfiles"], 'E1012: Type mismatch; expected list<number> but got list<string>', 1) |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1561 new |
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1562 exec "normal! afoo fo\<C-N>\<Esc>" |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1563 CheckDefExecFailure(["var old: dict<number> = v:completed_item"], 'E1012: Type mismatch; expected dict<number> but got dict<string>', 1) |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
1564 bwipe! |
19960
3c11b9f6fa03
patch 8.2.0536: Vim9: some compilation code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19912
diff
changeset
|
1565 enddef |
3c11b9f6fa03
patch 8.2.0536: Vim9: some compilation code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19912
diff
changeset
|
1566 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1567 def Test_expr7_special() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
1568 # special constant |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1569 assert_equal(g:special_true, true) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1570 assert_equal(g:special_false, false) |
19960
3c11b9f6fa03
patch 8.2.0536: Vim9: some compilation code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19912
diff
changeset
|
1571 assert_equal(g:special_true, v:true) |
3c11b9f6fa03
patch 8.2.0536: Vim9: some compilation code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19912
diff
changeset
|
1572 assert_equal(g:special_false, v:false) |
21725
741c1d58d50f
patch 8.2.1412: Vim: not operator does not result in boolean
Bram Moolenaar <Bram@vim.org>
parents:
21717
diff
changeset
|
1573 |
741c1d58d50f
patch 8.2.1412: Vim: not operator does not result in boolean
Bram Moolenaar <Bram@vim.org>
parents:
21717
diff
changeset
|
1574 assert_equal(true, !false) |
741c1d58d50f
patch 8.2.1412: Vim: not operator does not result in boolean
Bram Moolenaar <Bram@vim.org>
parents:
21717
diff
changeset
|
1575 assert_equal(false, !true) |
741c1d58d50f
patch 8.2.1412: Vim: not operator does not result in boolean
Bram Moolenaar <Bram@vim.org>
parents:
21717
diff
changeset
|
1576 assert_equal(true, !0) |
741c1d58d50f
patch 8.2.1412: Vim: not operator does not result in boolean
Bram Moolenaar <Bram@vim.org>
parents:
21717
diff
changeset
|
1577 assert_equal(false, !1) |
741c1d58d50f
patch 8.2.1412: Vim: not operator does not result in boolean
Bram Moolenaar <Bram@vim.org>
parents:
21717
diff
changeset
|
1578 assert_equal(false, !!false) |
741c1d58d50f
patch 8.2.1412: Vim: not operator does not result in boolean
Bram Moolenaar <Bram@vim.org>
parents:
21717
diff
changeset
|
1579 assert_equal(true, !!true) |
741c1d58d50f
patch 8.2.1412: Vim: not operator does not result in boolean
Bram Moolenaar <Bram@vim.org>
parents:
21717
diff
changeset
|
1580 assert_equal(false, !!0) |
741c1d58d50f
patch 8.2.1412: Vim: not operator does not result in boolean
Bram Moolenaar <Bram@vim.org>
parents:
21717
diff
changeset
|
1581 assert_equal(true, !!1) |
741c1d58d50f
patch 8.2.1412: Vim: not operator does not result in boolean
Bram Moolenaar <Bram@vim.org>
parents:
21717
diff
changeset
|
1582 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1583 assert_equal(g:special_null, v:null) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1584 assert_equal(g:special_none, v:none) |
19960
3c11b9f6fa03
patch 8.2.0536: Vim9: some compilation code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19912
diff
changeset
|
1585 |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22119
diff
changeset
|
1586 CheckDefFailure(['v:true = true'], 'E46:', 1) |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22119
diff
changeset
|
1587 CheckDefFailure(['v:true = false'], 'E46:', 1) |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22119
diff
changeset
|
1588 CheckDefFailure(['v:false = true'], 'E46:', 1) |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22119
diff
changeset
|
1589 CheckDefFailure(['v:null = 11'], 'E46:', 1) |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22119
diff
changeset
|
1590 CheckDefFailure(['v:none = 22'], 'E46:', 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1591 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1592 |
21307
b991565745fb
patch 8.2.1204: Vim9: true and false not recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21277
diff
changeset
|
1593 def Test_expr7_special_vim9script() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1594 var lines =<< trim END |
21307
b991565745fb
patch 8.2.1204: Vim9: true and false not recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21277
diff
changeset
|
1595 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1596 var t = true |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1597 var f = false |
21307
b991565745fb
patch 8.2.1204: Vim9: true and false not recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21277
diff
changeset
|
1598 assert_equal(v:true, true) |
b991565745fb
patch 8.2.1204: Vim9: true and false not recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21277
diff
changeset
|
1599 assert_equal(true, t) |
b991565745fb
patch 8.2.1204: Vim9: true and false not recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21277
diff
changeset
|
1600 assert_equal(v:false, false) |
b991565745fb
patch 8.2.1204: Vim9: true and false not recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21277
diff
changeset
|
1601 assert_equal(false, f) |
21725
741c1d58d50f
patch 8.2.1412: Vim: not operator does not result in boolean
Bram Moolenaar <Bram@vim.org>
parents:
21717
diff
changeset
|
1602 assert_equal(true, !false) |
741c1d58d50f
patch 8.2.1412: Vim: not operator does not result in boolean
Bram Moolenaar <Bram@vim.org>
parents:
21717
diff
changeset
|
1603 assert_equal(false, !true) |
741c1d58d50f
patch 8.2.1412: Vim: not operator does not result in boolean
Bram Moolenaar <Bram@vim.org>
parents:
21717
diff
changeset
|
1604 assert_equal(true, !0) |
741c1d58d50f
patch 8.2.1412: Vim: not operator does not result in boolean
Bram Moolenaar <Bram@vim.org>
parents:
21717
diff
changeset
|
1605 assert_equal(false, !1) |
741c1d58d50f
patch 8.2.1412: Vim: not operator does not result in boolean
Bram Moolenaar <Bram@vim.org>
parents:
21717
diff
changeset
|
1606 assert_equal(false, !!false) |
741c1d58d50f
patch 8.2.1412: Vim: not operator does not result in boolean
Bram Moolenaar <Bram@vim.org>
parents:
21717
diff
changeset
|
1607 assert_equal(true, !!true) |
741c1d58d50f
patch 8.2.1412: Vim: not operator does not result in boolean
Bram Moolenaar <Bram@vim.org>
parents:
21717
diff
changeset
|
1608 assert_equal(false, !!0) |
741c1d58d50f
patch 8.2.1412: Vim: not operator does not result in boolean
Bram Moolenaar <Bram@vim.org>
parents:
21717
diff
changeset
|
1609 assert_equal(true, !!1) |
21307
b991565745fb
patch 8.2.1204: Vim9: true and false not recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21277
diff
changeset
|
1610 END |
b991565745fb
patch 8.2.1204: Vim9: true and false not recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21277
diff
changeset
|
1611 CheckScriptSuccess(lines) |
b991565745fb
patch 8.2.1204: Vim9: true and false not recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21277
diff
changeset
|
1612 enddef |
b991565745fb
patch 8.2.1204: Vim9: true and false not recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21277
diff
changeset
|
1613 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1614 def Test_expr7_list() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
1615 # list |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1616 assert_equal(g:list_empty, []) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1617 assert_equal(g:list_empty, [ ]) |
21715
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1618 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1619 var numbers: list<number> = [1, 2, 3] |
21715
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1620 numbers = [1] |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1621 numbers = [] |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1622 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1623 var strings: list<string> = ['a', 'b', 'c'] |
21715
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1624 strings = ['x'] |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1625 strings = [] |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1626 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1627 var mixed: list<any> = [1, 'b', false,] |
21715
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1628 assert_equal(g:list_mixed, mixed) |
21831
d8422de73113
patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
21828
diff
changeset
|
1629 assert_equal('b', mixed[1]) |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
1630 |
21562
55aa283a0e5e
patch 8.2.1331: Vim9: :echo with two lists doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21546
diff
changeset
|
1631 echo [1, |
55aa283a0e5e
patch 8.2.1331: Vim9: :echo with two lists doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21546
diff
changeset
|
1632 2] [3, |
55aa283a0e5e
patch 8.2.1331: Vim9: :echo with two lists doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21546
diff
changeset
|
1633 4] |
55aa283a0e5e
patch 8.2.1331: Vim9: :echo with two lists doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21546
diff
changeset
|
1634 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1635 var llstring: list<list<string>> = [['text'], []] |
22322
a5b16c9eee9d
patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
1636 llstring = [[], ['text']] |
a5b16c9eee9d
patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
1637 llstring = [[], []] |
a5b16c9eee9d
patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
1638 |
22419
6a9e5c087c86
patch 8.2.1758: Vim9: type of unmaterialized list is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
1639 var rangelist: list<number> = range(3) |
6a9e5c087c86
patch 8.2.1758: Vim9: type of unmaterialized list is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
1640 g:rangelist = range(3) |
6a9e5c087c86
patch 8.2.1758: Vim9: type of unmaterialized list is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
1641 CheckDefExecFailure(["var x: list<string> = g:rangelist"], 'E1012: Type mismatch; expected list<string> but got list<number>', 1) |
6a9e5c087c86
patch 8.2.1758: Vim9: type of unmaterialized list is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
1642 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1643 CheckDefFailure(["var x = 1234[3]"], 'E1107:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1644 CheckDefExecFailure(["var x = g:anint[3]"], 'E1062:', 1) |
21831
d8422de73113
patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
21828
diff
changeset
|
1645 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1646 CheckDefFailure(["var x = g:list_mixed[xxx]"], 'E1001:', 1) |
21761
5a2373c25a86
patch 8.2.1430: Vim9: error for missing comma instead of extra white space
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
1647 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1648 CheckDefFailure(["var x = [1,2,3]"], 'E1069:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1649 CheckDefFailure(["var x = [1 ,2, 3]"], 'E1068:', 1) |
21761
5a2373c25a86
patch 8.2.1430: Vim9: error for missing comma instead of extra white space
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
1650 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1651 CheckDefExecFailure(["echo 1", "var x = [][0]", "echo 3"], 'E684:', 2) |
21859
3e5d0832a2e7
patch 8.2.1479: Vim9: error for list index uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
21837
diff
changeset
|
1652 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1653 CheckDefExecFailure(["var x = g:list_mixed['xx']"], 'E1012:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1654 CheckDefFailure(["var x = g:list_mixed["], 'E1097:', 2) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1655 CheckDefFailure(["var x = g:list_mixed[0"], 'E1097:', 2) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1656 CheckDefExecFailure(["var x = g:list_empty[3]"], 'E684:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1657 CheckDefExecFailure(["var l: list<number> = [234, 'x']"], 'E1012:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1658 CheckDefExecFailure(["var l: list<number> = ['x', 234]"], 'E1012:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1659 CheckDefExecFailure(["var l: list<string> = [234, 'x']"], 'E1012:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1660 CheckDefExecFailure(["var l: list<string> = ['x', 123]"], 'E1012:', 1) |
22482
a1b3804163ca
patch 8.2.1789: Vim9: crash with invalid list constant
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1661 |
a1b3804163ca
patch 8.2.1789: Vim9: crash with invalid list constant
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1662 var lines =<< trim END |
a1b3804163ca
patch 8.2.1789: Vim9: crash with invalid list constant
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1663 vim9script |
a1b3804163ca
patch 8.2.1789: Vim9: crash with invalid list constant
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1664 var datalist: list<string> |
a1b3804163ca
patch 8.2.1789: Vim9: crash with invalid list constant
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1665 def Main() |
a1b3804163ca
patch 8.2.1789: Vim9: crash with invalid list constant
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1666 datalist += ['x'. |
a1b3804163ca
patch 8.2.1789: Vim9: crash with invalid list constant
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1667 enddef |
a1b3804163ca
patch 8.2.1789: Vim9: crash with invalid list constant
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1668 Main() |
a1b3804163ca
patch 8.2.1789: Vim9: crash with invalid list constant
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1669 END |
a1b3804163ca
patch 8.2.1789: Vim9: crash with invalid list constant
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1670 CheckScriptFailure(lines, 'E1127:') |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1671 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1672 |
21028
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
1673 def Test_expr7_list_vim9script() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1674 var lines =<< trim END |
21028
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
1675 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1676 var l = [ |
21028
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
1677 11, |
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
1678 22, |
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
1679 ] |
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
1680 assert_equal([11, 22], l) |
21562
55aa283a0e5e
patch 8.2.1331: Vim9: :echo with two lists doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21546
diff
changeset
|
1681 |
55aa283a0e5e
patch 8.2.1331: Vim9: :echo with two lists doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21546
diff
changeset
|
1682 echo [1, |
55aa283a0e5e
patch 8.2.1331: Vim9: :echo with two lists doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21546
diff
changeset
|
1683 2] [3, |
55aa283a0e5e
patch 8.2.1331: Vim9: :echo with two lists doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21546
diff
changeset
|
1684 4] |
22580
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1685 |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1686 echo [1, # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1687 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1688 2] [3, |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1689 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1690 4] |
21028
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
1691 END |
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
1692 CheckScriptSuccess(lines) |
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
1693 |
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
1694 lines =<< trim END |
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
1695 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1696 var l = [11, |
21028
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
1697 22] |
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
1698 assert_equal([11, 22], l) |
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
1699 END |
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
1700 CheckScriptSuccess(lines) |
21034
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1701 |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1702 lines =<< trim END |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1703 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1704 var l = [11,22] |
21034
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1705 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1706 CheckScriptFailure(lines, 'E1069:', 2) |
21761
5a2373c25a86
patch 8.2.1430: Vim9: error for missing comma instead of extra white space
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
1707 |
5a2373c25a86
patch 8.2.1430: Vim9: error for missing comma instead of extra white space
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
1708 lines =<< trim END |
5a2373c25a86
patch 8.2.1430: Vim9: error for missing comma instead of extra white space
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
1709 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1710 var l = [11 , 22] |
21761
5a2373c25a86
patch 8.2.1430: Vim9: error for missing comma instead of extra white space
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
1711 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1712 CheckScriptFailure(lines, 'E1068:', 2) |
21803
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1713 |
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1714 lines =<< trim END |
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1715 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1716 var l: list<number> = [234, 'x'] |
21803
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1717 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1718 CheckScriptFailure(lines, 'E1012:', 2) |
21803
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1719 lines =<< trim END |
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1720 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1721 var l: list<number> = ['x', 234] |
21803
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1722 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1723 CheckScriptFailure(lines, 'E1012:', 2) |
21803
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1724 lines =<< trim END |
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1725 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1726 var l: list<string> = ['x', 234] |
21803
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1727 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1728 CheckScriptFailure(lines, 'E1012:', 2) |
21803
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1729 lines =<< trim END |
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1730 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1731 var l: list<string> = [234, 'x'] |
21803
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1732 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1733 CheckScriptFailure(lines, 'E1012:', 2) |
21028
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
1734 enddef |
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
1735 |
21767
9529a2367d3e
patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
1736 def LambdaWithComments(): func |
9529a2367d3e
patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
1737 return {x -> |
9529a2367d3e
patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
1738 # some comment |
9529a2367d3e
patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
1739 x == 1 |
9529a2367d3e
patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
1740 # some comment |
9529a2367d3e
patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
1741 || |
9529a2367d3e
patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
1742 x == 2 |
9529a2367d3e
patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
1743 } |
9529a2367d3e
patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
1744 enddef |
9529a2367d3e
patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
1745 |
21769
f37c1330b15c
patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents:
21767
diff
changeset
|
1746 def LambdaUsingArg(x: number): func |
f37c1330b15c
patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents:
21767
diff
changeset
|
1747 return {-> |
f37c1330b15c
patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents:
21767
diff
changeset
|
1748 # some comment |
f37c1330b15c
patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents:
21767
diff
changeset
|
1749 x == 1 |
f37c1330b15c
patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents:
21767
diff
changeset
|
1750 # some comment |
f37c1330b15c
patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents:
21767
diff
changeset
|
1751 || |
f37c1330b15c
patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents:
21767
diff
changeset
|
1752 x == 2 |
f37c1330b15c
patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents:
21767
diff
changeset
|
1753 } |
f37c1330b15c
patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents:
21767
diff
changeset
|
1754 enddef |
f37c1330b15c
patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents:
21767
diff
changeset
|
1755 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1756 def Test_expr7_lambda() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1757 var La = { -> 'result'} |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1758 assert_equal('result', La()) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1759 assert_equal([1, 3, 5], [1, 2, 3]->map({key, val -> key + val})) |
21263
71bd2f9adb61
patch 8.2.1182: Vim9: no check for whitespace after comma in lambda
Bram Moolenaar <Bram@vim.org>
parents:
21251
diff
changeset
|
1760 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
1761 # line continuation inside lambda with "cond ? expr : expr" works |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1762 var ll = range(3) |
21277
1e5c29d4e5b3
patch 8.2.1189: Vim9: line continuation in lambda doesn't always work
Bram Moolenaar <Bram@vim.org>
parents:
21263
diff
changeset
|
1763 map(ll, {k, v -> v % 2 ? { |
1e5c29d4e5b3
patch 8.2.1189: Vim9: line continuation in lambda doesn't always work
Bram Moolenaar <Bram@vim.org>
parents:
21263
diff
changeset
|
1764 '111': 111 } : {} |
1e5c29d4e5b3
patch 8.2.1189: Vim9: line continuation in lambda doesn't always work
Bram Moolenaar <Bram@vim.org>
parents:
21263
diff
changeset
|
1765 }) |
1e5c29d4e5b3
patch 8.2.1189: Vim9: line continuation in lambda doesn't always work
Bram Moolenaar <Bram@vim.org>
parents:
21263
diff
changeset
|
1766 assert_equal([{}, {'111': 111}, {}], ll) |
1e5c29d4e5b3
patch 8.2.1189: Vim9: line continuation in lambda doesn't always work
Bram Moolenaar <Bram@vim.org>
parents:
21263
diff
changeset
|
1767 |
1e5c29d4e5b3
patch 8.2.1189: Vim9: line continuation in lambda doesn't always work
Bram Moolenaar <Bram@vim.org>
parents:
21263
diff
changeset
|
1768 ll = range(3) |
1e5c29d4e5b3
patch 8.2.1189: Vim9: line continuation in lambda doesn't always work
Bram Moolenaar <Bram@vim.org>
parents:
21263
diff
changeset
|
1769 map(ll, {k, v -> v == 8 || v |
1e5c29d4e5b3
patch 8.2.1189: Vim9: line continuation in lambda doesn't always work
Bram Moolenaar <Bram@vim.org>
parents:
21263
diff
changeset
|
1770 == 9 |
1e5c29d4e5b3
patch 8.2.1189: Vim9: line continuation in lambda doesn't always work
Bram Moolenaar <Bram@vim.org>
parents:
21263
diff
changeset
|
1771 || v % 2 ? 111 : 222 |
1e5c29d4e5b3
patch 8.2.1189: Vim9: line continuation in lambda doesn't always work
Bram Moolenaar <Bram@vim.org>
parents:
21263
diff
changeset
|
1772 }) |
1e5c29d4e5b3
patch 8.2.1189: Vim9: line continuation in lambda doesn't always work
Bram Moolenaar <Bram@vim.org>
parents:
21263
diff
changeset
|
1773 assert_equal([222, 111, 222], ll) |
1e5c29d4e5b3
patch 8.2.1189: Vim9: line continuation in lambda doesn't always work
Bram Moolenaar <Bram@vim.org>
parents:
21263
diff
changeset
|
1774 |
1e5c29d4e5b3
patch 8.2.1189: Vim9: line continuation in lambda doesn't always work
Bram Moolenaar <Bram@vim.org>
parents:
21263
diff
changeset
|
1775 ll = range(3) |
1e5c29d4e5b3
patch 8.2.1189: Vim9: line continuation in lambda doesn't always work
Bram Moolenaar <Bram@vim.org>
parents:
21263
diff
changeset
|
1776 map(ll, {k, v -> v != 8 && v |
1e5c29d4e5b3
patch 8.2.1189: Vim9: line continuation in lambda doesn't always work
Bram Moolenaar <Bram@vim.org>
parents:
21263
diff
changeset
|
1777 != 9 |
1e5c29d4e5b3
patch 8.2.1189: Vim9: line continuation in lambda doesn't always work
Bram Moolenaar <Bram@vim.org>
parents:
21263
diff
changeset
|
1778 && v % 2 == 0 ? 111 : 222 |
1e5c29d4e5b3
patch 8.2.1189: Vim9: line continuation in lambda doesn't always work
Bram Moolenaar <Bram@vim.org>
parents:
21263
diff
changeset
|
1779 }) |
1e5c29d4e5b3
patch 8.2.1189: Vim9: line continuation in lambda doesn't always work
Bram Moolenaar <Bram@vim.org>
parents:
21263
diff
changeset
|
1780 assert_equal([111, 222, 111], ll) |
1e5c29d4e5b3
patch 8.2.1189: Vim9: line continuation in lambda doesn't always work
Bram Moolenaar <Bram@vim.org>
parents:
21263
diff
changeset
|
1781 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1782 var dl = [{'key': 0}, {'key': 22}]->filter({ _, v -> v['key'] }) |
21387
8d58cbb07a12
patch 8.2.1244: Vim9: in lambda index assumes a list
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
1783 assert_equal([{'key': 22}], dl) |
8d58cbb07a12
patch 8.2.1244: Vim9: in lambda index assumes a list
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
1784 |
21411
e1aeb986712f
patch 8.2.1256: Vim9: type wrong after getting dict item in lambda
Bram Moolenaar <Bram@vim.org>
parents:
21399
diff
changeset
|
1785 dl = [{'key': 12}, {'foo': 34}] |
e1aeb986712f
patch 8.2.1256: Vim9: type wrong after getting dict item in lambda
Bram Moolenaar <Bram@vim.org>
parents:
21399
diff
changeset
|
1786 assert_equal([{'key': 12}], filter(dl, |
e1aeb986712f
patch 8.2.1256: Vim9: type wrong after getting dict item in lambda
Bram Moolenaar <Bram@vim.org>
parents:
21399
diff
changeset
|
1787 {_, v -> has_key(v, 'key') ? v['key'] == 12 : 0})) |
e1aeb986712f
patch 8.2.1256: Vim9: type wrong after getting dict item in lambda
Bram Moolenaar <Bram@vim.org>
parents:
21399
diff
changeset
|
1788 |
21767
9529a2367d3e
patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
1789 assert_equal(false, LambdaWithComments()(0)) |
9529a2367d3e
patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
1790 assert_equal(true, LambdaWithComments()(1)) |
9529a2367d3e
patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
1791 assert_equal(true, LambdaWithComments()(2)) |
9529a2367d3e
patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
1792 assert_equal(false, LambdaWithComments()(3)) |
9529a2367d3e
patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
1793 |
21769
f37c1330b15c
patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents:
21767
diff
changeset
|
1794 assert_equal(false, LambdaUsingArg(0)()) |
f37c1330b15c
patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents:
21767
diff
changeset
|
1795 assert_equal(true, LambdaUsingArg(1)()) |
f37c1330b15c
patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents:
21767
diff
changeset
|
1796 |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22119
diff
changeset
|
1797 CheckDefFailure(["filter([1, 2], {k,v -> 1})"], 'E1069:', 1) |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1798 # error is in first line of the lambda |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1799 CheckDefFailure(["var L = {a -> a + b}"], 'E1001:', 0) |
21809
15ed135796fd
patch 8.2.1454: Vim9: failure invoking lambda with wrong arguments
Bram Moolenaar <Bram@vim.org>
parents:
21807
diff
changeset
|
1800 |
15ed135796fd
patch 8.2.1454: Vim9: failure invoking lambda with wrong arguments
Bram Moolenaar <Bram@vim.org>
parents:
21807
diff
changeset
|
1801 assert_equal('xxxyyy', 'xxx'->{a, b -> a .. b}('yyy')) |
15ed135796fd
patch 8.2.1454: Vim9: failure invoking lambda with wrong arguments
Bram Moolenaar <Bram@vim.org>
parents:
21807
diff
changeset
|
1802 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1803 CheckDefExecFailure(["var s = 'asdf'->{a -> a}('x')"], |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1804 'E1106: One argument too many') |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1805 CheckDefExecFailure(["var s = 'asdf'->{a -> a}('x', 'y')"], |
21809
15ed135796fd
patch 8.2.1454: Vim9: failure invoking lambda with wrong arguments
Bram Moolenaar <Bram@vim.org>
parents:
21807
diff
changeset
|
1806 'E1106: 2 arguments too many') |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1807 CheckDefFailure(["echo 'asdf'->{a -> a}(x)"], 'E1001:', 1) |
22625
0afa30d6dc72
patch 8.2.1861: Vim9: no specific error when parsing lambda fails
Bram Moolenaar <Bram@vim.org>
parents:
22606
diff
changeset
|
1808 |
0afa30d6dc72
patch 8.2.1861: Vim9: no specific error when parsing lambda fails
Bram Moolenaar <Bram@vim.org>
parents:
22606
diff
changeset
|
1809 CheckDefSuccess(['var Fx = {a -> #{k1: 0,', ' k2: 1}}']) |
0afa30d6dc72
patch 8.2.1861: Vim9: no specific error when parsing lambda fails
Bram Moolenaar <Bram@vim.org>
parents:
22606
diff
changeset
|
1810 CheckDefFailure(['var Fx = {a -> #{k1: 0', ' k2: 1}}'], 'E722:', 2) |
0afa30d6dc72
patch 8.2.1861: Vim9: no specific error when parsing lambda fails
Bram Moolenaar <Bram@vim.org>
parents:
22606
diff
changeset
|
1811 CheckDefFailure(['var Fx = {a -> #{k1: 0,', ' k2 1}}'], 'E720:', 2) |
0afa30d6dc72
patch 8.2.1861: Vim9: no specific error when parsing lambda fails
Bram Moolenaar <Bram@vim.org>
parents:
22606
diff
changeset
|
1812 |
0afa30d6dc72
patch 8.2.1861: Vim9: no specific error when parsing lambda fails
Bram Moolenaar <Bram@vim.org>
parents:
22606
diff
changeset
|
1813 CheckDefSuccess(['var Fx = {a -> [0,', ' 1]}']) |
0afa30d6dc72
patch 8.2.1861: Vim9: no specific error when parsing lambda fails
Bram Moolenaar <Bram@vim.org>
parents:
22606
diff
changeset
|
1814 CheckDefFailure(['var Fx = {a -> [0', ' 1]}'], 'E696:', 2) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1815 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1816 |
21040
d9e0db9b2b99
patch 8.2.1071: Vim9: no line break allowed inside a lambda
Bram Moolenaar <Bram@vim.org>
parents:
21034
diff
changeset
|
1817 def Test_expr7_lambda_vim9script() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1818 var lines =<< trim END |
21040
d9e0db9b2b99
patch 8.2.1071: Vim9: no line break allowed inside a lambda
Bram Moolenaar <Bram@vim.org>
parents:
21034
diff
changeset
|
1819 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1820 var v = 10->{a -> |
21040
d9e0db9b2b99
patch 8.2.1071: Vim9: no line break allowed inside a lambda
Bram Moolenaar <Bram@vim.org>
parents:
21034
diff
changeset
|
1821 a |
d9e0db9b2b99
patch 8.2.1071: Vim9: no line break allowed inside a lambda
Bram Moolenaar <Bram@vim.org>
parents:
21034
diff
changeset
|
1822 + 2 |
d9e0db9b2b99
patch 8.2.1071: Vim9: no line break allowed inside a lambda
Bram Moolenaar <Bram@vim.org>
parents:
21034
diff
changeset
|
1823 }() |
d9e0db9b2b99
patch 8.2.1071: Vim9: no line break allowed inside a lambda
Bram Moolenaar <Bram@vim.org>
parents:
21034
diff
changeset
|
1824 assert_equal(12, v) |
d9e0db9b2b99
patch 8.2.1071: Vim9: no line break allowed inside a lambda
Bram Moolenaar <Bram@vim.org>
parents:
21034
diff
changeset
|
1825 END |
d9e0db9b2b99
patch 8.2.1071: Vim9: no line break allowed inside a lambda
Bram Moolenaar <Bram@vim.org>
parents:
21034
diff
changeset
|
1826 CheckScriptSuccess(lines) |
21865
c16af87df654
patch 8.2.1482: Vim9: crash when using a nested lambda
Bram Moolenaar <Bram@vim.org>
parents:
21863
diff
changeset
|
1827 |
c16af87df654
patch 8.2.1482: Vim9: crash when using a nested lambda
Bram Moolenaar <Bram@vim.org>
parents:
21863
diff
changeset
|
1828 # nested lambda with line breaks |
c16af87df654
patch 8.2.1482: Vim9: crash when using a nested lambda
Bram Moolenaar <Bram@vim.org>
parents:
21863
diff
changeset
|
1829 lines =<< trim END |
c16af87df654
patch 8.2.1482: Vim9: crash when using a nested lambda
Bram Moolenaar <Bram@vim.org>
parents:
21863
diff
changeset
|
1830 vim9script |
c16af87df654
patch 8.2.1482: Vim9: crash when using a nested lambda
Bram Moolenaar <Bram@vim.org>
parents:
21863
diff
changeset
|
1831 search('"', 'cW', 0, 0, {-> |
c16af87df654
patch 8.2.1482: Vim9: crash when using a nested lambda
Bram Moolenaar <Bram@vim.org>
parents:
21863
diff
changeset
|
1832 synstack('.', col('.')) |
c16af87df654
patch 8.2.1482: Vim9: crash when using a nested lambda
Bram Moolenaar <Bram@vim.org>
parents:
21863
diff
changeset
|
1833 ->map({_, v -> synIDattr(v, 'name')})->len()}) |
c16af87df654
patch 8.2.1482: Vim9: crash when using a nested lambda
Bram Moolenaar <Bram@vim.org>
parents:
21863
diff
changeset
|
1834 END |
c16af87df654
patch 8.2.1482: Vim9: crash when using a nested lambda
Bram Moolenaar <Bram@vim.org>
parents:
21863
diff
changeset
|
1835 CheckScriptSuccess(lines) |
21040
d9e0db9b2b99
patch 8.2.1071: Vim9: no line break allowed inside a lambda
Bram Moolenaar <Bram@vim.org>
parents:
21034
diff
changeset
|
1836 enddef |
d9e0db9b2b99
patch 8.2.1071: Vim9: no line break allowed inside a lambda
Bram Moolenaar <Bram@vim.org>
parents:
21034
diff
changeset
|
1837 |
21955
3991a6df522e
patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents:
21925
diff
changeset
|
1838 def Test_epxr7_funcref() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1839 var lines =<< trim END |
21955
3991a6df522e
patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents:
21925
diff
changeset
|
1840 def RetNumber(): number |
3991a6df522e
patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents:
21925
diff
changeset
|
1841 return 123 |
3991a6df522e
patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents:
21925
diff
changeset
|
1842 enddef |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1843 var FuncRef = RetNumber |
21955
3991a6df522e
patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents:
21925
diff
changeset
|
1844 assert_equal(123, FuncRef()) |
3991a6df522e
patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents:
21925
diff
changeset
|
1845 END |
3991a6df522e
patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents:
21925
diff
changeset
|
1846 CheckDefAndScriptSuccess(lines) |
3991a6df522e
patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents:
21925
diff
changeset
|
1847 enddef |
3991a6df522e
patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents:
21925
diff
changeset
|
1848 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1849 def Test_expr7_dict() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
1850 # dictionary |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1851 assert_equal(g:dict_empty, {}) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1852 assert_equal(g:dict_empty, { }) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1853 assert_equal(g:dict_one, {'one': 1}) |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1854 var key = 'one' |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1855 var val = 1 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1856 assert_equal(g:dict_one, {key: val}) |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
1857 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1858 var numbers: dict<number> = #{a: 1, b: 2, c: 3} |
21715
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1859 numbers = #{a: 1} |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1860 numbers = #{} |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1861 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1862 var strings: dict<string> = #{a: 'a', b: 'b', c: 'c'} |
21715
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1863 strings = #{a: 'x'} |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1864 strings = #{} |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1865 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1866 var mixed: dict<any> = #{a: 'a', b: 42} |
21715
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1867 mixed = #{a: 'x'} |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1868 mixed = #{a: 234} |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1869 mixed = #{} |
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1870 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1871 var dictlist: dict<list<string>> = #{absent: [], present: ['hi']} |
22322
a5b16c9eee9d
patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
1872 dictlist = #{absent: ['hi'], present: []} |
a5b16c9eee9d
patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
1873 dictlist = #{absent: [], present: []} |
a5b16c9eee9d
patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
1874 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1875 var dictdict: dict<dict<string>> = #{one: #{a: 'text'}, two: #{}} |
22322
a5b16c9eee9d
patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
1876 dictdict = #{one: #{}, two: #{a: 'text'}} |
a5b16c9eee9d
patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
1877 dictdict = #{one: #{}, two: #{}} |
a5b16c9eee9d
patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents:
22296
diff
changeset
|
1878 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1879 CheckDefFailure(["var x = #{a:8}"], 'E1069:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1880 CheckDefFailure(["var x = #{a : 8}"], 'E1068:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1881 CheckDefFailure(["var x = #{a :8}"], 'E1068:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1882 CheckDefFailure(["var x = #{a: 8 , b: 9}"], 'E1068:', 1) |
21759
25b659fa5ca5
patch 8.2.1429: Vim9: no error for missing white after : in dict
Bram Moolenaar <Bram@vim.org>
parents:
21753
diff
changeset
|
1883 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1884 CheckDefFailure(["var x = #{8: 8}"], 'E1014:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1885 CheckDefFailure(["var x = #{xxx}"], 'E720:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1886 CheckDefFailure(["var x = #{xxx: 1", "var y = 2"], 'E722:', 2) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1887 CheckDefFailure(["var x = #{xxx: 1,"], 'E723:', 2) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1888 CheckDefFailure(["var x = {'a': xxx}"], 'E1001:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1889 CheckDefFailure(["var x = {xxx: 8}"], 'E1001:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1890 CheckDefFailure(["var x = #{a: 1, a: 2}"], 'E721:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1891 CheckDefFailure(["var x = #"], 'E1015:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1892 CheckDefExecFailure(["var x = g:anint.member"], 'E715:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1893 CheckDefExecFailure(["var x = g:dict_empty.member"], 'E716:', 1) |
21715
571832713efa
patch 8.2.1407: Vim9: type of list and dict only depends on first item
Bram Moolenaar <Bram@vim.org>
parents:
21691
diff
changeset
|
1894 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1895 CheckDefExecFailure(['var x: dict<number> = #{a: 234, b: "1"}'], 'E1012:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1896 CheckDefExecFailure(['var x: dict<number> = #{a: "x", b: 134}'], 'E1012:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1897 CheckDefExecFailure(['var x: dict<string> = #{a: 234, b: "1"}'], 'E1012:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1898 CheckDefExecFailure(['var x: dict<string> = #{a: "x", b: 134}'], 'E1012:', 1) |
22508
ac8c4a8b8cba
patch 8.2.1802: Vim9: crash with unterminated dict
Bram Moolenaar <Bram@vim.org>
parents:
22500
diff
changeset
|
1899 |
ac8c4a8b8cba
patch 8.2.1802: Vim9: crash with unterminated dict
Bram Moolenaar <Bram@vim.org>
parents:
22500
diff
changeset
|
1900 CheckDefFailure(['var x = ({'], 'E723:', 2) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1901 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1902 |
21034
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1903 def Test_expr7_dict_vim9script() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1904 var lines =<< trim END |
21034
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1905 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1906 var d = { |
21034
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1907 'one': |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1908 1, |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1909 'two': 2, |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1910 } |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1911 assert_equal({'one': 1, 'two': 2}, d) |
22580
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1912 |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1913 d = { # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1914 'one': |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1915 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1916 |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1917 1, |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1918 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1919 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1920 'two': 2, |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1921 } |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1922 assert_equal({'one': 1, 'two': 2}, d) |
21034
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1923 END |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1924 CheckScriptSuccess(lines) |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1925 |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1926 lines =<< trim END |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1927 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1928 var d = { "one": "one", "two": "two", } |
21118
b0baa80cb53f
patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents:
21046
diff
changeset
|
1929 assert_equal({'one': 'one', 'two': 'two'}, d) |
b0baa80cb53f
patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents:
21046
diff
changeset
|
1930 END |
b0baa80cb53f
patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents:
21046
diff
changeset
|
1931 CheckScriptSuccess(lines) |
b0baa80cb53f
patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents:
21046
diff
changeset
|
1932 |
b0baa80cb53f
patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents:
21046
diff
changeset
|
1933 lines =<< trim END |
b0baa80cb53f
patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents:
21046
diff
changeset
|
1934 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1935 var d = #{one: 1, |
21034
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1936 two: 2, |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1937 } |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1938 assert_equal({'one': 1, 'two': 2}, d) |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1939 END |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1940 CheckScriptSuccess(lines) |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1941 |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1942 lines =<< trim END |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1943 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1944 var d = #{one:1, two: 2} |
21034
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1945 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1946 CheckScriptFailure(lines, 'E1069:', 2) |
21034
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1947 |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1948 lines =<< trim END |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1949 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1950 var d = #{one: 1,two: 2} |
21034
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1951 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1952 CheckScriptFailure(lines, 'E1069:', 2) |
21761
5a2373c25a86
patch 8.2.1430: Vim9: error for missing comma instead of extra white space
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
1953 |
5a2373c25a86
patch 8.2.1430: Vim9: error for missing comma instead of extra white space
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
1954 lines =<< trim END |
5a2373c25a86
patch 8.2.1430: Vim9: error for missing comma instead of extra white space
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
1955 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1956 var d = #{one : 1} |
21761
5a2373c25a86
patch 8.2.1430: Vim9: error for missing comma instead of extra white space
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
1957 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1958 CheckScriptFailure(lines, 'E1068:', 2) |
21761
5a2373c25a86
patch 8.2.1430: Vim9: error for missing comma instead of extra white space
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
1959 |
5a2373c25a86
patch 8.2.1430: Vim9: error for missing comma instead of extra white space
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
1960 lines =<< trim END |
5a2373c25a86
patch 8.2.1430: Vim9: error for missing comma instead of extra white space
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
1961 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1962 var d = #{one:1} |
21761
5a2373c25a86
patch 8.2.1430: Vim9: error for missing comma instead of extra white space
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
1963 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1964 CheckScriptFailure(lines, 'E1069:', 2) |
21763
703ea7603d3e
patch 8.2.1431: Vim9: no error for white space before comma in dict
Bram Moolenaar <Bram@vim.org>
parents:
21761
diff
changeset
|
1965 |
703ea7603d3e
patch 8.2.1431: Vim9: no error for white space before comma in dict
Bram Moolenaar <Bram@vim.org>
parents:
21761
diff
changeset
|
1966 lines =<< trim END |
703ea7603d3e
patch 8.2.1431: Vim9: no error for white space before comma in dict
Bram Moolenaar <Bram@vim.org>
parents:
21761
diff
changeset
|
1967 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1968 var d = #{one: 1 , two: 2} |
21763
703ea7603d3e
patch 8.2.1431: Vim9: no error for white space before comma in dict
Bram Moolenaar <Bram@vim.org>
parents:
21761
diff
changeset
|
1969 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1970 CheckScriptFailure(lines, 'E1068:', 2) |
21803
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1971 |
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1972 lines =<< trim END |
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1973 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1974 var l: dict<number> = #{a: 234, b: 'x'} |
21803
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1975 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1976 CheckScriptFailure(lines, 'E1012:', 2) |
21803
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1977 lines =<< trim END |
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1978 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1979 var l: dict<number> = #{a: 'x', b: 234} |
21803
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1980 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1981 CheckScriptFailure(lines, 'E1012:', 2) |
21803
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1982 lines =<< trim END |
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1983 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1984 var l: dict<string> = #{a: 'x', b: 234} |
21803
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1985 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1986 CheckScriptFailure(lines, 'E1012:', 2) |
21803
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1987 lines =<< trim END |
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1988 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1989 var l: dict<string> = #{a: 234, b: 'x'} |
21803
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
1990 END |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
1991 CheckScriptFailure(lines, 'E1012:', 2) |
21034
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1992 enddef |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
1993 |
21168
f26a606e6dbc
patch 8.2.1135: Vim9: getting a dict member may not work
Bram Moolenaar <Bram@vim.org>
parents:
21166
diff
changeset
|
1994 let g:oneString = 'one' |
f26a606e6dbc
patch 8.2.1135: Vim9: getting a dict member may not work
Bram Moolenaar <Bram@vim.org>
parents:
21166
diff
changeset
|
1995 |
19848
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
1996 def Test_expr_member() |
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
1997 assert_equal(1, g:dict_one.one) |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1998 var d: dict<number> = g:dict_one |
20411
23af9e1a5283
patch 8.2.0760: Vim9: dict member errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
20349
diff
changeset
|
1999 assert_equal(1, d['one']) |
21248
4edc60c9c0aa
patch 8.2.1175: Vim9: cannot split a line before ".member"
Bram Moolenaar <Bram@vim.org>
parents:
21232
diff
changeset
|
2000 assert_equal(1, d[ |
4edc60c9c0aa
patch 8.2.1175: Vim9: cannot split a line before ".member"
Bram Moolenaar <Bram@vim.org>
parents:
21232
diff
changeset
|
2001 'one' |
4edc60c9c0aa
patch 8.2.1175: Vim9: cannot split a line before ".member"
Bram Moolenaar <Bram@vim.org>
parents:
21232
diff
changeset
|
2002 ]) |
4edc60c9c0aa
patch 8.2.1175: Vim9: cannot split a line before ".member"
Bram Moolenaar <Bram@vim.org>
parents:
21232
diff
changeset
|
2003 assert_equal(1, d |
4edc60c9c0aa
patch 8.2.1175: Vim9: cannot split a line before ".member"
Bram Moolenaar <Bram@vim.org>
parents:
21232
diff
changeset
|
2004 .one) |
21512
81c47a694479
patch 8.2.1306: checking for first character of dict key is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
21465
diff
changeset
|
2005 d = {'1': 1, '_': 2} |
81c47a694479
patch 8.2.1306: checking for first character of dict key is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
21465
diff
changeset
|
2006 assert_equal(1, d |
81c47a694479
patch 8.2.1306: checking for first character of dict key is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
21465
diff
changeset
|
2007 .1) |
81c47a694479
patch 8.2.1306: checking for first character of dict key is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
21465
diff
changeset
|
2008 assert_equal(2, d |
81c47a694479
patch 8.2.1306: checking for first character of dict key is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
21465
diff
changeset
|
2009 ._) |
19848
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
2010 |
21152
1561311249bb
patch 8.2.1127: Vim9: getting a dict member may not work
Bram Moolenaar <Bram@vim.org>
parents:
21142
diff
changeset
|
2011 # getting the one member should clear the dict after getting the item |
1561311249bb
patch 8.2.1127: Vim9: getting a dict member may not work
Bram Moolenaar <Bram@vim.org>
parents:
21142
diff
changeset
|
2012 assert_equal('one', #{one: 'one'}.one) |
21168
f26a606e6dbc
patch 8.2.1135: Vim9: getting a dict member may not work
Bram Moolenaar <Bram@vim.org>
parents:
21166
diff
changeset
|
2013 assert_equal('one', #{one: 'one'}[g:oneString]) |
21152
1561311249bb
patch 8.2.1127: Vim9: getting a dict member may not work
Bram Moolenaar <Bram@vim.org>
parents:
21142
diff
changeset
|
2014 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2015 CheckDefFailure(["var x = g:dict_one.#$!"], 'E1002:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2016 CheckDefExecFailure(["var d: dict<any>", "echo d['a']"], 'E716:', 2) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2017 CheckDefExecFailure(["var d: dict<number>", "d = g:list_empty"], 'E1012: Type mismatch; expected dict<number> but got list<unknown>', 2) |
19848
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
2018 enddef |
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
2019 |
21833
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2020 def Test_expr7_any_index_slice() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2021 var lines =<< trim END |
21833
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2022 # getting the one member should clear the list only after getting the item |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2023 assert_equal('bbb', ['aaa', 'bbb', 'ccc'][1]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2024 |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2025 # string is permissive, index out of range accepted |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2026 g:teststring = 'abcdef' |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2027 assert_equal('b', g:teststring[1]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2028 assert_equal('', g:teststring[-1]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2029 assert_equal('', g:teststring[99]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2030 |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2031 assert_equal('b', g:teststring[1:1]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2032 assert_equal('bcdef', g:teststring[1:]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2033 assert_equal('abcd', g:teststring[:3]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2034 assert_equal('cdef', g:teststring[-4:]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2035 assert_equal('abcdef', g:teststring[-9:]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2036 assert_equal('abcd', g:teststring[:-3]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2037 assert_equal('', g:teststring[:-9]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2038 |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2039 # blob index cannot be out of range |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2040 g:testblob = 0z01ab |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2041 assert_equal(0x01, g:testblob[0]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2042 assert_equal(0xab, g:testblob[1]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2043 assert_equal(0xab, g:testblob[-1]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2044 assert_equal(0x01, g:testblob[-2]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2045 |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2046 # blob slice accepts out of range |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2047 assert_equal(0z01ab, g:testblob[0:1]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2048 assert_equal(0z01, g:testblob[0:0]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2049 assert_equal(0z01, g:testblob[-2:-2]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2050 assert_equal(0zab, g:testblob[1:1]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2051 assert_equal(0zab, g:testblob[-1:-1]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2052 assert_equal(0z, g:testblob[2:2]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2053 assert_equal(0z, g:testblob[0:-3]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2054 |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2055 # list index cannot be out of range |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2056 g:testlist = [0, 1, 2, 3] |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2057 assert_equal(0, g:testlist[0]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2058 assert_equal(1, g:testlist[1]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2059 assert_equal(3, g:testlist[3]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2060 assert_equal(3, g:testlist[-1]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2061 assert_equal(0, g:testlist[-4]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2062 assert_equal(1, g:testlist[g:theone]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2063 |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2064 # list slice accepts out of range |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2065 assert_equal([0], g:testlist[0:0]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2066 assert_equal([3], g:testlist[3:3]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2067 assert_equal([0, 1], g:testlist[0:1]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2068 assert_equal([0, 1, 2, 3], g:testlist[0:3]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2069 assert_equal([0, 1, 2, 3], g:testlist[0:9]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2070 assert_equal([], g:testlist[-1:1]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2071 assert_equal([1], g:testlist[-3:1]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2072 assert_equal([0, 1], g:testlist[-4:1]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2073 assert_equal([0, 1], g:testlist[-9:1]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2074 assert_equal([1, 2, 3], g:testlist[1:-1]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2075 assert_equal([1], g:testlist[1:-3]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2076 assert_equal([], g:testlist[1:-4]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2077 assert_equal([], g:testlist[1:-9]) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2078 |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2079 g:testdict = #{a: 1, b: 2} |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2080 assert_equal(1, g:testdict['a']) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2081 assert_equal(2, g:testdict['b']) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2082 END |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2083 |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2084 CheckDefSuccess(lines) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2085 CheckScriptSuccess(['vim9script'] + lines) |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2086 |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2087 CheckDefExecFailure(['echo g:testblob[2]'], 'E979:', 1) |
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2088 CheckScriptFailure(['vim9script', 'echo g:testblob[2]'], 'E979:', 2) |
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2089 CheckDefExecFailure(['echo g:testblob[-3]'], 'E979:', 1) |
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2090 CheckScriptFailure(['vim9script', 'echo g:testblob[-3]'], 'E979:', 2) |
21833
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2091 |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2092 CheckDefExecFailure(['echo g:testlist[4]'], 'E684:', 1) |
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2093 CheckScriptFailure(['vim9script', 'echo g:testlist[4]'], 'E684:', 2) |
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2094 CheckDefExecFailure(['echo g:testlist[-5]'], 'E684:', 1) |
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2095 CheckScriptFailure(['vim9script', 'echo g:testlist[-5]'], 'E684:', 2) |
21833
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2096 |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2097 CheckDefExecFailure(['echo g:testdict["a":"b"]'], 'E719:', 1) |
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2098 CheckScriptFailure(['vim9script', 'echo g:testdict["a":"b"]'], 'E719:', 2) |
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2099 CheckDefExecFailure(['echo g:testdict[1]'], 'E716:', 1) |
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2100 CheckScriptFailure(['vim9script', 'echo g:testdict[1]'], 'E716:', 2) |
21833
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2101 |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2102 unlet g:teststring |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2103 unlet g:testblob |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
2104 unlet g:testlist |
21166
64f664f9b23a
patch 8.2.1134: Vim9: getting a list member may not work
Bram Moolenaar <Bram@vim.org>
parents:
21152
diff
changeset
|
2105 enddef |
64f664f9b23a
patch 8.2.1134: Vim9: getting a list member may not work
Bram Moolenaar <Bram@vim.org>
parents:
21152
diff
changeset
|
2106 |
21142
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2107 def Test_expr_member_vim9script() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2108 var lines =<< trim END |
21142
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2109 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2110 var d = #{one: |
21142
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2111 'one', |
21512
81c47a694479
patch 8.2.1306: checking for first character of dict key is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
21465
diff
changeset
|
2112 two: 'two', |
81c47a694479
patch 8.2.1306: checking for first character of dict key is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
21465
diff
changeset
|
2113 1: 1, |
81c47a694479
patch 8.2.1306: checking for first character of dict key is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
21465
diff
changeset
|
2114 _: 2} |
21142
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2115 assert_equal('one', d.one) |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2116 assert_equal('one', d |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2117 .one) |
21512
81c47a694479
patch 8.2.1306: checking for first character of dict key is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
21465
diff
changeset
|
2118 assert_equal(1, d |
81c47a694479
patch 8.2.1306: checking for first character of dict key is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
21465
diff
changeset
|
2119 .1) |
81c47a694479
patch 8.2.1306: checking for first character of dict key is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
21465
diff
changeset
|
2120 assert_equal(2, d |
81c47a694479
patch 8.2.1306: checking for first character of dict key is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
21465
diff
changeset
|
2121 ._) |
21142
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2122 assert_equal('one', d[ |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2123 'one' |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2124 ]) |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2125 END |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2126 CheckScriptSuccess(lines) |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2127 |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2128 lines =<< trim END |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2129 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2130 var l = [1, |
21142
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2131 2, |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2132 3, 4 |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2133 ] |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2134 assert_equal(2, l[ |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2135 1 |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2136 ]) |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2137 assert_equal([2, 3], l[1 : 2]) |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2138 assert_equal([1, 2, 3], l[ |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2139 : |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2140 2 |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2141 ]) |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2142 assert_equal([3, 4], l[ |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2143 2 |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2144 : |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2145 ]) |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2146 END |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2147 CheckScriptSuccess(lines) |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2148 enddef |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
2149 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2150 def Test_expr7_option() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
2151 # option |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2152 set ts=11 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2153 assert_equal(11, &ts) |
19449
f8408ba21982
patch 8.2.0282: Vim9: setting number option not tested
Bram Moolenaar <Bram@vim.org>
parents:
19437
diff
changeset
|
2154 &ts = 9 |
f8408ba21982
patch 8.2.0282: Vim9: setting number option not tested
Bram Moolenaar <Bram@vim.org>
parents:
19437
diff
changeset
|
2155 assert_equal(9, &ts) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2156 set ts=8 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2157 set grepprg=some\ text |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2158 assert_equal('some text', &grepprg) |
19219
89931701e033
patch 8.2.0168: Coverity warning for assigning NULL to an option
Bram Moolenaar <Bram@vim.org>
parents:
19217
diff
changeset
|
2159 &grepprg = test_null_string() |
89931701e033
patch 8.2.0168: Coverity warning for assigning NULL to an option
Bram Moolenaar <Bram@vim.org>
parents:
19217
diff
changeset
|
2160 assert_equal('', &grepprg) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2161 set grepprg& |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2162 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2163 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2164 def Test_expr7_environment() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
2165 # environment variable |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2166 assert_equal('testvar', $TESTVAR) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2167 assert_equal('', $ASDF_ASD_XXX) |
19842
e4ade28bfaf7
patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents:
19826
diff
changeset
|
2168 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2169 CheckDefFailure(["var x = $$$"], 'E1002:', 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2170 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2171 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2172 def Test_expr7_register() |
19449
f8408ba21982
patch 8.2.0282: Vim9: setting number option not tested
Bram Moolenaar <Bram@vim.org>
parents:
19437
diff
changeset
|
2173 @a = 'register a' |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2174 assert_equal('register a', @a) |
21612
c495d3e30f4b
patch 8.2.1356: Vim9: cannot get the percent register
Bram Moolenaar <Bram@vim.org>
parents:
21562
diff
changeset
|
2175 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2176 var fname = expand('%') |
21612
c495d3e30f4b
patch 8.2.1356: Vim9: cannot get the percent register
Bram Moolenaar <Bram@vim.org>
parents:
21562
diff
changeset
|
2177 assert_equal(fname, @%) |
c495d3e30f4b
patch 8.2.1356: Vim9: cannot get the percent register
Bram Moolenaar <Bram@vim.org>
parents:
21562
diff
changeset
|
2178 |
c495d3e30f4b
patch 8.2.1356: Vim9: cannot get the percent register
Bram Moolenaar <Bram@vim.org>
parents:
21562
diff
changeset
|
2179 feedkeys(":echo 'some'\<CR>", "xt") |
c495d3e30f4b
patch 8.2.1356: Vim9: cannot get the percent register
Bram Moolenaar <Bram@vim.org>
parents:
21562
diff
changeset
|
2180 assert_equal("echo 'some'", @:) |
c495d3e30f4b
patch 8.2.1356: Vim9: cannot get the percent register
Bram Moolenaar <Bram@vim.org>
parents:
21562
diff
changeset
|
2181 |
c495d3e30f4b
patch 8.2.1356: Vim9: cannot get the percent register
Bram Moolenaar <Bram@vim.org>
parents:
21562
diff
changeset
|
2182 normal axyz |
c495d3e30f4b
patch 8.2.1356: Vim9: cannot get the percent register
Bram Moolenaar <Bram@vim.org>
parents:
21562
diff
changeset
|
2183 assert_equal("xyz", @.) |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22119
diff
changeset
|
2184 CheckDefFailure(["@. = 'yes'"], 'E354:', 1) |
21614
d0128ecd4341
patch 8.2.1357: Vim9: cannot assign to / register
Bram Moolenaar <Bram@vim.org>
parents:
21612
diff
changeset
|
2185 |
d0128ecd4341
patch 8.2.1357: Vim9: cannot assign to / register
Bram Moolenaar <Bram@vim.org>
parents:
21612
diff
changeset
|
2186 @/ = 'slash' |
d0128ecd4341
patch 8.2.1357: Vim9: cannot assign to / register
Bram Moolenaar <Bram@vim.org>
parents:
21612
diff
changeset
|
2187 assert_equal('slash', @/) |
d0128ecd4341
patch 8.2.1357: Vim9: cannot assign to / register
Bram Moolenaar <Bram@vim.org>
parents:
21612
diff
changeset
|
2188 |
d0128ecd4341
patch 8.2.1357: Vim9: cannot assign to / register
Bram Moolenaar <Bram@vim.org>
parents:
21612
diff
changeset
|
2189 @= = 'equal' |
d0128ecd4341
patch 8.2.1357: Vim9: cannot assign to / register
Bram Moolenaar <Bram@vim.org>
parents:
21612
diff
changeset
|
2190 assert_equal('equal', @=) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2191 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2192 |
21399
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2193 def Test_expr7_namespace() |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2194 g:some_var = 'some' |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2195 assert_equal('some', get(g:, 'some_var')) |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2196 assert_equal('some', get(g:, 'some_var', 'xxx')) |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2197 assert_equal('xxx', get(g:, 'no_var', 'xxx')) |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2198 unlet g:some_var |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2199 |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2200 b:some_var = 'some' |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2201 assert_equal('some', get(b:, 'some_var')) |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2202 assert_equal('some', get(b:, 'some_var', 'xxx')) |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2203 assert_equal('xxx', get(b:, 'no_var', 'xxx')) |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2204 unlet b:some_var |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2205 |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2206 w:some_var = 'some' |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2207 assert_equal('some', get(w:, 'some_var')) |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2208 assert_equal('some', get(w:, 'some_var', 'xxx')) |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2209 assert_equal('xxx', get(w:, 'no_var', 'xxx')) |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2210 unlet w:some_var |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2211 |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2212 t:some_var = 'some' |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2213 assert_equal('some', get(t:, 'some_var')) |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2214 assert_equal('some', get(t:, 'some_var', 'xxx')) |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2215 assert_equal('xxx', get(t:, 'no_var', 'xxx')) |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2216 unlet t:some_var |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2217 enddef |
5cb6e676defd
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents:
21393
diff
changeset
|
2218 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2219 def Test_expr7_parens() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
2220 # (expr) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2221 assert_equal(4, (6 * 4) / 6) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2222 assert_equal(0, 6 * ( 4 / 6 )) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2223 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2224 assert_equal(6, +6) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2225 assert_equal(-6, -6) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2226 assert_equal(6, --6) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2227 assert_equal(6, -+-6) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2228 assert_equal(-6, ---6) |
21032
f80e822a310d
patch 8.2.1067: expression "!expr->func()" does not work
Bram Moolenaar <Bram@vim.org>
parents:
21028
diff
changeset
|
2229 assert_equal(false, !-3) |
f80e822a310d
patch 8.2.1067: expression "!expr->func()" does not work
Bram Moolenaar <Bram@vim.org>
parents:
21028
diff
changeset
|
2230 assert_equal(true, !+-+0) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2231 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2232 |
21044
dc2ca403a217
patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents:
21040
diff
changeset
|
2233 def Test_expr7_parens_vim9script() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2234 var lines =<< trim END |
21044
dc2ca403a217
patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents:
21040
diff
changeset
|
2235 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2236 var s = ( |
21044
dc2ca403a217
patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents:
21040
diff
changeset
|
2237 'one' |
dc2ca403a217
patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents:
21040
diff
changeset
|
2238 .. |
dc2ca403a217
patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents:
21040
diff
changeset
|
2239 'two' |
dc2ca403a217
patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents:
21040
diff
changeset
|
2240 ) |
dc2ca403a217
patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents:
21040
diff
changeset
|
2241 assert_equal('onetwo', s) |
dc2ca403a217
patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents:
21040
diff
changeset
|
2242 END |
dc2ca403a217
patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents:
21040
diff
changeset
|
2243 CheckScriptSuccess(lines) |
dc2ca403a217
patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents:
21040
diff
changeset
|
2244 enddef |
dc2ca403a217
patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents:
21040
diff
changeset
|
2245 |
19848
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
2246 def Test_expr7_negate() |
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
2247 assert_equal(-99, -99) |
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
2248 assert_equal(99, --99) |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2249 var nr = 88 |
19848
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
2250 assert_equal(-88, -nr) |
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
2251 assert_equal(88, --nr) |
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
2252 enddef |
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
2253 |
20029
8fb1cf4c44d5
patch 8.2.0570: Vim9: no error when omitting type from argument
Bram Moolenaar <Bram@vim.org>
parents:
20013
diff
changeset
|
2254 def Echo(arg: any): string |
19848
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
2255 return arg |
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
2256 enddef |
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
2257 |
21650
79a8d723a3d2
patch 8.2.1375: Vim9: method name with digit not accepted
Bram Moolenaar <Bram@vim.org>
parents:
21644
diff
changeset
|
2258 def s:Echo4Arg(arg: any): string |
19848
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
2259 return arg |
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
2260 enddef |
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
2261 |
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
2262 def Test_expr7_call() |
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
2263 assert_equal('yes', 'yes'->Echo()) |
21455
8cc1555f2445
patch 8.2.1278: Vim9: line break after "->" only allowed in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21425
diff
changeset
|
2264 assert_equal('yes', 'yes' |
21650
79a8d723a3d2
patch 8.2.1375: Vim9: method name with digit not accepted
Bram Moolenaar <Bram@vim.org>
parents:
21644
diff
changeset
|
2265 ->s:Echo4Arg()) |
21739
caf0286cf02b
patch 8.2.1419: Vim9: not operator applied too early
Bram Moolenaar <Bram@vim.org>
parents:
21737
diff
changeset
|
2266 assert_equal(true, !range(5)->empty()) |
21032
f80e822a310d
patch 8.2.1067: expression "!expr->func()" does not work
Bram Moolenaar <Bram@vim.org>
parents:
21028
diff
changeset
|
2267 assert_equal([0, 1, 2], --3->range()) |
19848
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
2268 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2269 CheckDefFailure(["var x = 'yes'->Echo"], 'E107:', 1) |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22119
diff
changeset
|
2270 CheckScriptFailure([ |
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22119
diff
changeset
|
2271 "vim9script", |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2272 "var x = substitute ('x', 'x', 'x', 'x')" |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22119
diff
changeset
|
2273 ], 'E121:', 2) |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2274 CheckDefFailure(["var Ref = function('len' [1, 2])"], 'E1123:', 1) |
21753
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21739
diff
changeset
|
2275 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2276 var auto_lines =<< trim END |
21753
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21739
diff
changeset
|
2277 def g:some#func(): string |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21739
diff
changeset
|
2278 return 'found' |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21739
diff
changeset
|
2279 enddef |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21739
diff
changeset
|
2280 END |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21739
diff
changeset
|
2281 mkdir('Xruntime/autoload', 'p') |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21739
diff
changeset
|
2282 writefile(auto_lines, 'Xruntime/autoload/some.vim') |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2283 var save_rtp = &rtp |
21753
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21739
diff
changeset
|
2284 &rtp = getcwd() .. '/Xruntime,' .. &rtp |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21739
diff
changeset
|
2285 assert_equal('found', g:some#func()) |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21739
diff
changeset
|
2286 assert_equal('found', some#func()) |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21739
diff
changeset
|
2287 |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21739
diff
changeset
|
2288 &rtp = save_rtp |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21739
diff
changeset
|
2289 delete('Xruntime', 'rf') |
19848
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
2290 enddef |
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
2291 |
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
2292 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2293 def Test_expr7_not() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2294 var lines =<< trim END |
21733
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
2295 assert_equal(true, !'') |
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
2296 assert_equal(true, ![]) |
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
2297 assert_equal(false, !'asdf') |
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
2298 assert_equal(false, ![2]) |
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
2299 assert_equal(true, !!'asdf') |
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
2300 assert_equal(true, !![2]) |
19483
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19469
diff
changeset
|
2301 |
22606
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
2302 assert_equal(true, ! false) |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
2303 assert_equal(true, !! true) |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
2304 assert_equal(true, ! ! true) |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
2305 assert_equal(true, !!! false) |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
2306 assert_equal(true, ! ! ! false) |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
2307 |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
2308 g:true = true |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
2309 g:false = false |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
2310 assert_equal(true, ! g:false) |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
2311 assert_equal(true, !! g:true) |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
2312 assert_equal(true, ! ! g:true) |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
2313 assert_equal(true, !!! g:false) |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
2314 assert_equal(true, ! ! ! g:false) |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
2315 unlet g:true |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
2316 unlet g:false |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
2317 |
21733
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
2318 assert_equal(true, !test_null_partial()) |
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
2319 assert_equal(false, !{-> 'yes'}) |
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
2320 |
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
2321 assert_equal(true, !test_null_dict()) |
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
2322 assert_equal(true, !{}) |
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
2323 assert_equal(false, !{'yes': 'no'}) |
19483
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19469
diff
changeset
|
2324 |
21733
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
2325 if has('channel') |
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
2326 assert_equal(true, !test_null_job()) |
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
2327 assert_equal(true, !test_null_channel()) |
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
2328 endif |
19483
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19469
diff
changeset
|
2329 |
21733
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
2330 assert_equal(true, !test_null_blob()) |
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
2331 assert_equal(true, !0z) |
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
2332 assert_equal(false, !0z01) |
19483
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19469
diff
changeset
|
2333 |
21733
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
2334 assert_equal(true, !test_void()) |
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
2335 assert_equal(true, !test_unknown()) |
21739
caf0286cf02b
patch 8.2.1419: Vim9: not operator applied too early
Bram Moolenaar <Bram@vim.org>
parents:
21737
diff
changeset
|
2336 |
caf0286cf02b
patch 8.2.1419: Vim9: not operator applied too early
Bram Moolenaar <Bram@vim.org>
parents:
21737
diff
changeset
|
2337 assert_equal(false, ![1, 2, 3]->reverse()) |
caf0286cf02b
patch 8.2.1419: Vim9: not operator applied too early
Bram Moolenaar <Bram@vim.org>
parents:
21737
diff
changeset
|
2338 assert_equal(true, ![]->reverse()) |
21733
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
2339 END |
22606
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
2340 CheckDefAndScriptSuccess(lines) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2341 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2342 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2343 func Test_expr7_fails() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2344 call CheckDefFailure(["var x = (12"], "E110:", 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2345 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2346 call CheckDefFailure(["var x = -'xx'"], "E1030:", 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2347 call CheckDefFailure(["var x = +'xx'"], "E1030:", 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2348 call CheckDefFailure(["var x = -0z12"], "E974:", 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2349 call CheckDefExecFailure(["var x = -[8]"], "E39:", 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2350 call CheckDefExecFailure(["var x = -{'a': 1}"], "E39:", 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2351 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2352 call CheckDefFailure(["var x = @"], "E1002:", 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2353 call CheckDefFailure(["var x = @<"], "E354:", 1) |
19217
1235c26d9f04
patch 8.2.0167: Coverity warning for ignoring return value
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
2354 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2355 call CheckDefFailure(["var x = [1, 2"], "E697:", 2) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2356 call CheckDefFailure(["var x = [notfound]"], "E1001:", 1) |
19826
293a22b677a8
patch 8.2.0469: Vim9: no error for missing ] after list
Bram Moolenaar <Bram@vim.org>
parents:
19822
diff
changeset
|
2357 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2358 call CheckDefFailure(["var x = { -> 123) }"], "E451:", 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2359 call CheckDefFailure(["var x = 123->{x -> x + 5) }"], "E451:", 1) |
19826
293a22b677a8
patch 8.2.0469: Vim9: no error for missing ] after list
Bram Moolenaar <Bram@vim.org>
parents:
19822
diff
changeset
|
2360 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2361 call CheckDefFailure(["var x = ¬exist"], 'E113:', 1) |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2362 call CheckDefFailure(["&grepprg = [343]"], 'E1012:', 1) |
19451
b26e96f7c12f
patch 8.2.0283: Vim9: failing to load script var not tested
Bram Moolenaar <Bram@vim.org>
parents:
19449
diff
changeset
|
2363 |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2364 call CheckDefExecFailure(["echo s:doesnt_exist"], 'E121:', 1) |
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2365 call CheckDefExecFailure(["echo g:doesnt_exist"], 'E121:', 1) |
19469
55656a51d2af
patch 8.2.0292: Vim9: CHECKNR and CHECKTYPE instructions not tested
Bram Moolenaar <Bram@vim.org>
parents:
19461
diff
changeset
|
2366 |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2367 call CheckDefFailure(["echo a:somevar"], 'E1075:', 1) |
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2368 call CheckDefFailure(["echo l:somevar"], 'E1075:', 1) |
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2369 call CheckDefFailure(["echo x:somevar"], 'E1075:', 1) |
19822
fc3cdc819d80
patch 8.2.0467: Vim9: some errors are not tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2370 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2371 call CheckDefExecFailure(["var x = +g:astring"], 'E1030:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2372 call CheckDefExecFailure(["var x = +g:ablob"], 'E974:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2373 call CheckDefExecFailure(["var x = +g:alist"], 'E745:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2374 call CheckDefExecFailure(["var x = +g:adict"], 'E728:', 1) |
19558
8eeec8886c02
patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents:
19521
diff
changeset
|
2375 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2376 call CheckDefFailure(["var x = ''", "var y = x.memb"], 'E715:', 2) |
19822
fc3cdc819d80
patch 8.2.0467: Vim9: some errors are not tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2377 |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2378 call CheckDefFailure(["'yes'->", "Echo()"], 'E488: Trailing characters: ->', 1) |
21455
8cc1555f2445
patch 8.2.1278: Vim9: line break after "->" only allowed in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21425
diff
changeset
|
2379 |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2380 call CheckDefExecFailure(["[1, 2->len()"], 'E697:', 2) |
22625
0afa30d6dc72
patch 8.2.1861: Vim9: no specific error when parsing lambda fails
Bram Moolenaar <Bram@vim.org>
parents:
22606
diff
changeset
|
2381 call CheckDefExecFailure(["#{a: 1->len()"], 'E722:', 1) |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2382 call CheckDefExecFailure(["{'a': 1->len()"], 'E723:', 2) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2383 endfunc |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2384 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2385 let g:Funcrefs = [function('add')] |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2386 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2387 func CallMe(arg) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2388 return a:arg |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2389 endfunc |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2390 |
19437
5d34ae66118e
patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents:
19423
diff
changeset
|
2391 func CallMe2(one, two) |
5d34ae66118e
patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents:
19423
diff
changeset
|
2392 return a:one .. a:two |
5d34ae66118e
patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents:
19423
diff
changeset
|
2393 endfunc |
5d34ae66118e
patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents:
19423
diff
changeset
|
2394 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2395 def Test_expr7_trailing() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
2396 # user function call |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2397 assert_equal(123, g:CallMe(123)) |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2398 assert_equal(123, g:CallMe( 123)) |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2399 assert_equal(123, g:CallMe(123 )) |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2400 assert_equal('yesno', g:CallMe2('yes', 'no')) |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2401 assert_equal('yesno', g:CallMe2( 'yes', 'no' )) |
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20170
diff
changeset
|
2402 assert_equal('nothing', g:CallMe('nothing')) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2403 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
2404 # partial call |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2405 var Part = function('g:CallMe') |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2406 assert_equal('yes', Part('yes')) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2407 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
2408 # funcref call, using list index |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2409 var l = [] |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2410 g:Funcrefs[0](l, 2) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2411 assert_equal([2], l) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2412 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
2413 # method call |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2414 l = [2, 5, 6] |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2415 l->map({k, v -> k + v}) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2416 assert_equal([2, 6, 8], l) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2417 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
2418 # lambda method call |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2419 l = [2, 5] |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2420 l->{l -> add(l, 8)}() |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2421 assert_equal([2, 5, 8], l) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2422 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
2423 # dict member |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2424 var d = #{key: 123} |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2425 assert_equal(123, d.key) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2426 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2427 |
21826
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
2428 def Test_expr7_string_subscript() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2429 var lines =<< trim END |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2430 var text = 'abcdef' |
21823
b1f3d8a44ab6
patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
2431 assert_equal('', text[-1]) |
b1f3d8a44ab6
patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
2432 assert_equal('a', text[0]) |
b1f3d8a44ab6
patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
2433 assert_equal('e', text[4]) |
b1f3d8a44ab6
patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
2434 assert_equal('f', text[5]) |
b1f3d8a44ab6
patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
2435 assert_equal('', text[6]) |
b1f3d8a44ab6
patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
2436 |
b1f3d8a44ab6
patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
2437 text = 'ábçdëf' |
b1f3d8a44ab6
patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
2438 assert_equal('', text[-999]) |
b1f3d8a44ab6
patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
2439 assert_equal('', text[-1]) |
b1f3d8a44ab6
patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
2440 assert_equal('á', text[0]) |
b1f3d8a44ab6
patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
2441 assert_equal('b', text[1]) |
b1f3d8a44ab6
patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
2442 assert_equal('ç', text[2]) |
b1f3d8a44ab6
patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
2443 assert_equal('d', text[3]) |
b1f3d8a44ab6
patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
2444 assert_equal('ë', text[4]) |
b1f3d8a44ab6
patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
2445 assert_equal('f', text[5]) |
b1f3d8a44ab6
patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
2446 assert_equal('', text[6]) |
b1f3d8a44ab6
patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
2447 assert_equal('', text[999]) |
21826
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
2448 |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
2449 assert_equal('ábçdëf', text[0:-1]) |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
2450 assert_equal('ábçdëf', text[0 :-1]) |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
2451 assert_equal('ábçdëf', text[0: -1]) |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
2452 assert_equal('ábçdëf', text[0 : -1]) |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
2453 assert_equal('ábçdëf', text[0 |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
2454 :-1]) |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
2455 assert_equal('ábçdëf', text[0: |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
2456 -1]) |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
2457 assert_equal('ábçdëf', text[0 : -1 |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
2458 ]) |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
2459 assert_equal('bçdëf', text[1:-1]) |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
2460 assert_equal('çdëf', text[2:-1]) |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
2461 assert_equal('dëf', text[3:-1]) |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
2462 assert_equal('ëf', text[4:-1]) |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
2463 assert_equal('f', text[5:-1]) |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
2464 assert_equal('', text[6:-1]) |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
2465 assert_equal('', text[999:-1]) |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
2466 |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
2467 assert_equal('ábçd', text[:3]) |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
2468 assert_equal('bçdëf', text[1:]) |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
2469 assert_equal('ábçdëf', text[:]) |
21823
b1f3d8a44ab6
patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
2470 END |
b1f3d8a44ab6
patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
2471 CheckDefSuccess(lines) |
b1f3d8a44ab6
patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
2472 CheckScriptSuccess(['vim9script'] + lines) |
21393
320581a133d9
patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents:
21387
diff
changeset
|
2473 enddef |
320581a133d9
patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents:
21387
diff
changeset
|
2474 |
21828
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2475 def Test_expr7_list_subscript() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2476 var lines =<< trim END |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2477 var list = [0, 1, 2, 3, 4] |
21828
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2478 assert_equal(0, list[0]) |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2479 assert_equal(4, list[4]) |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2480 assert_equal(4, list[-1]) |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2481 assert_equal(0, list[-5]) |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2482 |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2483 assert_equal([0, 1, 2, 3, 4], list[0:4]) |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2484 assert_equal([0, 1, 2, 3, 4], list[:]) |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2485 assert_equal([1, 2, 3, 4], list[1:]) |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2486 assert_equal([2, 3, 4], list[2:-1]) |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2487 assert_equal([4], list[4:-1]) |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2488 assert_equal([], list[5:-1]) |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2489 assert_equal([], list[999:-1]) |
21831
d8422de73113
patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
21828
diff
changeset
|
2490 assert_equal([1, 2, 3, 4], list[g:theone:g:thefour]) |
21828
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2491 |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2492 assert_equal([0, 1, 2, 3], list[0:3]) |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2493 assert_equal([0], list[0:0]) |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2494 assert_equal([0, 1, 2, 3, 4], list[0:-1]) |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2495 assert_equal([0, 1, 2], list[0:-3]) |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2496 assert_equal([0], list[0:-5]) |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2497 assert_equal([], list[0:-6]) |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2498 assert_equal([], list[0:-99]) |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2499 END |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2500 CheckDefSuccess(lines) |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2501 CheckScriptSuccess(['vim9script'] + lines) |
21831
d8422de73113
patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
21828
diff
changeset
|
2502 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2503 lines = ['var l = [0, 1, 2]', 'echo l[g:astring : g:theone]'] |
22284
6b385c2b9ff5
patch 8.2.1691: Vim9: list<any> is not accepted where list<number> is expected
Bram Moolenaar <Bram@vim.org>
parents:
22262
diff
changeset
|
2504 CheckDefExecFailure(lines, 'E1012:') |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2505 CheckScriptFailure(['vim9script'] + lines, 'E1030:', 3) |
21828
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2506 enddef |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
2507 |
22244
9f6b8fdea159
patch 8.2.1671: Vim9: stray error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
22238
diff
changeset
|
2508 def Test_expr7_dict_subscript() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2509 var lines =<< trim END |
22244
9f6b8fdea159
patch 8.2.1671: Vim9: stray error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
22238
diff
changeset
|
2510 vim9script |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2511 var l = [#{lnum: 2}, #{lnum: 1}] |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2512 var res = l[0].lnum > l[1].lnum |
22244
9f6b8fdea159
patch 8.2.1671: Vim9: stray error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
22238
diff
changeset
|
2513 assert_true(res) |
9f6b8fdea159
patch 8.2.1671: Vim9: stray error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
22238
diff
changeset
|
2514 END |
9f6b8fdea159
patch 8.2.1671: Vim9: stray error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
22238
diff
changeset
|
2515 CheckScriptSuccess(lines) |
9f6b8fdea159
patch 8.2.1671: Vim9: stray error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
22238
diff
changeset
|
2516 enddef |
9f6b8fdea159
patch 8.2.1671: Vim9: stray error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
22238
diff
changeset
|
2517 |
20949
62912ad41aff
patch 8.2.1026: Vim9: cannot break the line after "->"
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
2518 def Test_expr7_subscript_linebreak() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2519 var range = range( |
20949
62912ad41aff
patch 8.2.1026: Vim9: cannot break the line after "->"
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
2520 3) |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2521 var l = range |
21455
8cc1555f2445
patch 8.2.1278: Vim9: line break after "->" only allowed in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21425
diff
changeset
|
2522 ->map('string(v:key)') |
20949
62912ad41aff
patch 8.2.1026: Vim9: cannot break the line after "->"
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
2523 assert_equal(['0', '1', '2'], l) |
62912ad41aff
patch 8.2.1026: Vim9: cannot break the line after "->"
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
2524 |
20955
396fe712eb0f
patch 8.2.1029: Vim9: cannot chain function calls with -> at line start
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
2525 l = range |
396fe712eb0f
patch 8.2.1029: Vim9: cannot chain function calls with -> at line start
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
2526 ->map('string(v:key)') |
396fe712eb0f
patch 8.2.1029: Vim9: cannot chain function calls with -> at line start
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
2527 assert_equal(['0', '1', '2'], l) |
396fe712eb0f
patch 8.2.1029: Vim9: cannot chain function calls with -> at line start
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
2528 |
396fe712eb0f
patch 8.2.1029: Vim9: cannot chain function calls with -> at line start
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
2529 l = range # comment |
396fe712eb0f
patch 8.2.1029: Vim9: cannot chain function calls with -> at line start
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
2530 ->map('string(v:key)') |
396fe712eb0f
patch 8.2.1029: Vim9: cannot chain function calls with -> at line start
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
2531 assert_equal(['0', '1', '2'], l) |
396fe712eb0f
patch 8.2.1029: Vim9: cannot chain function calls with -> at line start
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
2532 |
396fe712eb0f
patch 8.2.1029: Vim9: cannot chain function calls with -> at line start
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
2533 l = range |
396fe712eb0f
patch 8.2.1029: Vim9: cannot chain function calls with -> at line start
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
2534 |
396fe712eb0f
patch 8.2.1029: Vim9: cannot chain function calls with -> at line start
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
2535 ->map('string(v:key)') |
396fe712eb0f
patch 8.2.1029: Vim9: cannot chain function calls with -> at line start
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
2536 assert_equal(['0', '1', '2'], l) |
396fe712eb0f
patch 8.2.1029: Vim9: cannot chain function calls with -> at line start
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
2537 |
396fe712eb0f
patch 8.2.1029: Vim9: cannot chain function calls with -> at line start
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
2538 l = range |
396fe712eb0f
patch 8.2.1029: Vim9: cannot chain function calls with -> at line start
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
2539 # comment |
396fe712eb0f
patch 8.2.1029: Vim9: cannot chain function calls with -> at line start
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
2540 ->map('string(v:key)') |
396fe712eb0f
patch 8.2.1029: Vim9: cannot chain function calls with -> at line start
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
2541 assert_equal(['0', '1', '2'], l) |
396fe712eb0f
patch 8.2.1029: Vim9: cannot chain function calls with -> at line start
Bram Moolenaar <Bram@vim.org>
parents:
20953
diff
changeset
|
2542 |
20949
62912ad41aff
patch 8.2.1026: Vim9: cannot break the line after "->"
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
2543 assert_equal('1', l[ |
62912ad41aff
patch 8.2.1026: Vim9: cannot break the line after "->"
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
2544 1]) |
62912ad41aff
patch 8.2.1026: Vim9: cannot break the line after "->"
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
2545 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2546 var d = #{one: 33} |
20949
62912ad41aff
patch 8.2.1026: Vim9: cannot break the line after "->"
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
2547 assert_equal(33, d. |
62912ad41aff
patch 8.2.1026: Vim9: cannot break the line after "->"
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
2548 one) |
62912ad41aff
patch 8.2.1026: Vim9: cannot break the line after "->"
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
2549 enddef |
62912ad41aff
patch 8.2.1026: Vim9: cannot break the line after "->"
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
2550 |
21232
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21216
diff
changeset
|
2551 def Test_expr7_method_call() |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21216
diff
changeset
|
2552 new |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21216
diff
changeset
|
2553 setline(1, ['first', 'last']) |
21544
6c67c86a202a
patch 8.2.1322: Vim9: method on double quoted string doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21512
diff
changeset
|
2554 'second'->append(1) |
6c67c86a202a
patch 8.2.1322: Vim9: method on double quoted string doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21512
diff
changeset
|
2555 "third"->append(2) |
6c67c86a202a
patch 8.2.1322: Vim9: method on double quoted string doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21512
diff
changeset
|
2556 assert_equal(['first', 'second', 'third', 'last'], getline(1, '$')) |
21232
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21216
diff
changeset
|
2557 bwipe! |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21216
diff
changeset
|
2558 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2559 var bufnr = bufnr() |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2560 var loclist = [#{bufnr: bufnr, lnum: 42, col: 17, text: 'wrong'}] |
21232
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21216
diff
changeset
|
2561 loclist->setloclist(0) |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21216
diff
changeset
|
2562 assert_equal([#{bufnr: bufnr, |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21216
diff
changeset
|
2563 lnum: 42, |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21216
diff
changeset
|
2564 col: 17, |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21216
diff
changeset
|
2565 text: 'wrong', |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21216
diff
changeset
|
2566 pattern: '', |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21216
diff
changeset
|
2567 valid: 1, |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21216
diff
changeset
|
2568 vcol: 0, |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21216
diff
changeset
|
2569 nr: 0, |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21216
diff
changeset
|
2570 type: '', |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21216
diff
changeset
|
2571 module: ''} |
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21216
diff
changeset
|
2572 ], getloclist(0)) |
22238
939f7184566f
patch 8.2.1668: Vim9: not accepting 0 or 1 as bool when type is any
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
2573 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2574 var result: bool = get(#{n: 0}, 'n', 0) |
22238
939f7184566f
patch 8.2.1668: Vim9: not accepting 0 or 1 as bool when type is any
Bram Moolenaar <Bram@vim.org>
parents:
22190
diff
changeset
|
2575 assert_equal(false, result) |
21232
3f14e0d4a4dd
patch 8.2.1167: Vim9: builtin function method call only supports first arg
Bram Moolenaar <Bram@vim.org>
parents:
21216
diff
changeset
|
2576 enddef |
20029
8fb1cf4c44d5
patch 8.2.0570: Vim9: no error when omitting type from argument
Bram Moolenaar <Bram@vim.org>
parents:
20013
diff
changeset
|
2577 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2578 func Test_expr7_trailing_fails() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2579 call CheckDefFailure(['var l = [2]', 'l->{l -> add(l, 8)}'], 'E107:', 2) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2580 call CheckDefFailure(['var l = [2]', 'l->{l -> add(l, 8)} ()'], 'E274:', 2) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2581 endfunc |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2582 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2583 func Test_expr_fails() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2584 call CheckDefFailure(["var x = '1'is2"], 'E488:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2585 call CheckDefFailure(["var x = '1'isnot2"], 'E488:', 1) |
19437
5d34ae66118e
patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents:
19423
diff
changeset
|
2586 |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2587 call CheckDefFailure(["CallMe ('yes')"], 'E476:', 1) |
21909
a211bca98bc3
patch 8.2.1504: Vim9: white space checks are only done for a :def function
Bram Moolenaar <Bram@vim.org>
parents:
21905
diff
changeset
|
2588 call CheckScriptFailure(["CallMe ('yes')"], 'E492:', 1) |
22190
da851f3b6a0b
patch 8.2.1644: Vim9: cannot assign 1 and 0 to bool at script level
Bram Moolenaar <Bram@vim.org>
parents:
22147
diff
changeset
|
2589 call CheckDefAndScriptFailure(["CallMe2('yes','no')"], 'E1069:', 1) |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2590 call CheckDefFailure(["CallMe2('yes' , 'no')"], 'E1068:', 1) |
19521
860b39ed0e0b
patch 8.2.0318: Vim9: types not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19485
diff
changeset
|
2591 |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2592 call CheckDefFailure(["v:nosuch += 3"], 'E1001:', 1) |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2593 call CheckDefFailure(["var v:statusmsg = ''"], 'E1016: Cannot declare a v: variable:', 1) |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2594 call CheckDefFailure(["var asdf = v:nosuch"], 'E1001:', 1) |
19822
fc3cdc819d80
patch 8.2.0467: Vim9: some errors are not tested
Bram Moolenaar <Bram@vim.org>
parents:
19583
diff
changeset
|
2595 |
21863
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2596 call CheckDefFailure(["echo len('asdf'"], 'E110:', 2) |
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2597 call CheckDefFailure(["echo Func0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789()"], 'E1011:', 1) |
809b1e7fbd72
patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
21859
diff
changeset
|
2598 call CheckDefFailure(["echo doesnotexist()"], 'E117:', 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2599 endfunc |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21763
diff
changeset
|
2600 |
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21763
diff
changeset
|
2601 " vim: shiftwidth=2 sts=2 expandtab |