annotate src/testdir/test_vim9_expr.vim @ 23418:681f042ae5ac v8.2.2252

patch 8.2.2252: Vim9: crash when using lambda without return type in dict Commit: https://github.com/vim/vim/commit/6b55377303968e1624339cd95053201d5acdcaa2 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Dec 31 13:31:23 2020 +0100 patch 8.2.2252: Vim9: crash when using lambda without return type in dict Problem: Vim9: crash when using lambda without return type in dict. Solution: Without a return type use t_unknown. (closes https://github.com/vim/vim/issues/7587)
author Bram Moolenaar <Bram@vim.org>
date Thu, 31 Dec 2020 13:45:04 +0100
parents 9bd3873b13e2
children 5807e3958e38
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " 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()
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
16 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
17 assert_equal('one', true ? 'one' : 'two')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
18 assert_equal('one', 1 ?
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
19 'one' :
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
20 'two')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
21 if has('float')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
22 assert_equal('one', !!0.1 ? 'one' : 'two')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
23 endif
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
24 assert_equal('one', !!'x' ? 'one' : 'two')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
25 assert_equal('one', !!'x'
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
26 ? 'one'
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
27 : 'two')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
28 assert_equal('one', !!0z1234 ? 'one' : 'two')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
29 assert_equal('one', !![0] ? 'one' : 'two')
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
30 assert_equal('one', !!{x: 0} ? 'one' : 'two')
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
31 var name = 1
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
32 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
33
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
34 assert_equal('two', false ? 'one' : 'two')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
35 assert_equal('two', 0 ? 'one' : 'two')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
36 if has('float')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
37 assert_equal('two', !!0.0 ? 'one' : 'two')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
38 endif
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
39 assert_equal('two', !!'' ? 'one' : 'two')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
40 assert_equal('two', !!0z ? 'one' : 'two')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
41 assert_equal('two', !![] ? 'one' : 'two')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
42 assert_equal('two', !!{} ? 'one' : 'two')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
43 name = 0
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
44 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
45
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
46 # with constant condition expression is not evaluated
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
47 assert_equal('one', 1 ? 'one' : xxx)
21959
67d4be2757b0 patch 8.2.1529: Vim9: :elseif may be compiled when not needed
Bram Moolenaar <Bram@vim.org>
parents: 21955
diff changeset
48
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
49 var Some: func = function('len')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
50 var Other: func = function('winnr')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
51 var Res: func = g:atrue ? Some : Other
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
52 assert_equal(function('len'), Res)
20207
3c247d9cd6f9 patch 8.2.0659: Vim9: no test for equal func type
Bram Moolenaar <Bram@vim.org>
parents: 20203
diff changeset
53
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
54 var RetOne: func(string): number = function('len')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
55 var RetTwo: func(string): number = function('winnr')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
56 var RetThat: func = g:atrue ? RetOne : RetTwo
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
57 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
58
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
59 var X = FuncOne
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
60 var Y = FuncTwo
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
61 var Z = g:cond ? FuncOne : FuncTwo
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
62 assert_equal(123, Z(3))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
63 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
64 CheckDefAndScriptSuccess(lines)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66
22492
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22482
diff changeset
67 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
68 # 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
69 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
70 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
71 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
72 ? 'yes'
9d8634e91d1b patch 8.2.1062: Vim9: no line break allowed inside "cond ? val1 : val2"
Bram Moolenaar <Bram@vim.org>
parents: 20992
diff changeset
73 : 'no'
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
74 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
75 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 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
77
9d8634e91d1b patch 8.2.1062: Vim9: no line break allowed inside "cond ? val1 : val2"
Bram Moolenaar <Bram@vim.org>
parents: 20992
diff changeset
78 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
79 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
80 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
81 ? 'yes'
9d8634e91d1b patch 8.2.1062: Vim9: no line break allowed inside "cond ? val1 : val2"
Bram Moolenaar <Bram@vim.org>
parents: 20992
diff changeset
82 : 'no'
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
83 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
84 END
9d8634e91d1b patch 8.2.1062: Vim9: no line break allowed inside "cond ? val1 : val2"
Bram Moolenaar <Bram@vim.org>
parents: 20992
diff changeset
85 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
86
0ca7e04d39e3 patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents: 21044
diff changeset
87 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
88 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
89 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
90 'yes' :
0ca7e04d39e3 patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents: 21044
diff changeset
91 'no'
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
92 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
93 END
0ca7e04d39e3 patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents: 21044
diff changeset
94 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
95
22580
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
96 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
97 vim9script
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
98 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
99 'yes' :
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
100 # comment
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
101 '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
102 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
103 END
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
104 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
105
21644
7d3ba70a03f1 patch 8.2.1372: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21642
diff changeset
106 # 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
107 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
108 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
109 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
110 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
111 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
112 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
113 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
114 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
115 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
116 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
117 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
118 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
119 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
120 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
121 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
122 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
123 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
124 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
125 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
126 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
127 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
128 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
129 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
130 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
131 CheckScriptFailure(lines, 'E1004:', 2)
21925
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21909
diff changeset
132
22500
ef8a3177edc1 patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents: 22494
diff changeset
133 lines =<< trim END
ef8a3177edc1 patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents: 22494
diff changeset
134 vim9script
ef8a3177edc1 patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents: 22494
diff changeset
135 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
136 END
22860
53acb89ec9f2 patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Bram Moolenaar <Bram@vim.org>
parents: 22836
diff changeset
137 CheckScriptFailure(lines, 'E1135:', 2)
22500
ef8a3177edc1 patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents: 22494
diff changeset
138
ef8a3177edc1 patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents: 22494
diff changeset
139 lines =<< trim END
ef8a3177edc1 patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents: 22494
diff changeset
140 vim9script
ef8a3177edc1 patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents: 22494
diff changeset
141 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
142 END
ef8a3177edc1 patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents: 22494
diff changeset
143 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
144
ef8a3177edc1 patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents: 22494
diff changeset
145 lines =<< trim END
ef8a3177edc1 patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents: 22494
diff changeset
146 vim9script
ef8a3177edc1 patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents: 22494
diff changeset
147 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
148 END
ef8a3177edc1 patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents: 22494
diff changeset
149 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
150
21925
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21909
diff changeset
151 # 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
152 lines =<< trim END
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21909
diff changeset
153 vim9script
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21909
diff changeset
154 try
22147
d55008685870 patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents: 22119
diff changeset
155 eval('0 ? 1: 2')
21925
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21909
diff changeset
156 catch
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21909
diff changeset
157 endtry
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21909
diff changeset
158 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
159 END
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21909
diff changeset
160 CheckScriptSuccess(lines)
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21909
diff changeset
161
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21909
diff changeset
162 lines =<< trim END
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21909
diff changeset
163 vim9script
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21909
diff changeset
164 try
22147
d55008685870 patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents: 22119
diff changeset
165 eval('0 ? 1 :2')
21925
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21909
diff changeset
166 catch
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21909
diff changeset
167 endtry
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21909
diff changeset
168 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
169 END
51d591dbb8df patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents: 21909
diff changeset
170 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
171 enddef
9d8634e91d1b patch 8.2.1062: Vim9: no line break allowed inside "cond ? val1 : val2"
Bram Moolenaar <Bram@vim.org>
parents: 20992
diff changeset
172
22492
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22482
diff changeset
173 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
174 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
175
22296
006b8ab9d554 patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents: 22284
diff changeset
176 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
177 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
178 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
179 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
180
22296
006b8ab9d554 patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents: 22284
diff changeset
181 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
182 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
183 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
184 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
185
22860
53acb89ec9f2 patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Bram Moolenaar <Bram@vim.org>
parents: 22836
diff changeset
186 call CheckDefFailure(["var x = 'x' ? 'one' : 'two'"], 'E1135:', 1)
22500
ef8a3177edc1 patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents: 22494
diff changeset
187 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
188 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
189 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
190
23122
60a0221beab0 patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents: 23106
diff changeset
191 call CheckDefExecFailure(["var x = false ? "], 'E1097:', 3)
60a0221beab0 patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents: 23106
diff changeset
192 call CheckDefExecFailure(["var x = false ? 'one' : "], 'E1097:', 3)
23106
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
193
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
194 call CheckDefExecFailure(["var x = true ? xxx : 'foo'"], 'E1001:', 1)
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
195 call CheckDefExecFailure(["var x = false ? 'foo' : xxx"], 'E1001:', 1)
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
196
22500
ef8a3177edc1 patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents: 22494
diff changeset
197 if has('float')
ef8a3177edc1 patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents: 22494
diff changeset
198 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
199 endif
ef8a3177edc1 patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents: 22494
diff changeset
200
21421
0f0fee4122d3 patch 8.2.1261: Vim9: common type of function not tested
Bram Moolenaar <Bram@vim.org>
parents: 21411
diff changeset
201 " 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
202 call CheckDefFailure([
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
203 \ 'var X = FuncOne',
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
204 \ 'var Y = FuncTwo',
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
205 \ '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
206 \ '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
207 endfunc
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
208
22492
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22482
diff changeset
209 def Test_expr1_falsy()
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22482
diff changeset
210 var lines =<< trim END
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22482
diff changeset
211 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
212 assert_equal(123, 123 ?? 456)
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22482
diff changeset
213 assert_equal('yes', 'yes' ?? 456)
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22482
diff changeset
214 assert_equal([1], [1] ?? 456)
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
215 assert_equal({one: 1}, {one: 1} ?? 456)
22492
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(0.1, 0.1 ?? 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
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22482
diff changeset
220 assert_equal(456, v:false ?? 456)
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22482
diff changeset
221 assert_equal(456, 0 ?? 456)
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22482
diff changeset
222 assert_equal(456, '' ?? 456)
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22482
diff changeset
223 assert_equal(456, [] ?? 456)
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22482
diff changeset
224 assert_equal(456, {} ?? 456)
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22482
diff changeset
225 if has('float')
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22482
diff changeset
226 assert_equal(456, 0.0 ?? 456)
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22482
diff changeset
227 endif
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22482
diff changeset
228 END
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22482
diff changeset
229 CheckDefAndScriptSuccess(lines)
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22482
diff changeset
230
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22482
diff changeset
231 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
232 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
233 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
234 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
235 enddef
0e03ef68e738 patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents: 22482
diff changeset
236
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
237 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
238 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
239 return val
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
240 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
241
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
242 " test ||
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
243 def Test_expr2()
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
244 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
245 assert_equal(true, 1 || 0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
246 assert_equal(true, 0 ||
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
247 0 ||
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
248 1)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
249 assert_equal(true, 0 ||
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
250 0 ||
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
251 !!7)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
252 assert_equal(false, 0 || 0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
253 assert_equal(false, 0
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
254 || 0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
255 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
256
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
257 g:vals = []
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
258 assert_equal(true, Record(1) || Record(3))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
259 assert_equal([1], g:vals)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
260
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
261 g:vals = []
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
262 assert_equal(true, Record(0) || Record(1))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
263 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
264
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
265 g:vals = []
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
266 assert_equal(true, Record(0) || Record(true))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
267 assert_equal([0, true], g:vals)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
268
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
269 g:vals = []
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
270 assert_equal(true, Record(0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
271 || Record(1)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
272 || Record(0))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
273 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
274
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
275 g:vals = []
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
276 assert_equal(true, Record(0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
277 || Record(true)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
278 || Record(0))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
279 assert_equal([0, true], g:vals)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
280
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
281 g:vals = []
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
282 assert_equal(true, Record(true) || Record(false))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
283 assert_equal([true], g:vals)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
284
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
285 g:vals = []
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
286 assert_equal(false, Record(0) || Record(false) || Record(0))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
287 assert_equal([0, false, 0], g:vals)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
288 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
289 CheckDefAndScriptSuccess(lines)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
290 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
291
21024
02b03915855d patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents: 21022
diff changeset
292 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
293 # 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
294 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
295 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
296 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
297 || 1
22494
4c21f7f6f9e3 patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents: 22492
diff changeset
298 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
299 END
02b03915855d patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents: 21022
diff changeset
300 CheckScriptSuccess(lines)
02b03915855d patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents: 21022
diff changeset
301
02b03915855d patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents: 21022
diff changeset
302 lines =<< trim END
02b03915855d patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents: 21022
diff changeset
303 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
304 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
305 || v:true
02b03915855d patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents: 21022
diff changeset
306 || v:false
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
307 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
308 END
02b03915855d patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents: 21022
diff changeset
309 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
310
0ca7e04d39e3 patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents: 21044
diff changeset
311 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
312 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
313 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
314 v:true ||
0ca7e04d39e3 patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents: 21044
diff changeset
315 v:false
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
316 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
317 END
31a3f4d408b9 patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents: 21307
diff changeset
318 CheckScriptSuccess(lines)
31a3f4d408b9 patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents: 21307
diff changeset
319
22580
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
320 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
321 vim9script
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
322 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
323 # comment
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
324 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
325 # comment
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
326 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
327 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
328 END
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
329 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
330
21642
5ae89c8633ae patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21636
diff changeset
331 # 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
332 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
333 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
334 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
335 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
336 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
337 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
338 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
339 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
340 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
341 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
342 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
343 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
344 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
345 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
346 CheckScriptFailure(lines, 'E1004:', 2)
21024
02b03915855d patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents: 21022
diff changeset
347 enddef
02b03915855d patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents: 21022
diff changeset
348
22494
4c21f7f6f9e3 patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents: 22492
diff changeset
349 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
350 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
351 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
352 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
353 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
354
23122
60a0221beab0 patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents: 23106
diff changeset
355 call CheckDefFailure(["var x = false || "], 'E1097:', 3)
23106
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
356
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
357 call CheckDefFailure(["var x = 1 || xxx"], 'E1001:', 1)
22860
53acb89ec9f2 patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Bram Moolenaar <Bram@vim.org>
parents: 22836
diff changeset
358 call CheckDefFailure(["var x = [] || false"], 'E1012:', 1)
53acb89ec9f2 patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Bram Moolenaar <Bram@vim.org>
parents: 22836
diff changeset
359 call CheckDefFailure(["if 'yes' || 0", 'echo 0', 'endif'], 'E1012: Type mismatch; expected bool but got string', 1)
22494
4c21f7f6f9e3 patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents: 22492
diff changeset
360
4c21f7f6f9e3 patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents: 22492
diff changeset
361 # 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
362 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
363 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
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()
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
369 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
370 assert_equal(false, 1 && 0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
371 assert_equal(false, 0 &&
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
372 0 &&
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
373 1)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
374 assert_equal(true, 1
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
375 && true
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
376 && 1)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
377 assert_equal(false, 0 && 0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
378 assert_equal(false, 0 && false)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
379 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
380
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
381 g:vals = []
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
382 assert_equal(true, Record(true) && Record(1))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
383 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
384
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
385 g:vals = []
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
386 assert_equal(true, Record(1) && Record(true))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
387 assert_equal([1, true], g:vals)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
388
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
389 g:vals = []
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
390 assert_equal(false, Record(0) && Record(1))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
391 assert_equal([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
392
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
393 g:vals = []
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
394 assert_equal(false, Record(0) && Record(1) && Record(0))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
395 assert_equal([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
396
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
397 g:vals = []
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
398 assert_equal(false, Record(0) && Record(4) && Record(0))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
399 assert_equal([0], g:vals)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
400
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
401 g:vals = []
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
402 assert_equal(false, Record(1) && Record(true) && Record(0))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
403 assert_equal([1, true, 0], g:vals)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
404 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
405 CheckDefAndScriptSuccess(lines)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
406 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
407
21024
02b03915855d patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents: 21022
diff changeset
408 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
409 # 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
410 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
411 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
412 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
413 && 1
22494
4c21f7f6f9e3 patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents: 22492
diff changeset
414 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
415 END
02b03915855d patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents: 21022
diff changeset
416 CheckScriptSuccess(lines)
02b03915855d patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents: 21022
diff changeset
417
02b03915855d patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents: 21022
diff changeset
418 lines =<< trim END
02b03915855d patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents: 21022
diff changeset
419 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
420 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
421 && v:true
02b03915855d patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents: 21022
diff changeset
422 && v:true
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
423 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
424 END
02b03915855d patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents: 21022
diff changeset
425 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
426
0ca7e04d39e3 patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents: 21044
diff changeset
427 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
428 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
429 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
430 v:true &&
0ca7e04d39e3 patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents: 21044
diff changeset
431 v:true
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
432 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
433 END
31a3f4d408b9 patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents: 21307
diff changeset
434 CheckScriptSuccess(lines)
31a3f4d408b9 patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents: 21307
diff changeset
435
22580
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
436 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
437 vim9script
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
438 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
439 # comment
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
440 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
441 # comment
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
442 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
443 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
444 END
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
445 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
446
21642
5ae89c8633ae patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21636
diff changeset
447 # 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
448 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
449 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
450 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
451 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
452 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
453 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
454 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
455 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
456 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
457 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
458 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
459 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
460 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
461 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
462 CheckScriptFailure(lines, 'E1004:', 2)
21024
02b03915855d patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents: 21022
diff changeset
463 enddef
02b03915855d patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents: 21022
diff changeset
464
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
465 func Test_expr3_fails()
22296
006b8ab9d554 patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents: 22284
diff changeset
466 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
467 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
468 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
469 call CheckDefFailure(["var x = 1&& 2"], msg, 1)
22860
53acb89ec9f2 patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Bram Moolenaar <Bram@vim.org>
parents: 22836
diff changeset
470
53acb89ec9f2 patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Bram Moolenaar <Bram@vim.org>
parents: 22836
diff changeset
471 call CheckDefFailure(["if 'yes' && 0", 'echo 0', 'endif'], 'E1012: Type mismatch; expected bool but got string', 1)
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
472
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
473 call CheckDefExecFailure(['assert_equal(false, Record(1) && Record(4) && Record(0))'], 'E1023: Using a Number as a Bool: 4', 1)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
474 endfunc
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
475
21831
d8422de73113 patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
476 " 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
477 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
478 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
479 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
480 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
481 let anint = 10
21831
d8422de73113 patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
482 let theone = 1
d8422de73113 patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
483 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
484 if has('float')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
485 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
486 endif
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
487 let astring = 'asdf'
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
488 let ablob = 0z01ab
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
489 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
490 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
491
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
492 " test == comperator
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
493 def Test_expr4_equal()
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
494 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
495 var trueVar = true
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
496 var falseVar = false
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
497 assert_equal(true, true == true)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
498 assert_equal(false, true ==
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
499 false)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
500 assert_equal(true, true
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
501 == trueVar)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
502 assert_equal(false, true == falseVar)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
503 assert_equal(true, true == g:atrue)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
504 assert_equal(false, g:atrue == false)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
505
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
506 assert_equal(true, v:none == v:none)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
507 assert_equal(false, v:none == v:null)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
508 assert_equal(true, g:anone == v:none)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
509 assert_equal(false, v:none == g:anull)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
510
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
511 var nr0 = 0
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
512 var nr61 = 61
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
513 assert_equal(false, 2 == 0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
514 assert_equal(false, 2 == nr0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
515 assert_equal(true, 61 == 61)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
516 assert_equal(true, 61 == nr61)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
517 assert_equal(true, g:anint == 10)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
518 assert_equal(false, 61 == g:anint)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
519
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
520 if has('float')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
521 var ff = 0.3
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
522 assert_equal(true, ff == 0.3)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
523 assert_equal(false, 0.4 == ff)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
524 assert_equal(true, 0.1 == g:afloat)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
525 assert_equal(false, g:afloat == 0.3)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
526
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
527 ff = 3.0
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
528 assert_equal(true, ff == 3)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
529 assert_equal(true, 3 == ff)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
530 ff = 3.1
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
531 assert_equal(false, ff == 3)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
532 assert_equal(false, 3 == ff)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
533 endif
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
534
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
535 assert_equal(true, 'abc' == 'abc')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
536 assert_equal(false, 'xyz' == 'abc')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
537 assert_equal(true, g:astring == 'asdf')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
538 assert_equal(false, 'xyz' == g:astring)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
539
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
540 assert_equal(false, 'abc' == 'aBc')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
541 assert_equal(false, 'abc' ==# 'aBc')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
542 assert_equal(true, 'abc' ==? 'aBc')
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
543
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
544 assert_equal(false, 'abc' == 'ABC')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
545 set ignorecase
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
546 assert_equal(false, 'abc' == 'ABC')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
547 assert_equal(false, 'abc' ==# 'ABC')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
548 assert_equal(true, 'abc' ==? 'ABC')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
549 set noignorecase
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
550
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
551 var bb = 0z3f
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
552 assert_equal(true, 0z3f == bb)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
553 assert_equal(false, bb == 0z4f)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
554 assert_equal(true, g:ablob == 0z01ab)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
555 assert_equal(false, 0z3f == g:ablob)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
556
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
557 assert_equal(true, [1, 2, 3] == [1, 2, 3])
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
558 assert_equal(false, [1, 2, 3] == [2, 3, 1])
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
559 assert_equal(true, [2, 3, 4] == g:alist)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
560 assert_equal(false, g:alist == [2, 3, 1])
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
561 assert_equal(false, [1, 2, 3] == [])
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
562 assert_equal(false, [1, 2, 3] == ['1', '2', '3'])
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
563
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
564 assert_equal(true, {one: 1, two: 2} == {one: 1, two: 2})
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
565 assert_equal(false, {one: 1, two: 2} == {one: 2, two: 2})
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
566 assert_equal(false, {one: 1, two: 2} == {two: 2})
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
567 assert_equal(false, {one: 1, two: 2} == {})
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
568 assert_equal(true, g:adict == {bbb: 8, aaa: 2})
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
569 assert_equal(false, {ccc: 9, aaa: 2} == g:adict)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
570
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
571 assert_equal(true, function('g:Test_expr4_equal') == function('g:Test_expr4_equal'))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
572 assert_equal(false, function('g:Test_expr4_equal') == function('g:Test_expr4_is'))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
573
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
574 assert_equal(true, function('g:Test_expr4_equal', [123]) == function('g:Test_expr4_equal', [123]))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
575 assert_equal(false, function('g:Test_expr4_equal', [123]) == function('g:Test_expr4_is', [123]))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
576 assert_equal(false, function('g:Test_expr4_equal', [123]) == function('g:Test_expr4_equal', [999]))
19860
37c4779ca8f5 patch 8.2.0486: Vim9: some code and error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19856
diff changeset
577
22878
f304f84b81a6 patch 8.2.1986: expression test is flaky on Appveyor
Bram Moolenaar <Bram@vim.org>
parents: 22866
diff changeset
578 # TODO: this unexpectedly sometimes fails on Appveyor
f304f84b81a6 patch 8.2.1986: expression test is flaky on Appveyor
Bram Moolenaar <Bram@vim.org>
parents: 22866
diff changeset
579 if !has('win32')
f304f84b81a6 patch 8.2.1986: expression test is flaky on Appveyor
Bram Moolenaar <Bram@vim.org>
parents: 22866
diff changeset
580 var OneFunc: func
f304f84b81a6 patch 8.2.1986: expression test is flaky on Appveyor
Bram Moolenaar <Bram@vim.org>
parents: 22866
diff changeset
581 var TwoFunc: func
f304f84b81a6 patch 8.2.1986: expression test is flaky on Appveyor
Bram Moolenaar <Bram@vim.org>
parents: 22866
diff changeset
582 OneFunc = function('len')
f304f84b81a6 patch 8.2.1986: expression test is flaky on Appveyor
Bram Moolenaar <Bram@vim.org>
parents: 22866
diff changeset
583 TwoFunc = function('len')
f304f84b81a6 patch 8.2.1986: expression test is flaky on Appveyor
Bram Moolenaar <Bram@vim.org>
parents: 22866
diff changeset
584 assert_equal(true, OneFunc('abc') == TwoFunc('123'))
f304f84b81a6 patch 8.2.1986: expression test is flaky on Appveyor
Bram Moolenaar <Bram@vim.org>
parents: 22866
diff changeset
585 endif
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
586 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
587 CheckDefAndScriptSuccess(lines)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
588
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
589 CheckDefFailure(["var x = 'a' == xxx"], 'E1001:', 1)
23122
60a0221beab0 patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents: 23106
diff changeset
590 CheckDefFailure(["var x = 'a' == "], 'E1097:', 3)
23106
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
591
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
592 CheckDefExecFailure(['var items: any', 'eval 1', 'eval 2', 'if items == []', 'endif'], 'E691:', 4)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
593 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
594
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
595 " test != comperator
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
596 def Test_expr4_notequal()
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
597 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
598 var trueVar = true
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
599 var falseVar = false
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
600 assert_equal(false, true != true)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
601 assert_equal(true, true !=
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
602 false)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
603 assert_equal(false, true
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
604 != trueVar)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
605 assert_equal(true, true != falseVar)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
606 assert_equal(false, true != g:atrue)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
607 assert_equal(true, g:atrue != false)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
608
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
609 assert_equal(false, v:none != v:none)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
610 assert_equal(true, v:none != v:null)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
611 assert_equal(false, g:anone != v:none)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
612 assert_equal(true, v:none != g:anull)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
613
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
614 var nr55 = 55
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
615 var nr0 = 55
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
616 assert_equal(true, 2 != 0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
617 assert_equal(true, 2 != nr0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
618 assert_equal(false, 55 != 55)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
619 assert_equal(false, 55 != nr55)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
620 assert_equal(false, g:anint != 10)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
621 assert_equal(true, 61 != g:anint)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
622
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
623 if has('float')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
624 var ff = 0.3
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
625 assert_equal(false, 0.3 != ff)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
626 assert_equal(true, 0.4 != ff)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
627 assert_equal(false, 0.1 != g:afloat)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
628 assert_equal(true, g:afloat != 0.3)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
629
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
630 ff = 3.0
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
631 assert_equal(false, ff != 3)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
632 assert_equal(false, 3 != ff)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
633 ff = 3.1
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
634 assert_equal(true, ff != 3)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
635 assert_equal(true, 3 != ff)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
636 endif
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
637
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
638 assert_equal(false, 'abc' != 'abc')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
639 assert_equal(true, 'xyz' != 'abc')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
640 assert_equal(false, g:astring != 'asdf')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
641 assert_equal(true, 'xyz' != g:astring)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
642
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
643 assert_equal(true, 'abc' != 'ABC')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
644 set ignorecase
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
645 assert_equal(true, 'abc' != 'ABC')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
646 assert_equal(true, 'abc' !=# 'ABC')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
647 assert_equal(false, 'abc' !=? 'ABC')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
648 set noignorecase
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
649
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
650 var bb = 0z3f
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
651 assert_equal(false, 0z3f != bb)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
652 assert_equal(true, bb != 0z4f)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
653 assert_equal(false, g:ablob != 0z01ab)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
654 assert_equal(true, 0z3f != g:ablob)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
655
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
656 assert_equal(false, [1, 2, 3] != [1, 2, 3])
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
657 assert_equal(true, [1, 2, 3] != [2, 3, 1])
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
658 assert_equal(false, [2, 3, 4] != g:alist)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
659 assert_equal(true, g:alist != [2, 3, 1])
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
660 assert_equal(true, [1, 2, 3] != [])
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
661 assert_equal(true, [1, 2, 3] != ['1', '2', '3'])
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
662
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
663 assert_equal(false, {one: 1, two: 2} != {one: 1, two: 2})
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
664 assert_equal(true, {one: 1, two: 2} != {one: 2, two: 2})
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
665 assert_equal(true, {one: 1, two: 2} != {two: 2})
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
666 assert_equal(true, {one: 1, two: 2} != {})
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
667 assert_equal(false, g:adict != {bbb: 8, aaa: 2})
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
668 assert_equal(true, {ccc: 9, aaa: 2} != g:adict)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
669
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
670 assert_equal(false, function('g:Test_expr4_equal') != function('g:Test_expr4_equal'))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
671 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
672
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
673 assert_equal(false, function('g:Test_expr4_equal', [123]) != function('g:Test_expr4_equal', [123]))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
674 assert_equal(true, function('g:Test_expr4_equal', [123]) != function('g:Test_expr4_is', [123]))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
675 assert_equal(true, function('g:Test_expr4_equal', [123]) != function('g:Test_expr4_equal', [999]))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
676 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
677 CheckDefAndScriptSuccess(lines)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
678 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
679
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
680 " test > comperator
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
681 def Test_expr4_greater()
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
682 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
683 assert_true(2 > 0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
684 assert_true(2 >
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
685 1)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
686 assert_false(2 > 2)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
687 assert_false(2 > 3)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
688 var nr2 = 2
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
689 assert_true(nr2 > 0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
690 assert_true(nr2 >
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
691 1)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
692 assert_false(nr2 > 2)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
693 assert_false(nr2
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
694 > 3)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
695 if has('float')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
696 var ff = 2.0
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
697 assert_true(ff > 0.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
698 assert_true(ff > 1.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
699 assert_false(ff > 2.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
700 assert_false(ff > 3.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
701 endif
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
702 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
703 CheckDefAndScriptSuccess(lines)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
704 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
705
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
706 " test >= comperator
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
707 def Test_expr4_greaterequal()
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
708 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
709 assert_true(2 >= 0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
710 assert_true(2 >=
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
711 2)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
712 assert_false(2 >= 3)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
713 var nr2 = 2
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
714 assert_true(nr2 >= 0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
715 assert_true(nr2 >= 2)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
716 assert_false(nr2 >= 3)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
717 if has('float')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
718 var ff = 2.0
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
719 assert_true(ff >= 0.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
720 assert_true(ff >= 2.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
721 assert_false(ff >= 3.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
722 endif
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
723 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
724 CheckDefAndScriptSuccess(lines)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
725 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
726
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
727 " test < comperator
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
728 def Test_expr4_smaller()
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
729 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
730 assert_false(2 < 0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
731 assert_false(2 <
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
732 2)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
733 assert_true(2
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
734 < 3)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
735 var nr2 = 2
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
736 assert_false(nr2 < 0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
737 assert_false(nr2 < 2)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
738 assert_true(nr2 < 3)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
739 if has('float')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
740 var ff = 2.0
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
741 assert_false(ff < 0.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
742 assert_false(ff < 2.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
743 assert_true(ff < 3.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
744 endif
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
745 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
746 CheckDefAndScriptSuccess(lines)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
747 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
748
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
749 " test <= comperator
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
750 def Test_expr4_smallerequal()
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
751 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
752 assert_false(2 <= 0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
753 assert_false(2 <=
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
754 1)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
755 assert_true(2
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
756 <= 2)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
757 assert_true(2 <= 3)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
758 var nr2 = 2
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
759 assert_false(nr2 <= 0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
760 assert_false(nr2 <= 1)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
761 assert_true(nr2 <= 2)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
762 assert_true(nr2 <= 3)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
763 if has('float')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
764 var ff = 2.0
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
765 assert_false(ff <= 0.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
766 assert_false(ff <= 1.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
767 assert_true(ff <= 2.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
768 assert_true(ff <= 3.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
769 endif
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
770 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
771 CheckDefAndScriptSuccess(lines)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
772 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
773
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
774 " test =~ comperator
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
775 def Test_expr4_match()
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
776 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
777 assert_equal(false, '2' =~ '0')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
778 assert_equal(false, ''
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
779 =~ '0')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
780 assert_equal(true, '2' =~
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
781 '[0-9]')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
782 set ignorecase
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
783 assert_equal(false, 'abc' =~ 'ABC')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
784 assert_equal(false, 'abc' =~# 'ABC')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
785 assert_equal(true, 'abc' =~? 'ABC')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
786 set noignorecase
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
787 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
788 CheckDefAndScriptSuccess(lines)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
789 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
790
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
791 " test !~ comperator
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
792 def Test_expr4_nomatch()
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
793 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
794 assert_equal(true, '2' !~ '0')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
795 assert_equal(true, ''
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
796 !~ '0')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
797 assert_equal(false, '2' !~
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
798 '[0-9]')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
799 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
800 CheckDefAndScriptSuccess(lines)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
801 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
802
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
803 " test is comperator
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
804 def Test_expr4_is()
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
805 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
806 var mylist = [2]
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
807 assert_false(mylist is [2])
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
808 var other = mylist
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
809 assert_true(mylist is
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
810 other)
19461
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
811
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
812 var myblob = 0z1234
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
813 assert_false(myblob
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
814 is 0z1234)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
815 var otherblob = myblob
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
816 assert_true(myblob is otherblob)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
817 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
818 CheckDefAndScriptSuccess(lines)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
819 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
820
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
821 " test isnot comperator
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
822 def Test_expr4_isnot()
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
823 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
824 var mylist = [2]
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
825 assert_true('2' isnot '0')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
826 assert_true(mylist isnot [2])
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
827 var other = mylist
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
828 assert_false(mylist isnot
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
829 other)
19461
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
830
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
831 var myblob = 0z1234
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
832 assert_true(myblob
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
833 isnot 0z1234)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
834 var otherblob = myblob
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
835 assert_false(myblob isnot otherblob)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
836 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
837 CheckDefAndScriptSuccess(lines)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
838 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
839
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
840 def RetVoid()
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
841 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
842 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
843
21737
a849c984b485 patch 8.2.1418: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents: 21733
diff changeset
844 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
845 # 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
846 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
847 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
848 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
849 < 1
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
850 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
851 END
fe2ed85db946 patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents: 21024
diff changeset
852 CheckScriptSuccess(lines)
fe2ed85db946 patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents: 21024
diff changeset
853
fe2ed85db946 patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents: 21024
diff changeset
854 lines =<< trim END
fe2ed85db946 patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents: 21024
diff changeset
855 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
856 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
857 # comment
21026
fe2ed85db946 patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents: 21024
diff changeset
858 != 123
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
859 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
860 END
fe2ed85db946 patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents: 21024
diff changeset
861 CheckScriptSuccess(lines)
fe2ed85db946 patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents: 21024
diff changeset
862
fe2ed85db946 patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents: 21024
diff changeset
863 lines =<< trim END
fe2ed85db946 patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents: 21024
diff changeset
864 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
865 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
866 123
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
867 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
868 END
0ca7e04d39e3 patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents: 21044
diff changeset
869 CheckScriptSuccess(lines)
0ca7e04d39e3 patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents: 21044
diff changeset
870
0ca7e04d39e3 patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents: 21044
diff changeset
871 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
872 vim9script
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
873 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
874 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
875 is list
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
876 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
877 END
fe2ed85db946 patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents: 21024
diff changeset
878 CheckScriptSuccess(lines)
fe2ed85db946 patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents: 21024
diff changeset
879
fe2ed85db946 patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents: 21024
diff changeset
880 lines =<< trim END
fe2ed85db946 patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents: 21024
diff changeset
881 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
882 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
883 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
884 # comment
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
885 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
886 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
887 END
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
888 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
889
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
890 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
891 vim9script
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
892 var myblob = 0z1234
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
893 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
894 isnot 0z11
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
895 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
896 END
fe2ed85db946 patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents: 21024
diff changeset
897 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
898
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21313
diff changeset
899 # 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
900 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
901 vim9script
d1215fcdbca8 patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 21248
diff changeset
902 echo '' == 0
d1215fcdbca8 patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 21248
diff changeset
903 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
904 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
905
d1215fcdbca8 patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 21248
diff changeset
906 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
907 vim9script
d1215fcdbca8 patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 21248
diff changeset
908 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
909 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
910 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
911
d1215fcdbca8 patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 21248
diff changeset
912 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
913 vim9script
d1215fcdbca8 patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 21248
diff changeset
914 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
915 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
916 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
917
21636
dcfcb6163f3d patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21634
diff changeset
918 # 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
919 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
920 vim9script
dcfcb6163f3d patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21634
diff changeset
921 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
922 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
923 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
924 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
925 vim9script
dcfcb6163f3d patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21634
diff changeset
926 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
927 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
928 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
929 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
930 vim9script
dcfcb6163f3d patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21634
diff changeset
931 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
932 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
933 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
934 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
935 vim9script
dcfcb6163f3d patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21634
diff changeset
936 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
937 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
938 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
939 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
940 vim9script
dcfcb6163f3d patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21634
diff changeset
941 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
942 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
943 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
944 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
945 vim9script
dcfcb6163f3d patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21634
diff changeset
946 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
947 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
948 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
949
a849c984b485 patch 8.2.1418: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents: 21733
diff changeset
950 lines =<< trim END
a849c984b485 patch 8.2.1418: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents: 21733
diff changeset
951 vim9script
a849c984b485 patch 8.2.1418: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents: 21733
diff changeset
952 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
953 END
a849c984b485 patch 8.2.1418: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents: 21733
diff changeset
954 CheckScriptSuccess(lines)
21837
2b941fbab4d9 patch 8.2.1468: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents: 21833
diff changeset
955
2b941fbab4d9 patch 8.2.1468: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents: 21833
diff changeset
956 lines =<< trim END
2b941fbab4d9 patch 8.2.1468: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents: 21833
diff changeset
957 vim9script
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
958 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
959 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
960 END
2b941fbab4d9 patch 8.2.1468: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents: 21833
diff changeset
961 CheckScriptSuccess(lines)
21026
fe2ed85db946 patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents: 21024
diff changeset
962 enddef
fe2ed85db946 patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents: 21024
diff changeset
963
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
964 func Test_expr4_fails()
22296
006b8ab9d554 patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents: 22284
diff changeset
965 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
966 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
967 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
968 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
969
22296
006b8ab9d554 patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents: 22284
diff changeset
970 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
971 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
972 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
973 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
974
22296
006b8ab9d554 patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents: 22284
diff changeset
975 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
976 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
977 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
978 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
979
22296
006b8ab9d554 patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents: 22284
diff changeset
980 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
981 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
982 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
983 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
984
22421
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 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
986 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
987 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
988 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
989
22421
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 = 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
991 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
992 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
993 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
994
22421
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 <= 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
999 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
1000 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
1001 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
1002 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
1003
22421
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 = 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
1005 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
1006 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
1007 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
1008 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
1009 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
1010 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
1011 endif
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1012
22421
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)
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1016 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
1017 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
1018 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
1019
22421
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)
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1023 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
1024 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
1025 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
1026
22421
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 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
1028 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
1029 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
1030 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
1031 endfunc
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1032
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1033 " 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
1034 def Test_expr5()
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1035 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1036 assert_equal(66, 60 + 6)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1037 assert_equal(70, 60 +
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1038 g:anint)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1039 assert_equal(9, g:thefour
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1040 + 5)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1041 assert_equal(14, g:thefour + g:anint)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1042 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
1043
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1044 assert_equal(54, 60 - 6)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1045 assert_equal(50, 60 -
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1046 g:anint)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1047 assert_equal(-1, g:thefour
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1048 - 5)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1049 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
1050
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1051 assert_equal('hello', 'hel' .. 'lo')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1052 assert_equal('hello 123', 'hello ' ..
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1053 123)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1054 assert_equal('hello 123', 'hello '
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1055 .. 123)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1056 assert_equal('123 hello', 123 .. ' hello')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1057 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
1058
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1059 assert_equal('av:true', 'a' .. true)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1060 assert_equal('av:false', 'a' .. false)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1061 assert_equal('av:null', 'a' .. v:null)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1062 assert_equal('av:none', 'a' .. v:none)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1063 if has('float')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1064 assert_equal('a0.123', 'a' .. 0.123)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1065 endif
21771
fcf978444298 patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents: 21769
diff changeset
1066
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1067 assert_equal([1, 2, 3, 4], [1, 2] + [3, 4])
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1068 assert_equal(0z11223344, 0z1122 + 0z3344)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1069 assert_equal(0z112201ab, 0z1122
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1070 + g:ablob)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1071 assert_equal(0z01ab3344, g:ablob + 0z3344)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1072 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
1073
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1074 # concatenate non-constant to constant
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1075 var save_path = &path
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1076 &path = 'b'
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1077 assert_equal('ab', 'a' .. &path)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1078 &path = save_path
21903
1fc2ffadf412 patch 8.2.1501: Vim9: concatenating to constant reverses order
Bram Moolenaar <Bram@vim.org>
parents: 21865
diff changeset
1079
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1080 @b = 'b'
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1081 assert_equal('ab', 'a' .. @b)
21903
1fc2ffadf412 patch 8.2.1501: Vim9: concatenating to constant reverses order
Bram Moolenaar <Bram@vim.org>
parents: 21865
diff changeset
1082
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1083 $ENVVAR = 'env'
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1084 assert_equal('aenv', 'a' .. $ENVVAR)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1085 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1086 CheckDefAndScriptSuccess(lines)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1087 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1088
20992
7ee565134d4a patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents: 20988
diff changeset
1089 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
1090 # 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
1091 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
1092 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
1093 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
1094 + 77
7ee565134d4a patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents: 20988
diff changeset
1095 - 22
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
1096 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
1097 END
7ee565134d4a patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents: 20988
diff changeset
1098 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
1099
7ee565134d4a patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents: 20988
diff changeset
1100 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
1101 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
1102 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
1103 77 -
3a86e41fdffd patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21630
diff changeset
1104 22
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
1105 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
1106 END
3a86e41fdffd patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21630
diff changeset
1107 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
1108
3a86e41fdffd patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21630
diff changeset
1109 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
1110 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
1111 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
1112 77 -
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
1113 # comment
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
1114 22
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
1115 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
1116 END
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
1117 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
1118
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
1119 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
1120 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
1121 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
1122 .. 'two'
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
1123 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
1124 END
7ee565134d4a patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents: 20988
diff changeset
1125 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
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
22681
674ba3200e1f patch 8.2.1889: Vim9: errornous error for missing white space after {}
Bram Moolenaar <Bram@vim.org>
parents: 22639
diff changeset
1135 echo {} - 22
674ba3200e1f patch 8.2.1889: Vim9: errornous error for missing white space after {}
Bram Moolenaar <Bram@vim.org>
parents: 22639
diff changeset
1136 END
22683
5cbcd3768125 patch 8.2.1890: Vim9: strange error for subtracting from a list
Bram Moolenaar <Bram@vim.org>
parents: 22681
diff changeset
1137 CheckScriptFailure(lines, 'E728:', 2)
5cbcd3768125 patch 8.2.1890: Vim9: strange error for subtracting from a list
Bram Moolenaar <Bram@vim.org>
parents: 22681
diff changeset
1138
5cbcd3768125 patch 8.2.1890: Vim9: strange error for subtracting from a list
Bram Moolenaar <Bram@vim.org>
parents: 22681
diff changeset
1139 lines =<< trim END
5cbcd3768125 patch 8.2.1890: Vim9: strange error for subtracting from a list
Bram Moolenaar <Bram@vim.org>
parents: 22681
diff changeset
1140 vim9script
5cbcd3768125 patch 8.2.1890: Vim9: strange error for subtracting from a list
Bram Moolenaar <Bram@vim.org>
parents: 22681
diff changeset
1141 echo [] - 33
5cbcd3768125 patch 8.2.1890: Vim9: strange error for subtracting from a list
Bram Moolenaar <Bram@vim.org>
parents: 22681
diff changeset
1142 END
5cbcd3768125 patch 8.2.1890: Vim9: strange error for subtracting from a list
Bram Moolenaar <Bram@vim.org>
parents: 22681
diff changeset
1143 CheckScriptFailure(lines, 'E745:', 2)
5cbcd3768125 patch 8.2.1890: Vim9: strange error for subtracting from a list
Bram Moolenaar <Bram@vim.org>
parents: 22681
diff changeset
1144
5cbcd3768125 patch 8.2.1890: Vim9: strange error for subtracting from a list
Bram Moolenaar <Bram@vim.org>
parents: 22681
diff changeset
1145 lines =<< trim END
5cbcd3768125 patch 8.2.1890: Vim9: strange error for subtracting from a list
Bram Moolenaar <Bram@vim.org>
parents: 22681
diff changeset
1146 vim9script
5cbcd3768125 patch 8.2.1890: Vim9: strange error for subtracting from a list
Bram Moolenaar <Bram@vim.org>
parents: 22681
diff changeset
1147 echo 0z1234 - 44
5cbcd3768125 patch 8.2.1890: Vim9: strange error for subtracting from a list
Bram Moolenaar <Bram@vim.org>
parents: 22681
diff changeset
1148 END
5cbcd3768125 patch 8.2.1890: Vim9: strange error for subtracting from a list
Bram Moolenaar <Bram@vim.org>
parents: 22681
diff changeset
1149 CheckScriptFailure(lines, 'E974:', 2)
22681
674ba3200e1f patch 8.2.1889: Vim9: errornous error for missing white space after {}
Bram Moolenaar <Bram@vim.org>
parents: 22639
diff changeset
1150
674ba3200e1f patch 8.2.1889: Vim9: errornous error for missing white space after {}
Bram Moolenaar <Bram@vim.org>
parents: 22639
diff changeset
1151 lines =<< trim END
674ba3200e1f patch 8.2.1889: Vim9: errornous error for missing white space after {}
Bram Moolenaar <Bram@vim.org>
parents: 22639
diff changeset
1152 vim9script
21546
4d3e983313dc patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21544
diff changeset
1153 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
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, '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
1156
4d3e983313dc patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21544
diff changeset
1157 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
1158 vim9script
4d3e983313dc patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21544
diff changeset
1159 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
1160 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
1161 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
1162
4d3e983313dc patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21544
diff changeset
1163 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
1164 vim9script
4d3e983313dc patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21544
diff changeset
1165 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
1166 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
1167 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
1168
3c6c52fbc8ea patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21614
diff changeset
1169 # 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
1170 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
1171 vim9script
3c6c52fbc8ea patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21614
diff changeset
1172 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
1173 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
1174 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
1175 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
1176 vim9script
3c6c52fbc8ea patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21614
diff changeset
1177 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
1178 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
1179 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
1180 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
1181 vim9script
3c6c52fbc8ea patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21614
diff changeset
1182 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
1183 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
1184 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
1185
3c6c52fbc8ea patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21614
diff changeset
1186 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
1187 vim9script
3c6c52fbc8ea patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21614
diff changeset
1188 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
1189 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
1190 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
1191 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
1192 vim9script
3c6c52fbc8ea patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21614
diff changeset
1193 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
1194 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
1195 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
1196 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
1197 vim9script
3c6c52fbc8ea patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21614
diff changeset
1198 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
1199 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
1200 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
1201
fcf978444298 patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents: 21769
diff changeset
1202 # 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
1203 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
1204 vim9script
fcf978444298 patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents: 21769
diff changeset
1205 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
1206 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
1207 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
1208 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
1209 vim9script
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
1210 echo 'a' .. {a: 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
1211 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
1212 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
1213 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
1214 vim9script
fcf978444298 patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents: 21769
diff changeset
1215 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
1216 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
1217 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
1218 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
1219 vim9script
fcf978444298 patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents: 21769
diff changeset
1220 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
1221 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
1222 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
1223 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
1224 vim9script
fcf978444298 patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents: 21769
diff changeset
1225 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
1226 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
1227 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
1228 enddef
11dbf7e1f65c patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents: 21959
diff changeset
1229
11dbf7e1f65c patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents: 21959
diff changeset
1230 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
1231 if !has('channel')
11dbf7e1f65c patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents: 21959
diff changeset
1232 MissingFeature 'float'
11dbf7e1f65c patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents: 21959
diff changeset
1233 else
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1234 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
1235 vim9script
11dbf7e1f65c patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents: 21959
diff changeset
1236 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
1237 END
11dbf7e1f65c patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents: 21959
diff changeset
1238 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
1239 lines =<< trim END
11dbf7e1f65c patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents: 21959
diff changeset
1240 vim9script
11dbf7e1f65c patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents: 21959
diff changeset
1241 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
1242 END
11dbf7e1f65c patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents: 21959
diff changeset
1243 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
1244 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
1245 enddef
7ee565134d4a patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents: 20988
diff changeset
1246
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1247 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
1248 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
1249 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
1250 else
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1251 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1252 assert_equal(66.0, 60.0 + 6.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1253 assert_equal(66.0, 60.0 + 6)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1254 assert_equal(66.0, 60 +
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1255 6.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1256 assert_equal(5.1, g:afloat
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1257 + 5)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1258 assert_equal(8.1, 8 + g:afloat)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1259 assert_equal(10.1, g:anint + g:afloat)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1260 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
1261
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1262 assert_equal(54.0, 60.0 - 6.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1263 assert_equal(54.0, 60.0
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1264 - 6)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1265 assert_equal(54.0, 60 - 6.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1266 assert_equal(-4.9, g:afloat - 5)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1267 assert_equal(7.9, 8 - g:afloat)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1268 assert_equal(9.9, g:anint - g:afloat)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1269 assert_equal(-9.9, g:afloat - g:anint)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1270 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1271 CheckDefAndScriptSuccess(lines)
19259
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
1272 endif
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1273 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1274
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1275 func Test_expr5_fails()
22296
006b8ab9d554 patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents: 22284
diff changeset
1276 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
1277 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
1278 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
1279 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
1280
22296
006b8ab9d554 patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents: 22284
diff changeset
1281 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
1282 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
1283 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
1284 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
1285
22296
006b8ab9d554 patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents: 22284
diff changeset
1286 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
1287 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
1288 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
1289 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
1290
22836
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
1291 call CheckDefFailure(["var x = 0z1122 + 33"], 'E1051:', 1)
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
1292 call CheckDefFailure(["var x = 0z1122 + [3]"], 'E1051:', 1)
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
1293 call CheckDefFailure(["var x = 0z1122 + 'asd'"], 'E1051:', 1)
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
1294 call CheckDefFailure(["var x = 33 + 0z1122"], 'E1051:', 1)
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
1295 call CheckDefFailure(["var x = [3] + 0z1122"], 'E1051:', 1)
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
1296 call CheckDefFailure(["var x = 'asdf' + 0z1122"], 'E1051:', 1)
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
1297 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
1298
22836
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
1299 call CheckDefFailure(["var x = 'a' .. [1]"], 'E1105:', 1)
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
1300 call CheckDefFailure(["var x = 'a' .. {a: 1}"], 'E1105:', 1)
22836
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
1301 call CheckDefFailure(["var x = 'a' .. test_void()"], 'E1105:', 1)
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
1302 call CheckDefFailure(["var x = 'a' .. 0z32"], 'E1105:', 1)
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
1303 call CheckDefFailure(["var x = 'a' .. function('len')"], 'E1105:', 1)
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
1304 call CheckDefFailure(["var x = 'a' .. function('len', ['a'])"], 'E1105:', 1)
22930
84567584951f patch 8.2.2012: Vim9: confusing error message when using bool wrongly
Bram Moolenaar <Bram@vim.org>
parents: 22878
diff changeset
1305
84567584951f patch 8.2.2012: Vim9: confusing error message when using bool wrongly
Bram Moolenaar <Bram@vim.org>
parents: 22878
diff changeset
1306 call CheckScriptFailure(['vim9script', 'var x = 1 + v:none'], 'E611:', 2)
84567584951f patch 8.2.2012: Vim9: confusing error message when using bool wrongly
Bram Moolenaar <Bram@vim.org>
parents: 22878
diff changeset
1307 call CheckScriptFailure(['vim9script', 'var x = 1 + v:null'], 'E611:', 2)
84567584951f patch 8.2.2012: Vim9: confusing error message when using bool wrongly
Bram Moolenaar <Bram@vim.org>
parents: 22878
diff changeset
1308 call CheckScriptFailure(['vim9script', 'var x = 1 + v:true'], 'E1138:', 2)
84567584951f patch 8.2.2012: Vim9: confusing error message when using bool wrongly
Bram Moolenaar <Bram@vim.org>
parents: 22878
diff changeset
1309 call CheckScriptFailure(['vim9script', 'var x = 1 + v:false'], 'E1138:', 2)
84567584951f patch 8.2.2012: Vim9: confusing error message when using bool wrongly
Bram Moolenaar <Bram@vim.org>
parents: 22878
diff changeset
1310 call CheckScriptFailure(['vim9script', 'var x = 1 + true'], 'E1138:', 2)
84567584951f patch 8.2.2012: Vim9: confusing error message when using bool wrongly
Bram Moolenaar <Bram@vim.org>
parents: 22878
diff changeset
1311 call CheckScriptFailure(['vim9script', 'var x = 1 + false'], 'E1138:', 2)
22119
11dbf7e1f65c patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents: 21959
diff changeset
1312 endfunc
11dbf7e1f65c patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents: 21959
diff changeset
1313
11dbf7e1f65c patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents: 21959
diff changeset
1314 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
1315 CheckFeature channel
22836
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
1316 call CheckDefFailure(["var x = 'a' .. test_null_job()"], 'E1105:', 1)
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
1317 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
1318 endfunc
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1319
23199
59f31d2eb4cf patch 8.2.2145: Vim9: concatenating lists does not adjust type of result
Bram Moolenaar <Bram@vim.org>
parents: 23142
diff changeset
1320 def Test_expr5_list_add()
59f31d2eb4cf patch 8.2.2145: Vim9: concatenating lists does not adjust type of result
Bram Moolenaar <Bram@vim.org>
parents: 23142
diff changeset
1321 # concatenating two lists with same member types is OK
59f31d2eb4cf patch 8.2.2145: Vim9: concatenating lists does not adjust type of result
Bram Moolenaar <Bram@vim.org>
parents: 23142
diff changeset
1322 var d = {}
59f31d2eb4cf patch 8.2.2145: Vim9: concatenating lists does not adjust type of result
Bram Moolenaar <Bram@vim.org>
parents: 23142
diff changeset
1323 for i in ['a'] + ['b']
59f31d2eb4cf patch 8.2.2145: Vim9: concatenating lists does not adjust type of result
Bram Moolenaar <Bram@vim.org>
parents: 23142
diff changeset
1324 d = {[i]: 0}
59f31d2eb4cf patch 8.2.2145: Vim9: concatenating lists does not adjust type of result
Bram Moolenaar <Bram@vim.org>
parents: 23142
diff changeset
1325 endfor
59f31d2eb4cf patch 8.2.2145: Vim9: concatenating lists does not adjust type of result
Bram Moolenaar <Bram@vim.org>
parents: 23142
diff changeset
1326
59f31d2eb4cf patch 8.2.2145: Vim9: concatenating lists does not adjust type of result
Bram Moolenaar <Bram@vim.org>
parents: 23142
diff changeset
1327 # concatenating two lists with different member types results in "any"
59f31d2eb4cf patch 8.2.2145: Vim9: concatenating lists does not adjust type of result
Bram Moolenaar <Bram@vim.org>
parents: 23142
diff changeset
1328 var lines =<< trim END
59f31d2eb4cf patch 8.2.2145: Vim9: concatenating lists does not adjust type of result
Bram Moolenaar <Bram@vim.org>
parents: 23142
diff changeset
1329 var d = {}
59f31d2eb4cf patch 8.2.2145: Vim9: concatenating lists does not adjust type of result
Bram Moolenaar <Bram@vim.org>
parents: 23142
diff changeset
1330 for i in ['a'] + [0]
59f31d2eb4cf patch 8.2.2145: Vim9: concatenating lists does not adjust type of result
Bram Moolenaar <Bram@vim.org>
parents: 23142
diff changeset
1331 d = {[i]: 0}
59f31d2eb4cf patch 8.2.2145: Vim9: concatenating lists does not adjust type of result
Bram Moolenaar <Bram@vim.org>
parents: 23142
diff changeset
1332 endfor
59f31d2eb4cf patch 8.2.2145: Vim9: concatenating lists does not adjust type of result
Bram Moolenaar <Bram@vim.org>
parents: 23142
diff changeset
1333 END
59f31d2eb4cf patch 8.2.2145: Vim9: concatenating lists does not adjust type of result
Bram Moolenaar <Bram@vim.org>
parents: 23142
diff changeset
1334 CheckDefExecFailure(lines, 'E1012:')
59f31d2eb4cf patch 8.2.2145: Vim9: concatenating lists does not adjust type of result
Bram Moolenaar <Bram@vim.org>
parents: 23142
diff changeset
1335 enddef
59f31d2eb4cf patch 8.2.2145: Vim9: concatenating lists does not adjust type of result
Bram Moolenaar <Bram@vim.org>
parents: 23142
diff changeset
1336
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1337 " 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
1338 def Test_expr6()
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1339 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1340 assert_equal(36, 6 * 6)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1341 assert_equal(24, 6 *
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1342 g:thefour)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1343 assert_equal(24, g:thefour
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1344 * 6)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1345 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
1346
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1347 assert_equal(10, 60 / 6)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1348 assert_equal(6, 60 /
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1349 g:anint)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1350 assert_equal(1, g:anint / 6)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1351 assert_equal(2, g:anint
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1352 / g:thefour)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1353
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1354 assert_equal(5, 11 % 6)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1355 assert_equal(4, g:anint % 6)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1356 assert_equal(3, 13 %
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1357 g:anint)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1358 assert_equal(2, g:anint
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1359 % g:thefour)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1360
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1361 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
1362
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1363 var x = [2]
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1364 var y = [3]
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1365 assert_equal(5, x[0] + y[0])
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1366 assert_equal(6, x[0] * y[0])
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1367 if has('float')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1368 var xf = [2.0]
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1369 var yf = [3.0]
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1370 assert_equal(5.0, xf[0]
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1371 + yf[0])
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1372 assert_equal(6.0, xf[0]
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1373 * yf[0])
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1374 endif
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1375 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1376 CheckDefAndScriptSuccess(lines)
19856
90eec641cc8c patch 8.2.0484: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19854
diff changeset
1377
22836
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
1378 CheckDefFailure(["var x = 6 * xxx"], 'E1001:', 1)
23122
60a0221beab0 patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents: 23106
diff changeset
1379 CheckDefFailure(["var d = 6 * "], 'E1097:', 3)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1380 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1381
20992
7ee565134d4a patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents: 20988
diff changeset
1382 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
1383 # 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
1384 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
1385 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
1386 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
1387 * 22
7ee565134d4a patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents: 20988
diff changeset
1388 / 3
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
1389 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
1390 END
7ee565134d4a patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents: 20988
diff changeset
1391 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
1392
7ee565134d4a patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents: 20988
diff changeset
1393 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
1394 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
1395 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
1396 % 10
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
1397 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
1398 END
7ee565134d4a patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents: 20988
diff changeset
1399 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
1400
3a86e41fdffd patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21630
diff changeset
1401 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
1402 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
1403 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
1404 # comment
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
1405
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
1406 # comment
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
1407 % 10
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
1408 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
1409 END
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
1410 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
1411
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
1412 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
1413 vim9script
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
1414 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
1415 22 /
3a86e41fdffd patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21630
diff changeset
1416 3
22433
8b5e2f9580db patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents: 22421
diff changeset
1417 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
1418 END
3a86e41fdffd patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21630
diff changeset
1419 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
1420
3a86e41fdffd patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21630
diff changeset
1421 # 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
1422 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
1423 vim9script
3a86e41fdffd patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21630
diff changeset
1424 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
1425 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
1426 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
1427 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
1428 vim9script
3a86e41fdffd patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21630
diff changeset
1429 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
1430 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
1431 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
1432 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
1433 vim9script
3a86e41fdffd patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents: 21630
diff changeset
1434 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
1435 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
1436 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
1437 enddef
7ee565134d4a patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents: 20988
diff changeset
1438
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1439 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
1440 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
1441 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
1442 else
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1443 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1444 assert_equal(36.0, 6.0 * 6)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1445 assert_equal(36.0, 6 *
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1446 6.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1447 assert_equal(36.0, 6.0 * 6.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1448 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
1449
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1450 assert_equal(10.0, 60 / 6.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1451 assert_equal(10.0, 60.0 /
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1452 6)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1453 assert_equal(10.0, 60.0 / 6.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1454 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
1455
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1456 assert_equal(4.0, 6.0 * 4 / 6)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1457 assert_equal(4.0, 6 *
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1458 4.0 /
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1459 6)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1460 assert_equal(4.0, 6 * 4 / 6.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1461 assert_equal(4.0, 6.0 * 4.0 / 6)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1462 assert_equal(4.0, 6 * 4.0 / 6.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1463 assert_equal(4.0, 6.0 * 4 / 6.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1464 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
1465
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1466 assert_equal(4.0, 6.0 * 4.0 / 6.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1467 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1468 CheckDefAndScriptSuccess(lines)
19259
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
1469 endif
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1470 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1471
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1472 func Test_expr6_fails()
22296
006b8ab9d554 patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents: 22284
diff changeset
1473 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
1474 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
1475 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
1476 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
1477
22296
006b8ab9d554 patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents: 22284
diff changeset
1478 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
1479 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
1480 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
1481 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
1482
22296
006b8ab9d554 patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents: 22284
diff changeset
1483 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
1484 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
1485 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
1486 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
1487
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1488 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
1489 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
1490 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
1491
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1492 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
1493 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
1494 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
1495
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1496 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
1497 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
1498 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
1499
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
1500 call CheckDefFailure(["var x = {one: 1} * {two: 2}"], 'E1036:', 1)
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
1501 call CheckDefFailure(["var x = {one: 1} / {two: 2}"], 'E1036:', 1)
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
1502 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
1503
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1504 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
1505 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
1506 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
1507 endif
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1508 endfunc
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1509
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1510 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
1511 CheckFeature float
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1512 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
1513 endfunc
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1514
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1515 " 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
1516 if has('float')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1517 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
1518 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
1519 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
1520 endif
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1521 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
1522 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
1523 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
1524
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1525 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
1526 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
1527 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
1528 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
1529
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1530 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
1531 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
1532 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
1533 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
1534
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1535 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
1536 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
1537
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1538 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
1539 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
1540
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1541 let $TESTVAR = 'testvar'
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1542
21717
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21715
diff changeset
1543 " type casts
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21715
diff changeset
1544 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
1545 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
1546 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
1547 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
1548 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
1549
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1550 CheckDefFailure(["var x = <nr>123"], 'E1010:', 1)
23122
60a0221beab0 patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents: 23106
diff changeset
1551 CheckDefFailure(["var x = <number>"], 'E1097:', 3)
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 = <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
1553 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
1554 enddef
ef3b31d510d2 patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents: 21715
diff changeset
1555
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1556 " 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
1557 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
1558 # number constant
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1559 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1560 assert_equal(0, 0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1561 assert_equal(654, 0654)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1562
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1563 assert_equal(6, 0x6)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1564 assert_equal(15, 0xf)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1565 assert_equal(255, 0xff)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1566 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1567 CheckDefAndScriptSuccess(lines)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1568 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1569
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1570 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
1571 # 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
1572 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
1573 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
1574 else
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1575 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1576 assert_equal(g:float_zero, .0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1577 assert_equal(g:float_zero, 0.0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1578 assert_equal(g:float_neg, -9.8)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1579 assert_equal(g:float_big, 9.9e99)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1580 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1581 CheckDefAndScriptSuccess(lines)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1582 endif
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1583 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1584
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1585 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
1586 # blob constant
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1587 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1588 assert_equal(g:blob_empty, 0z)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1589 assert_equal(g:blob_one, 0z01)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1590 assert_equal(g:blob_long, 0z0102.0304)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1591 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1592 CheckDefAndScriptSuccess(lines)
19856
90eec641cc8c patch 8.2.0484: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19854
diff changeset
1593
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1594 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
1595 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1596
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1597 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
1598 # string constant
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1599 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1600 assert_equal(g:string_empty, '')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1601 assert_equal(g:string_empty, "")
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1602 assert_equal(g:string_short, 'x')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1603 assert_equal(g:string_short, "x")
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1604 assert_equal(g:string_long, 'abcdefghijklm')
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1605 assert_equal(g:string_long, "abcdefghijklm")
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1606 assert_equal(g:string_special, "ab\ncd\ref\ekk")
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1607 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1608 CheckDefAndScriptSuccess(lines)
19856
90eec641cc8c patch 8.2.0484: Vim9: some error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19854
diff changeset
1609
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1610 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
1611 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
1612 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1613
19960
3c11b9f6fa03 patch 8.2.0536: Vim9: some compilation code not tested
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1614 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
1615 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
1616 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
1617
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1618 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
1619 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
1620 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
1621 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
1622 bwipe!
19960
3c11b9f6fa03 patch 8.2.0536: Vim9: some compilation code not tested
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1623 enddef
3c11b9f6fa03 patch 8.2.0536: Vim9: some compilation code not tested
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1624
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1625 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
1626 # special constant
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1627 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1628 assert_equal(g:special_true, true)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1629 assert_equal(g:special_false, false)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1630 assert_equal(g:special_true, v:true)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1631 assert_equal(g:special_false, v:false)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1632 assert_equal(v:true, true)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1633 assert_equal(v:false, false)
21725
741c1d58d50f patch 8.2.1412: Vim: not operator does not result in boolean
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
1634
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1635 assert_equal(true, !false)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1636 assert_equal(false, !true)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1637 assert_equal(true, !0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1638 assert_equal(false, !1)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1639 assert_equal(false, !!false)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1640 assert_equal(true, !!true)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1641 assert_equal(false, !!0)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1642 assert_equal(true, !!1)
21725
741c1d58d50f patch 8.2.1412: Vim: not operator does not result in boolean
Bram Moolenaar <Bram@vim.org>
parents: 21717
diff changeset
1643
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1644 var t = true
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1645 var f = false
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1646 assert_equal(true, t)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1647 assert_equal(false, f)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1648
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1649 assert_equal(g:special_null, v:null)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1650 assert_equal(g:special_none, v:none)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1651 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1652 CheckDefAndScriptSuccess(lines)
19960
3c11b9f6fa03 patch 8.2.0536: Vim9: some compilation code not tested
Bram Moolenaar <Bram@vim.org>
parents: 19912
diff changeset
1653
22147
d55008685870 patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents: 22119
diff changeset
1654 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
1655 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
1656 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
1657 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
1658 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
1659 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1660
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1661 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
1662 # list
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1663 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1664 assert_equal(g:list_empty, [])
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1665 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
1666
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1667 var numbers: list<number> = [1, 2, 3]
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1668 numbers = [1]
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1669 numbers = []
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
1670
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1671 var strings: list<string> = ['a', 'b', 'c']
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1672 strings = ['x']
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1673 strings = []
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
1674
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1675 var mixed: list<any> = [1, 'b', false,]
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1676 assert_equal(g:list_mixed, mixed)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1677 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
1678
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1679 echo [1,
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1680 2] [3,
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1681 4]
21562
55aa283a0e5e patch 8.2.1331: Vim9: :echo with two lists doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 21546
diff changeset
1682
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1683 var llstring: list<list<string>> = [['text'], []]
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1684 llstring = [[], ['text']]
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1685 llstring = [[], []]
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1686 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1687 CheckDefAndScriptSuccess(lines)
22322
a5b16c9eee9d patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 22296
diff changeset
1688
22419
6a9e5c087c86 patch 8.2.1758: Vim9: type of unmaterialized list is wrong
Bram Moolenaar <Bram@vim.org>
parents: 22351
diff changeset
1689 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
1690 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
1691 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
1692
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1693 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
1694 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
1695
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1696 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
1697
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1698 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
1699 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
1700
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1701 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
1702
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1703 CheckDefExecFailure(["var x = g:list_mixed['xx']"], 'E1012:', 1)
23122
60a0221beab0 patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents: 23106
diff changeset
1704 CheckDefFailure(["var x = g:list_mixed["], 'E1097:', 3)
60a0221beab0 patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents: 23106
diff changeset
1705 CheckDefFailure(["var x = g:list_mixed[0"], 'E1097:', 3)
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1706 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
1707 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
1708 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
1709 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
1710 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
1711
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1712 lines =<< trim END
22482
a1b3804163ca patch 8.2.1789: Vim9: crash with invalid list constant
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1713 vim9script
a1b3804163ca patch 8.2.1789: Vim9: crash with invalid list constant
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1714 var datalist: list<string>
a1b3804163ca patch 8.2.1789: Vim9: crash with invalid list constant
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1715 def Main()
a1b3804163ca patch 8.2.1789: Vim9: crash with invalid list constant
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1716 datalist += ['x'.
a1b3804163ca patch 8.2.1789: Vim9: crash with invalid list constant
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1717 enddef
a1b3804163ca patch 8.2.1789: Vim9: crash with invalid list constant
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1718 Main()
a1b3804163ca patch 8.2.1789: Vim9: crash with invalid list constant
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1719 END
a1b3804163ca patch 8.2.1789: Vim9: crash with invalid list constant
Bram Moolenaar <Bram@vim.org>
parents: 22435
diff changeset
1720 CheckScriptFailure(lines, 'E1127:')
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
1721
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
1722 lines =<< trim END
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
1723 var numbers = [1, 2, 3, 4]
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
1724 var a = 1
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
1725 var b = 2
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
1726 END
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
1727 CheckDefAndScriptFailure(lines + ['echo numbers[1:b]'], 'E1004:', 4)
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
1728 CheckDefAndScriptFailure(lines + ['echo numbers[1: b]'], 'E1004:', 4)
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
1729 CheckDefAndScriptFailure(lines + ['echo numbers[a :b]'], 'E1004:', 4)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1730 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1731
21028
7acceb76669f patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents: 21026
diff changeset
1732 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
1733 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
1734 vim9script
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1735 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
1736 11,
7acceb76669f patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents: 21026
diff changeset
1737 22,
7acceb76669f patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents: 21026
diff changeset
1738 ]
7acceb76669f patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents: 21026
diff changeset
1739 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
1740
55aa283a0e5e patch 8.2.1331: Vim9: :echo with two lists doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 21546
diff changeset
1741 echo [1,
55aa283a0e5e patch 8.2.1331: Vim9: :echo with two lists doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 21546
diff changeset
1742 2] [3,
55aa283a0e5e patch 8.2.1331: Vim9: :echo with two lists doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 21546
diff changeset
1743 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
1744
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
1745 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
1746 # comment
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
1747 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
1748 # comment
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
1749 4]
21028
7acceb76669f patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents: 21026
diff changeset
1750 END
7acceb76669f patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents: 21026
diff changeset
1751 CheckScriptSuccess(lines)
7acceb76669f patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents: 21026
diff changeset
1752
7acceb76669f patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents: 21026
diff changeset
1753 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
1754 vim9script
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1755 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
1756 22]
7acceb76669f patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents: 21026
diff changeset
1757 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
1758 END
7acceb76669f patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents: 21026
diff changeset
1759 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
1760
2f8b0812819f patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents: 21032
diff changeset
1761 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
1762 vim9script
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1763 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
1764 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
1765 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
1766
5a2373c25a86 patch 8.2.1430: Vim9: error for missing comma instead of extra white space
Bram Moolenaar <Bram@vim.org>
parents: 21759
diff changeset
1767 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
1768 vim9script
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1769 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
1770 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
1771 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
1772
e591b448a670 patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents: 21771
diff changeset
1773 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
1774 vim9script
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1775 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
1776 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
1777 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
1778 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
1779 vim9script
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1780 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
1781 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
1782 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
1783 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
1784 vim9script
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1785 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
1786 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
1787 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
1788 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
1789 vim9script
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1790 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
1791 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
1792 CheckScriptFailure(lines, 'E1012:', 2)
22804
af26fadf333d patch 8.2.1950: Vim9: crash when compiling function fails when getting type
Bram Moolenaar <Bram@vim.org>
parents: 22752
diff changeset
1793
af26fadf333d patch 8.2.1950: Vim9: crash when compiling function fails when getting type
Bram Moolenaar <Bram@vim.org>
parents: 22752
diff changeset
1794 lines =<< trim END
af26fadf333d patch 8.2.1950: Vim9: crash when compiling function fails when getting type
Bram Moolenaar <Bram@vim.org>
parents: 22752
diff changeset
1795 vim9script
af26fadf333d patch 8.2.1950: Vim9: crash when compiling function fails when getting type
Bram Moolenaar <Bram@vim.org>
parents: 22752
diff changeset
1796 def Failing()
af26fadf333d patch 8.2.1950: Vim9: crash when compiling function fails when getting type
Bram Moolenaar <Bram@vim.org>
parents: 22752
diff changeset
1797 job_stop()
af26fadf333d patch 8.2.1950: Vim9: crash when compiling function fails when getting type
Bram Moolenaar <Bram@vim.org>
parents: 22752
diff changeset
1798 enddef
af26fadf333d patch 8.2.1950: Vim9: crash when compiling function fails when getting type
Bram Moolenaar <Bram@vim.org>
parents: 22752
diff changeset
1799 var list = [Failing]
af26fadf333d patch 8.2.1950: Vim9: crash when compiling function fails when getting type
Bram Moolenaar <Bram@vim.org>
parents: 22752
diff changeset
1800 END
22836
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
1801 if has('channel')
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
1802 CheckScriptFailure(lines, 'E119:', 1)
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
1803 else
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
1804 CheckScriptFailure(lines, 'E117:', 1)
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
1805 endif
21028
7acceb76669f patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents: 21026
diff changeset
1806 enddef
7acceb76669f patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents: 21026
diff changeset
1807
21767
9529a2367d3e patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1808 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
1809 return {x ->
9529a2367d3e patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1810 # some comment
9529a2367d3e patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1811 x == 1
9529a2367d3e patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1812 # some comment
9529a2367d3e patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1813 ||
9529a2367d3e patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1814 x == 2
9529a2367d3e patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1815 }
9529a2367d3e patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1816 enddef
9529a2367d3e patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1817
21769
f37c1330b15c patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents: 21767
diff changeset
1818 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
1819 return {->
f37c1330b15c patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents: 21767
diff changeset
1820 # some comment
f37c1330b15c patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents: 21767
diff changeset
1821 x == 1
f37c1330b15c patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents: 21767
diff changeset
1822 # some comment
f37c1330b15c patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents: 21767
diff changeset
1823 ||
f37c1330b15c patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents: 21767
diff changeset
1824 x == 2
f37c1330b15c patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents: 21767
diff changeset
1825 }
f37c1330b15c patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents: 21767
diff changeset
1826 enddef
f37c1330b15c patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents: 21767
diff changeset
1827
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1828 def Test_expr7_lambda()
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1829 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1830 var La = { -> 'result'}
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1831 assert_equal('result', La())
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1832 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
1833
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1834 # line continuation inside lambda with "cond ? expr : expr" works
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1835 var ll = range(3)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1836 map(ll, {k, v -> v % 2 ? {
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
1837 ['111']: 111 } : {}
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1838 })
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
1839 assert_equal([{}, {111: 111}, {}], ll)
21277
1e5c29d4e5b3 patch 8.2.1189: Vim9: line continuation in lambda doesn't always work
Bram Moolenaar <Bram@vim.org>
parents: 21263
diff changeset
1840
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1841 ll = range(3)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1842 map(ll, {k, v -> v == 8 || v
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1843 == 9
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1844 || v % 2 ? 111 : 222
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1845 })
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1846 assert_equal([222, 111, 222], ll)
21277
1e5c29d4e5b3 patch 8.2.1189: Vim9: line continuation in lambda doesn't always work
Bram Moolenaar <Bram@vim.org>
parents: 21263
diff changeset
1847
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1848 ll = range(3)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1849 map(ll, {k, v -> v != 8 && v
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1850 != 9
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1851 && v % 2 == 0 ? 111 : 222
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1852 })
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1853 assert_equal([111, 222, 111], ll)
21277
1e5c29d4e5b3 patch 8.2.1189: Vim9: line continuation in lambda doesn't always work
Bram Moolenaar <Bram@vim.org>
parents: 21263
diff changeset
1854
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
1855 var dl = [{key: 0}, {key: 22}]->filter({ _, v -> v['key'] })
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
1856 assert_equal([{key: 22}], dl)
21387
8d58cbb07a12 patch 8.2.1244: Vim9: in lambda index assumes a list
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1857
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
1858 dl = [{key: 12}, {['foo']: 34}]
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
1859 assert_equal([{key: 12}], filter(dl,
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1860 {_, v -> has_key(v, 'key') ? v['key'] == 12 : 0}))
21411
e1aeb986712f patch 8.2.1256: Vim9: type wrong after getting dict item in lambda
Bram Moolenaar <Bram@vim.org>
parents: 21399
diff changeset
1861
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1862 assert_equal(false, LambdaWithComments()(0))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1863 assert_equal(true, LambdaWithComments()(1))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1864 assert_equal(true, LambdaWithComments()(2))
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1865 assert_equal(false, LambdaWithComments()(3))
21767
9529a2367d3e patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1866
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1867 assert_equal(false, LambdaUsingArg(0)())
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1868 assert_equal(true, LambdaUsingArg(1)())
23013
a0a998d2e443 patch 8.2.2053: Vim9: lamba doesn't accept argument types
Bram Moolenaar <Bram@vim.org>
parents: 22936
diff changeset
1869
a0a998d2e443 patch 8.2.2053: Vim9: lamba doesn't accept argument types
Bram Moolenaar <Bram@vim.org>
parents: 22936
diff changeset
1870 var res = map([1, 2, 3], {i: number, v: number -> i + v})
a0a998d2e443 patch 8.2.2053: Vim9: lamba doesn't accept argument types
Bram Moolenaar <Bram@vim.org>
parents: 22936
diff changeset
1871 assert_equal([1, 3, 5], res)
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1872 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
1873 CheckDefAndScriptSuccess(lines)
21769
f37c1330b15c patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents: 21767
diff changeset
1874
23368
a7cbdb9294c4 patch 8.2.2227: Vim9: recognizing lambda is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 23352
diff changeset
1875 CheckDefFailure(["var Ref = {a->a + 1}"], 'E1004:')
a7cbdb9294c4 patch 8.2.2227: Vim9: recognizing lambda is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 23352
diff changeset
1876 CheckDefFailure(["var Ref = {a-> a + 1}"], 'E1004:')
a7cbdb9294c4 patch 8.2.2227: Vim9: recognizing lambda is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 23352
diff changeset
1877 CheckDefFailure(["var Ref = {a ->a + 1}"], 'E1004:')
23310
7951c5098e8e patch 8.2.2200: Vim9: lambda without white space around -> is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23201
diff changeset
1878
22147
d55008685870 patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents: 22119
diff changeset
1879 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
1880 # 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
1881 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
1882
15ed135796fd patch 8.2.1454: Vim9: failure invoking lambda with wrong arguments
Bram Moolenaar <Bram@vim.org>
parents: 21807
diff changeset
1883 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
1884
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
1885 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
1886 '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
1887 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
1888 '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
1889 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
1890
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
1891 CheckDefSuccess(['var Fx = {a -> {k1: 0,', ' k2: 1}}'])
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
1892 CheckDefFailure(['var Fx = {a -> {k1: 0', ' k2: 1}}'], 'E722:', 2)
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
1893 CheckDefFailure(['var Fx = {a -> {k1: 0,', ' k2 1}}'], 'E720:', 2)
22625
0afa30d6dc72 patch 8.2.1861: Vim9: no specific error when parsing lambda fails
Bram Moolenaar <Bram@vim.org>
parents: 22606
diff changeset
1894
0afa30d6dc72 patch 8.2.1861: Vim9: no specific error when parsing lambda fails
Bram Moolenaar <Bram@vim.org>
parents: 22606
diff changeset
1895 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
1896 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
1897 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1898
23318
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1899 def NewLambdaWithComments(): func
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1900 return (x) =>
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1901 # some comment
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1902 x == 1
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1903 # some comment
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1904 ||
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1905 x == 2
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1906 enddef
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1907
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1908 def NewLambdaUsingArg(x: number): func
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1909 return () =>
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1910 # some comment
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1911 x == 1
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1912 # some comment
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1913 ||
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1914 x == 2
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1915 enddef
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1916
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1917 def Test_expr7_new_lambda()
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1918 var lines =<< trim END
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1919 var La = () => 'result'
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1920 assert_equal('result', La())
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1921 assert_equal([1, 3, 5], [1, 2, 3]->map((key, val) => key + val))
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1922
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1923 # line continuation inside lambda with "cond ? expr : expr" works
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1924 var ll = range(3)
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1925 map(ll, (k, v) => v % 2 ? {
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1926 ['111']: 111 } : {}
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1927 )
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1928 assert_equal([{}, {111: 111}, {}], ll)
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1929
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1930 ll = range(3)
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1931 map(ll, (k, v) => v == 8 || v
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1932 == 9
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1933 || v % 2 ? 111 : 222
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1934 )
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1935 assert_equal([222, 111, 222], ll)
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1936
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1937 ll = range(3)
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1938 map(ll, (k, v) => v != 8 && v
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1939 != 9
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1940 && v % 2 == 0 ? 111 : 222
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1941 )
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1942 assert_equal([111, 222, 111], ll)
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1943
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1944 var dl = [{key: 0}, {key: 22}]->filter(( _, v) => v['key'] )
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1945 assert_equal([{key: 22}], dl)
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1946
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1947 dl = [{key: 12}, {['foo']: 34}]
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1948 assert_equal([{key: 12}], filter(dl,
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1949 (_, v) => has_key(v, 'key') ? v['key'] == 12 : 0))
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1950
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1951 assert_equal(false, NewLambdaWithComments()(0))
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1952 assert_equal(true, NewLambdaWithComments()(1))
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1953 assert_equal(true, NewLambdaWithComments()(2))
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1954 assert_equal(false, NewLambdaWithComments()(3))
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1955
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1956 assert_equal(false, NewLambdaUsingArg(0)())
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1957 assert_equal(true, NewLambdaUsingArg(1)())
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1958
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1959 var res = map([1, 2, 3], (i: number, v: number) => i + v)
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1960 assert_equal([1, 3, 5], res)
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1961
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1962 # Lambda returning a dict
23332
cdb706d5c43d patch 8.2.2209: Vim9: return type of => lambda not parsed
Bram Moolenaar <Bram@vim.org>
parents: 23318
diff changeset
1963 var Lmb = () => ({key: 42})
23318
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1964 assert_equal({key: 42}, Lmb())
23338
9c5275b1c763 patch 8.2.2212: Vim9: lambda with => does not work at the script level
Bram Moolenaar <Bram@vim.org>
parents: 23332
diff changeset
1965
9c5275b1c763 patch 8.2.2212: Vim9: lambda with => does not work at the script level
Bram Moolenaar <Bram@vim.org>
parents: 23332
diff changeset
1966 var RefOne: func(number): string = (a: number): string => 'x'
9c5275b1c763 patch 8.2.2212: Vim9: lambda with => does not work at the script level
Bram Moolenaar <Bram@vim.org>
parents: 23332
diff changeset
1967 var RefTwo: func(number): any = (a: number): any => 'x'
9c5275b1c763 patch 8.2.2212: Vim9: lambda with => does not work at the script level
Bram Moolenaar <Bram@vim.org>
parents: 23332
diff changeset
1968
9c5275b1c763 patch 8.2.2212: Vim9: lambda with => does not work at the script level
Bram Moolenaar <Bram@vim.org>
parents: 23332
diff changeset
1969 var Fx = (a) => ({k1: 0,
9c5275b1c763 patch 8.2.2212: Vim9: lambda with => does not work at the script level
Bram Moolenaar <Bram@vim.org>
parents: 23332
diff changeset
1970 k2: 1})
9c5275b1c763 patch 8.2.2212: Vim9: lambda with => does not work at the script level
Bram Moolenaar <Bram@vim.org>
parents: 23332
diff changeset
1971 var Fy = (a) => [0,
9c5275b1c763 patch 8.2.2212: Vim9: lambda with => does not work at the script level
Bram Moolenaar <Bram@vim.org>
parents: 23332
diff changeset
1972 1]
23318
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1973 END
23338
9c5275b1c763 patch 8.2.2212: Vim9: lambda with => does not work at the script level
Bram Moolenaar <Bram@vim.org>
parents: 23332
diff changeset
1974 CheckDefAndScriptSuccess(lines)
23318
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1975
23368
a7cbdb9294c4 patch 8.2.2227: Vim9: recognizing lambda is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 23352
diff changeset
1976 CheckDefAndScriptFailure(["var Ref = (a)=>a + 1"], 'E1004:')
a7cbdb9294c4 patch 8.2.2227: Vim9: recognizing lambda is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 23352
diff changeset
1977 CheckDefAndScriptFailure(["var Ref = (a)=> a + 1"], 'E1004:')
a7cbdb9294c4 patch 8.2.2227: Vim9: recognizing lambda is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 23352
diff changeset
1978 CheckDefAndScriptFailure(["var Ref = (a) =>a + 1"], 'E1004:')
23338
9c5275b1c763 patch 8.2.2212: Vim9: lambda with => does not work at the script level
Bram Moolenaar <Bram@vim.org>
parents: 23332
diff changeset
1979
23332
cdb706d5c43d patch 8.2.2209: Vim9: return type of => lambda not parsed
Bram Moolenaar <Bram@vim.org>
parents: 23318
diff changeset
1980 CheckDefFailure(["var Ref: func(number): number = (a: number): string => 'x'"], 'E1012:')
cdb706d5c43d patch 8.2.2209: Vim9: return type of => lambda not parsed
Bram Moolenaar <Bram@vim.org>
parents: 23318
diff changeset
1981 CheckDefFailure(["var Ref: func(number): string = (a: number): string => 99"], 'E1012:')
cdb706d5c43d patch 8.2.2209: Vim9: return type of => lambda not parsed
Bram Moolenaar <Bram@vim.org>
parents: 23318
diff changeset
1982
23318
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1983 CheckDefFailure(["filter([1, 2], (k,v) => 1)"], 'E1069:', 1)
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1984 # error is in first line of the lambda
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1985 CheckDefFailure(["var L = (a) -> a + b"], 'E1001:', 1)
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1986
23332
cdb706d5c43d patch 8.2.2209: Vim9: return type of => lambda not parsed
Bram Moolenaar <Bram@vim.org>
parents: 23318
diff changeset
1987 # TODO: ->(lambda)() doesn't work yet
23318
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1988 # assert_equal('xxxyyy', 'xxx'->((a, b) => a .. b)('yyy'))
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1989
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1990 # CheckDefExecFailure(["var s = 'asdf'->{a -> a}('x')"],
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1991 # 'E1106: One argument too many')
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1992 # CheckDefExecFailure(["var s = 'asdf'->{a -> a}('x', 'y')"],
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1993 # 'E1106: 2 arguments too many')
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1994 # CheckDefFailure(["echo 'asdf'->{a -> a}(x)"], 'E1001:', 1)
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1995
23332
cdb706d5c43d patch 8.2.2209: Vim9: return type of => lambda not parsed
Bram Moolenaar <Bram@vim.org>
parents: 23318
diff changeset
1996 CheckDefFailure(['var Fx = (a) => ({k1: 0', ' k2: 1})'], 'E722:', 2)
cdb706d5c43d patch 8.2.2209: Vim9: return type of => lambda not parsed
Bram Moolenaar <Bram@vim.org>
parents: 23318
diff changeset
1997 CheckDefFailure(['var Fx = (a) => ({k1: 0,', ' k2 1})'], 'E720:', 2)
23318
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1998
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
1999 CheckDefFailure(['var Fx = (a) => [0', ' 1]'], 'E696:', 2)
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
2000 enddef
c76240efdf02 patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents: 23310
diff changeset
2001
21040
d9e0db9b2b99 patch 8.2.1071: Vim9: no line break allowed inside a lambda
Bram Moolenaar <Bram@vim.org>
parents: 21034
diff changeset
2002 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
2003 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
2004 vim9script
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
2005 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
2006 a
d9e0db9b2b99 patch 8.2.1071: Vim9: no line break allowed inside a lambda
Bram Moolenaar <Bram@vim.org>
parents: 21034
diff changeset
2007 + 2
d9e0db9b2b99 patch 8.2.1071: Vim9: no line break allowed inside a lambda
Bram Moolenaar <Bram@vim.org>
parents: 21034
diff changeset
2008 }()
d9e0db9b2b99 patch 8.2.1071: Vim9: no line break allowed inside a lambda
Bram Moolenaar <Bram@vim.org>
parents: 21034
diff changeset
2009 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
2010 END
d9e0db9b2b99 patch 8.2.1071: Vim9: no line break allowed inside a lambda
Bram Moolenaar <Bram@vim.org>
parents: 21034
diff changeset
2011 CheckScriptSuccess(lines)
21865
c16af87df654 patch 8.2.1482: Vim9: crash when using a nested lambda
Bram Moolenaar <Bram@vim.org>
parents: 21863
diff changeset
2012
c16af87df654 patch 8.2.1482: Vim9: crash when using a nested lambda
Bram Moolenaar <Bram@vim.org>
parents: 21863
diff changeset
2013 # 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
2014 lines =<< trim END
c16af87df654 patch 8.2.1482: Vim9: crash when using a nested lambda
Bram Moolenaar <Bram@vim.org>
parents: 21863
diff changeset
2015 vim9script
c16af87df654 patch 8.2.1482: Vim9: crash when using a nested lambda
Bram Moolenaar <Bram@vim.org>
parents: 21863
diff changeset
2016 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
2017 synstack('.', col('.'))
c16af87df654 patch 8.2.1482: Vim9: crash when using a nested lambda
Bram Moolenaar <Bram@vim.org>
parents: 21863
diff changeset
2018 ->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
2019 END
c16af87df654 patch 8.2.1482: Vim9: crash when using a nested lambda
Bram Moolenaar <Bram@vim.org>
parents: 21863
diff changeset
2020 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
2021 enddef
d9e0db9b2b99 patch 8.2.1071: Vim9: no line break allowed inside a lambda
Bram Moolenaar <Bram@vim.org>
parents: 21034
diff changeset
2022
21955
3991a6df522e patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents: 21925
diff changeset
2023 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
2024 var lines =<< trim END
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
2025 def RetNumber(): number
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
2026 return 123
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
2027 enddef
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
2028 var FuncRef = RetNumber
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
2029 assert_equal(123, FuncRef())
21955
3991a6df522e patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents: 21925
diff changeset
2030 END
3991a6df522e patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents: 21925
diff changeset
2031 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
2032 enddef
3991a6df522e patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents: 21925
diff changeset
2033
22936
00b0275ffe7f patch 8.2.2015: Vim9: literal dict #{} is not like any other language
Bram Moolenaar <Bram@vim.org>
parents: 22932
diff changeset
2034 let g:test_space_dict = {'': 'empty', ' ': 'space'}
00b0275ffe7f patch 8.2.2015: Vim9: literal dict #{} is not like any other language
Bram Moolenaar <Bram@vim.org>
parents: 22932
diff changeset
2035 let g:test_hash_dict = #{one: 1, two: 2}
00b0275ffe7f patch 8.2.2015: Vim9: literal dict #{} is not like any other language
Bram Moolenaar <Bram@vim.org>
parents: 22932
diff changeset
2036
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2037 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
2038 # dictionary
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
2039 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
2040 assert_equal(g:dict_empty, {})
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
2041 assert_equal(g:dict_empty, { })
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2042 assert_equal(g:dict_one, {['one']: 1})
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
2043 var key = 'one'
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
2044 var val = 1
22936
00b0275ffe7f patch 8.2.2015: Vim9: literal dict #{} is not like any other language
Bram Moolenaar <Bram@vim.org>
parents: 22932
diff changeset
2045 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
2046
22936
00b0275ffe7f patch 8.2.2015: Vim9: literal dict #{} is not like any other language
Bram Moolenaar <Bram@vim.org>
parents: 22932
diff changeset
2047 var numbers: dict<number> = {a: 1, b: 2, c: 3}
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2048 numbers = {a: 1}
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2049 numbers = {}
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
2050
22936
00b0275ffe7f patch 8.2.2015: Vim9: literal dict #{} is not like any other language
Bram Moolenaar <Bram@vim.org>
parents: 22932
diff changeset
2051 var strings: dict<string> = {a: 'a', b: 'b', c: 'c'}
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2052 strings = {a: 'x'}
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2053 strings = {}
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2054
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2055 var dash = {xx-x: 8}
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2056 assert_equal({['xx-x']: 8}, dash)
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2057
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2058 var dnr = {8: 8}
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2059 assert_equal({['8']: 8}, dnr)
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
2060
22936
00b0275ffe7f patch 8.2.2015: Vim9: literal dict #{} is not like any other language
Bram Moolenaar <Bram@vim.org>
parents: 22932
diff changeset
2061 var mixed: dict<any> = {a: 'a', b: 42}
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2062 mixed = {a: 'x'}
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2063 mixed = {a: 234}
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2064 mixed = {}
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
2065
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2066 var dictlist: dict<list<string>> = {absent: [], present: ['hi']}
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2067 dictlist = {absent: ['hi'], present: []}
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2068 dictlist = {absent: [], present: []}
22322
a5b16c9eee9d patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 22296
diff changeset
2069
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2070 var dictdict: dict<dict<string>> = {one: {a: 'text'}, two: {}}
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2071 dictdict = {one: {}, two: {a: 'text'}}
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2072 dictdict = {one: {}, two: {}}
22808
96dbb61a54c2 patch 8.2.1952: Vim9: crash when using a NULL dict key
Bram Moolenaar <Bram@vim.org>
parents: 22804
diff changeset
2073
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2074 assert_equal({['']: 0}, {[matchstr('string', 'wont match')]: 0})
22936
00b0275ffe7f patch 8.2.2015: Vim9: literal dict #{} is not like any other language
Bram Moolenaar <Bram@vim.org>
parents: 22932
diff changeset
2075
00b0275ffe7f patch 8.2.2015: Vim9: literal dict #{} is not like any other language
Bram Moolenaar <Bram@vim.org>
parents: 22932
diff changeset
2076 assert_equal(g:test_space_dict, {['']: 'empty', [' ']: 'space'})
00b0275ffe7f patch 8.2.2015: Vim9: literal dict #{} is not like any other language
Bram Moolenaar <Bram@vim.org>
parents: 22932
diff changeset
2077 assert_equal(g:test_hash_dict, {one: 1, two: 2})
23088
285cde4b8d0e patch 8.2.2090: Vim9: dict does not accept a key in quotes
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
2078
285cde4b8d0e patch 8.2.2090: Vim9: dict does not accept a key in quotes
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
2079 assert_equal({['a a']: 1, ['b/c']: 2}, {'a a': 1, "b/c": 2})
23418
681f042ae5ac patch 8.2.2252: Vim9: crash when using lambda without return type in dict
Bram Moolenaar <Bram@vim.org>
parents: 23414
diff changeset
2080
681f042ae5ac patch 8.2.2252: Vim9: crash when using lambda without return type in dict
Bram Moolenaar <Bram@vim.org>
parents: 23414
diff changeset
2081 var d = {a: () => 3, b: () => 7}
681f042ae5ac patch 8.2.2252: Vim9: crash when using lambda without return type in dict
Bram Moolenaar <Bram@vim.org>
parents: 23414
diff changeset
2082 assert_equal(3, d.a())
681f042ae5ac patch 8.2.2252: Vim9: crash when using lambda without return type in dict
Bram Moolenaar <Bram@vim.org>
parents: 23414
diff changeset
2083 assert_equal(7, d.b())
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
2084 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
2085 CheckDefAndScriptSuccess(lines)
22322
a5b16c9eee9d patch 8.2.1710: Vim9: list of list type can be wrong
Bram Moolenaar <Bram@vim.org>
parents: 22296
diff changeset
2086
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2087 # legacy syntax doesn't work
23122
60a0221beab0 patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents: 23106
diff changeset
2088 CheckDefFailure(["var x = #{key: 8}"], 'E1097:', 3)
60a0221beab0 patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents: 23106
diff changeset
2089 CheckDefFailure(["var x = 'a' .. #{a: 1}"], 'E1097:', 3)
21759
25b659fa5ca5 patch 8.2.1429: Vim9: no error for missing white after : in dict
Bram Moolenaar <Bram@vim.org>
parents: 21753
diff changeset
2090
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2091 CheckDefFailure(["var x = {a:8}"], 'E1069:', 1)
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2092 CheckDefFailure(["var x = {a : 8}"], 'E1059:', 1)
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2093 CheckDefFailure(["var x = {a :8}"], 'E1059:', 1)
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2094 CheckDefFailure(["var x = {a: 8 , b: 9}"], 'E1068:', 1)
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2095 CheckDefFailure(["var x = {a: 1,b: 2}"], 'E1069:', 1)
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2096
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2097 CheckDefFailure(["var x = {xxx}"], 'E720:', 1)
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2098 CheckDefFailure(["var x = {xxx: 1", "var y = 2"], 'E722:', 2)
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2099 CheckDefFailure(["var x = {xxx: 1,"], 'E723:', 2)
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2100 CheckDefFailure(["var x = {['a']: xxx}"], 'E1001:', 1)
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2101 CheckDefFailure(["var x = {a: 1, a: 2}"], 'E721:', 1)
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
2102 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
2103 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
2104
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2105 CheckDefExecFailure(['var x: dict<number> = {a: 234, b: "1"}'], 'E1012:', 1)
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2106 CheckDefExecFailure(['var x: dict<number> = {a: "x", b: 134}'], 'E1012:', 1)
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2107 CheckDefExecFailure(['var x: dict<string> = {a: 234, b: "1"}'], 'E1012:', 1)
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2108 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
2109
ac8c4a8b8cba patch 8.2.1802: Vim9: crash with unterminated dict
Bram Moolenaar <Bram@vim.org>
parents: 22500
diff changeset
2110 CheckDefFailure(['var x = ({'], 'E723:', 2)
23142
5f08d4a42898 patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23122
diff changeset
2111 CheckDefExecFailure(['{}[getftype("file")]'], 'E716: Key not present in Dictionary: ""', 1)
23201
94608d7c3b55 patch 8.2.2146: Vim9: automatic conversion of number to string for dict key
Bram Moolenaar <Bram@vim.org>
parents: 23199
diff changeset
2112
94608d7c3b55 patch 8.2.2146: Vim9: automatic conversion of number to string for dict key
Bram Moolenaar <Bram@vim.org>
parents: 23199
diff changeset
2113 # no automatic conversion from number to string
94608d7c3b55 patch 8.2.2146: Vim9: automatic conversion of number to string for dict key
Bram Moolenaar <Bram@vim.org>
parents: 23199
diff changeset
2114 lines =<< trim END
94608d7c3b55 patch 8.2.2146: Vim9: automatic conversion of number to string for dict key
Bram Moolenaar <Bram@vim.org>
parents: 23199
diff changeset
2115 var n = 123
94608d7c3b55 patch 8.2.2146: Vim9: automatic conversion of number to string for dict key
Bram Moolenaar <Bram@vim.org>
parents: 23199
diff changeset
2116 var d = {[n]: 1}
94608d7c3b55 patch 8.2.2146: Vim9: automatic conversion of number to string for dict key
Bram Moolenaar <Bram@vim.org>
parents: 23199
diff changeset
2117 END
94608d7c3b55 patch 8.2.2146: Vim9: automatic conversion of number to string for dict key
Bram Moolenaar <Bram@vim.org>
parents: 23199
diff changeset
2118 CheckDefFailure(lines, 'E1012:', 2)
94608d7c3b55 patch 8.2.2146: Vim9: automatic conversion of number to string for dict key
Bram Moolenaar <Bram@vim.org>
parents: 23199
diff changeset
2119 CheckScriptFailure(['vim9script'] + lines, 'E928:', 3)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2120 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2121
21034
2f8b0812819f patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents: 21032
diff changeset
2122 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
2123 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
2124 vim9script
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
2125 var d = {
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2126 ['one']:
21034
2f8b0812819f patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents: 21032
diff changeset
2127 1,
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2128 ['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
2129 }
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2130 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
2131
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
2132 d = { # comment
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2133 ['one']:
22580
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
2134 # comment
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
2135
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
2136 1,
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
2137 # comment
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
2138 # comment
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2139 ['two']: 2,
22580
eb54d34ecd27 patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents: 22508
diff changeset
2140 }
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2141 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
2142 END
2f8b0812819f patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents: 21032
diff changeset
2143 CheckScriptSuccess(lines)
2f8b0812819f patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents: 21032
diff changeset
2144
2f8b0812819f patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents: 21032
diff changeset
2145 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
2146 vim9script
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2147 var d = { ["one"]: "one", ["two"]: "two", }
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2148 assert_equal({one: 'one', two: 'two'}, d)
21118
b0baa80cb53f patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents: 21046
diff changeset
2149 END
b0baa80cb53f patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents: 21046
diff changeset
2150 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
2151
b0baa80cb53f patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents: 21046
diff changeset
2152 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
2153 vim9script
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2154 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
2155 two: 2,
2f8b0812819f patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents: 21032
diff changeset
2156 }
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2157 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
2158 END
2f8b0812819f patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents: 21032
diff changeset
2159 CheckScriptSuccess(lines)
2f8b0812819f patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents: 21032
diff changeset
2160
2f8b0812819f patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents: 21032
diff changeset
2161 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
2162 vim9script
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2163 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
2164 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
2165 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
2166
2f8b0812819f patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents: 21032
diff changeset
2167 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
2168 vim9script
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2169 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
2170 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
2171 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
2172
5a2373c25a86 patch 8.2.1430: Vim9: error for missing comma instead of extra white space
Bram Moolenaar <Bram@vim.org>
parents: 21759
diff changeset
2173 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
2174 vim9script
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2175 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
2176 END
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2177 CheckScriptFailure(lines, 'E1059:', 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
2178
5a2373c25a86 patch 8.2.1430: Vim9: error for missing comma instead of extra white space
Bram Moolenaar <Bram@vim.org>
parents: 21759
diff changeset
2179 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
2180 vim9script
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2181 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
2182 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
2183 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
2184
703ea7603d3e patch 8.2.1431: Vim9: no error for white space before comma in dict
Bram Moolenaar <Bram@vim.org>
parents: 21761
diff changeset
2185 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
2186 vim9script
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2187 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
2188 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
2189 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
2190
e591b448a670 patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents: 21771
diff changeset
2191 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
2192 vim9script
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2193 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
2194 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
2195 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
2196 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
2197 vim9script
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2198 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
2199 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
2200 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
2201 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
2202 vim9script
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2203 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
2204 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
2205 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
2206 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
2207 vim9script
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2208 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
2209 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
2210 CheckScriptFailure(lines, 'E1012:', 2)
22804
af26fadf333d patch 8.2.1950: Vim9: crash when compiling function fails when getting type
Bram Moolenaar <Bram@vim.org>
parents: 22752
diff changeset
2211
af26fadf333d patch 8.2.1950: Vim9: crash when compiling function fails when getting type
Bram Moolenaar <Bram@vim.org>
parents: 22752
diff changeset
2212 lines =<< trim END
23106
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2213 vim9script
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2214 var d = {['a']: 234, ['b': 'x'}
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2215 END
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2216 CheckScriptFailure(lines, 'E1139:', 2)
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2217 lines =<< trim END
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2218 vim9script
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2219 def Func()
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2220 var d = {['a']: 234, ['b': 'x'}
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2221 enddef
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2222 defcompile
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2223 END
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2224 CheckScriptFailure(lines, 'E1139:', 1)
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2225 lines =<< trim END
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2226 vim9script
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2227 var d = {'a':
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2228 END
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2229 CheckScriptFailure(lines, 'E15:', 2)
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2230 lines =<< trim END
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2231 vim9script
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2232 def Func()
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2233 var d = {'a':
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2234 enddef
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2235 defcompile
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2236 END
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2237 CheckScriptFailure(lines, 'E723:', 1)
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2238
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2239 lines =<< trim END
22804
af26fadf333d patch 8.2.1950: Vim9: crash when compiling function fails when getting type
Bram Moolenaar <Bram@vim.org>
parents: 22752
diff changeset
2240 vim9script
af26fadf333d patch 8.2.1950: Vim9: crash when compiling function fails when getting type
Bram Moolenaar <Bram@vim.org>
parents: 22752
diff changeset
2241 def Failing()
af26fadf333d patch 8.2.1950: Vim9: crash when compiling function fails when getting type
Bram Moolenaar <Bram@vim.org>
parents: 22752
diff changeset
2242 job_stop()
af26fadf333d patch 8.2.1950: Vim9: crash when compiling function fails when getting type
Bram Moolenaar <Bram@vim.org>
parents: 22752
diff changeset
2243 enddef
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2244 var dict = {name: Failing}
22804
af26fadf333d patch 8.2.1950: Vim9: crash when compiling function fails when getting type
Bram Moolenaar <Bram@vim.org>
parents: 22752
diff changeset
2245 END
22836
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
2246 if has('channel')
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
2247 CheckScriptFailure(lines, 'E119:', 1)
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
2248 else
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
2249 CheckScriptFailure(lines, 'E117:', 1)
b129f28b0e35 patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents: 22808
diff changeset
2250 endif
21034
2f8b0812819f patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents: 21032
diff changeset
2251 enddef
2f8b0812819f patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents: 21032
diff changeset
2252
21168
f26a606e6dbc patch 8.2.1135: Vim9: getting a dict member may not work
Bram Moolenaar <Bram@vim.org>
parents: 21166
diff changeset
2253 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
2254
19848
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
2255 def Test_expr_member()
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
2256 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
2257 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
2258 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
2259 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
2260 'one'
4edc60c9c0aa patch 8.2.1175: Vim9: cannot split a line before ".member"
Bram Moolenaar <Bram@vim.org>
parents: 21232
diff changeset
2261 ])
4edc60c9c0aa patch 8.2.1175: Vim9: cannot split a line before ".member"
Bram Moolenaar <Bram@vim.org>
parents: 21232
diff changeset
2262 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
2263 .one)
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2264 d = {1: 1, _: 2}
21512
81c47a694479 patch 8.2.1306: checking for first character of dict key is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 21465
diff changeset
2265 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
2266 .1)
81c47a694479 patch 8.2.1306: checking for first character of dict key is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 21465
diff changeset
2267 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
2268 ._)
19848
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
2269
21152
1561311249bb patch 8.2.1127: Vim9: getting a dict member may not work
Bram Moolenaar <Bram@vim.org>
parents: 21142
diff changeset
2270 # getting the one member should clear the dict after getting the item
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2271 assert_equal('one', {one: 'one'}.one)
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2272 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
2273
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 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
2275 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
2276 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
2277 enddef
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
2278
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
2279 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
2280 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
2281 # 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
2282 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
2283
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21831
diff changeset
2284 # 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
2285 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
2286 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
2287 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
2288 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
2289
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2290 assert_equal('b', g:teststring[1 : 1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2291 assert_equal('bcdef', g:teststring[1 :])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2292 assert_equal('abcd', g:teststring[: 3])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2293 assert_equal('cdef', g:teststring[-4 :])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2294 assert_equal('abcdef', g:teststring[-9 :])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2295 assert_equal('abcd', g:teststring[: -3])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2296 assert_equal('', g:teststring[: -9])
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
2297
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21831
diff changeset
2298 # 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
2299 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
2300 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
2301 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
2302 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
2303 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
2304
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21831
diff changeset
2305 # blob slice accepts out of range
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2306 assert_equal(0z01ab, g:testblob[0 : 1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2307 assert_equal(0z01, g:testblob[0 : 0])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2308 assert_equal(0z01, g:testblob[-2 : -2])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2309 assert_equal(0zab, g:testblob[1 : 1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2310 assert_equal(0zab, g:testblob[-1 : -1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2311 assert_equal(0z, g:testblob[2 : 2])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2312 assert_equal(0z, g:testblob[0 : -3])
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
2313
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21831
diff changeset
2314 # 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
2315 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
2316 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
2317 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
2318 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
2319 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
2320 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
2321 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
2322
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21831
diff changeset
2323 # list slice accepts out of range
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2324 assert_equal([0], g:testlist[0 : 0])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2325 assert_equal([3], g:testlist[3 : 3])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2326 assert_equal([0, 1], g:testlist[0 : 1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2327 assert_equal([0, 1, 2, 3], g:testlist[0 : 3])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2328 assert_equal([0, 1, 2, 3], g:testlist[0 : 9])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2329 assert_equal([], g:testlist[-1 : 1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2330 assert_equal([1], g:testlist[-3 : 1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2331 assert_equal([0, 1], g:testlist[-4 : 1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2332 assert_equal([0, 1], g:testlist[-9 : 1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2333 assert_equal([1, 2, 3], g:testlist[1 : -1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2334 assert_equal([1], g:testlist[1 : -3])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2335 assert_equal([], g:testlist[1 : -4])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2336 assert_equal([], g:testlist[1 : -9])
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
2337
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2338 g:testdict = {a: 1, b: 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
2339 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
2340 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
2341 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
2342
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21831
diff changeset
2343 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
2344 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
2345
21863
809b1e7fbd72 patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 21859
diff changeset
2346 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
2347 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
2348 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
2349 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
2350
21863
809b1e7fbd72 patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 21859
diff changeset
2351 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
2352 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
2353 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
2354 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
2355
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2356 CheckDefExecFailure(['echo g:testdict["a" : "b"]'], 'E719:', 1)
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2357 CheckScriptFailure(['vim9script', 'echo g:testdict["a" : "b"]'], 'E719:', 2)
21863
809b1e7fbd72 patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 21859
diff changeset
2358 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
2359 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
2360
e3f9528bddda patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents: 21831
diff changeset
2361 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
2362 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
2363 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
2364 enddef
64f664f9b23a patch 8.2.1134: Vim9: getting a list member may not work
Bram Moolenaar <Bram@vim.org>
parents: 21152
diff changeset
2365
21142
165cea61e974 patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents: 21122
diff changeset
2366 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
2367 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
2368 vim9script
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2369 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
2370 '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
2371 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
2372 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
2373 _: 2}
21142
165cea61e974 patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents: 21122
diff changeset
2374 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
2375 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
2376 .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
2377 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
2378 .1)
81c47a694479 patch 8.2.1306: checking for first character of dict key is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 21465
diff changeset
2379 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
2380 ._)
21142
165cea61e974 patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents: 21122
diff changeset
2381 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
2382 'one'
165cea61e974 patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents: 21122
diff changeset
2383 ])
165cea61e974 patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents: 21122
diff changeset
2384 END
165cea61e974 patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents: 21122
diff changeset
2385 CheckScriptSuccess(lines)
165cea61e974 patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents: 21122
diff changeset
2386
165cea61e974 patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents: 21122
diff changeset
2387 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
2388 vim9script
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
2389 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
2390 2,
165cea61e974 patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents: 21122
diff changeset
2391 3, 4
165cea61e974 patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents: 21122
diff changeset
2392 ]
165cea61e974 patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents: 21122
diff changeset
2393 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
2394 1
165cea61e974 patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents: 21122
diff changeset
2395 ])
165cea61e974 patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents: 21122
diff changeset
2396 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
2397 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
2398 :
165cea61e974 patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents: 21122
diff changeset
2399 2
165cea61e974 patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents: 21122
diff changeset
2400 ])
165cea61e974 patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents: 21122
diff changeset
2401 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
2402 2
165cea61e974 patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents: 21122
diff changeset
2403 :
165cea61e974 patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents: 21122
diff changeset
2404 ])
165cea61e974 patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents: 21122
diff changeset
2405 END
165cea61e974 patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents: 21122
diff changeset
2406 CheckScriptSuccess(lines)
165cea61e974 patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents: 21122
diff changeset
2407 enddef
165cea61e974 patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents: 21122
diff changeset
2408
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2409 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
2410 # option
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2411 set ts=11
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2412 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
2413 &ts = 9
f8408ba21982 patch 8.2.0282: Vim9: setting number option not tested
Bram Moolenaar <Bram@vim.org>
parents: 19437
diff changeset
2414 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
2415 set ts=8
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2416 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
2417 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
2418 &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
2419 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
2420 set grepprg&
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2421 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2422
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2423 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
2424 # environment variable
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('testvar', $TESTVAR)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2426 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
2427
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
2428 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
2429 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2430
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2431 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
2432 @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
2433 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
2434
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
2435 var fname = expand('%')
21612
c495d3e30f4b patch 8.2.1356: Vim9: cannot get the percent register
Bram Moolenaar <Bram@vim.org>
parents: 21562
diff changeset
2436 assert_equal(fname, @%)
c495d3e30f4b patch 8.2.1356: Vim9: cannot get the percent register
Bram Moolenaar <Bram@vim.org>
parents: 21562
diff changeset
2437
c495d3e30f4b patch 8.2.1356: Vim9: cannot get the percent register
Bram Moolenaar <Bram@vim.org>
parents: 21562
diff changeset
2438 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
2439 assert_equal("echo 'some'", @:)
c495d3e30f4b patch 8.2.1356: Vim9: cannot get the percent register
Bram Moolenaar <Bram@vim.org>
parents: 21562
diff changeset
2440
c495d3e30f4b patch 8.2.1356: Vim9: cannot get the percent register
Bram Moolenaar <Bram@vim.org>
parents: 21562
diff changeset
2441 normal axyz
c495d3e30f4b patch 8.2.1356: Vim9: cannot get the percent register
Bram Moolenaar <Bram@vim.org>
parents: 21562
diff changeset
2442 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
2443 CheckDefFailure(["@. = 'yes'"], 'E354:', 1)
21614
d0128ecd4341 patch 8.2.1357: Vim9: cannot assign to / register
Bram Moolenaar <Bram@vim.org>
parents: 21612
diff changeset
2444
d0128ecd4341 patch 8.2.1357: Vim9: cannot assign to / register
Bram Moolenaar <Bram@vim.org>
parents: 21612
diff changeset
2445 @/ = 'slash'
d0128ecd4341 patch 8.2.1357: Vim9: cannot assign to / register
Bram Moolenaar <Bram@vim.org>
parents: 21612
diff changeset
2446 assert_equal('slash', @/)
d0128ecd4341 patch 8.2.1357: Vim9: cannot assign to / register
Bram Moolenaar <Bram@vim.org>
parents: 21612
diff changeset
2447
d0128ecd4341 patch 8.2.1357: Vim9: cannot assign to / register
Bram Moolenaar <Bram@vim.org>
parents: 21612
diff changeset
2448 @= = 'equal'
d0128ecd4341 patch 8.2.1357: Vim9: cannot assign to / register
Bram Moolenaar <Bram@vim.org>
parents: 21612
diff changeset
2449 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
2450 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2451
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
2452 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
2453 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
2454 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
2455 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
2456 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
2457 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
2458
5cb6e676defd patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents: 21393
diff changeset
2459 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
2460 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
2461 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
2462 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
2463 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
2464
5cb6e676defd patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents: 21393
diff changeset
2465 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
2466 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
2467 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
2468 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
2469 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
2470
5cb6e676defd patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Bram Moolenaar <Bram@vim.org>
parents: 21393
diff changeset
2471 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
2472 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
2473 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
2474 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
2475 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
2476 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
2477
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2478 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
2479 # (expr)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2480 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
2481 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
2482
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2483 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
2484 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
2485 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
2486 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
2487 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
2488 assert_equal(false, !-3)
f80e822a310d patch 8.2.1067: expression "!expr->func()" does not work
Bram Moolenaar <Bram@vim.org>
parents: 21028
diff changeset
2489 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
2490 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2491
21044
dc2ca403a217 patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents: 21040
diff changeset
2492 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
2493 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
2494 vim9script
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
2495 var s = (
21044
dc2ca403a217 patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents: 21040
diff changeset
2496 'one'
dc2ca403a217 patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents: 21040
diff changeset
2497 ..
dc2ca403a217 patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents: 21040
diff changeset
2498 'two'
dc2ca403a217 patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents: 21040
diff changeset
2499 )
dc2ca403a217 patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents: 21040
diff changeset
2500 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
2501 END
dc2ca403a217 patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents: 21040
diff changeset
2502 CheckScriptSuccess(lines)
dc2ca403a217 patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents: 21040
diff changeset
2503 enddef
dc2ca403a217 patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents: 21040
diff changeset
2504
22932
87b62395a4d1 patch 8.2.2013: Vim9: not skipping white space after unary minus
Bram Moolenaar <Bram@vim.org>
parents: 22930
diff changeset
2505 def Test_expr7_negate_add()
19848
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
2506 assert_equal(-99, -99)
22932
87b62395a4d1 patch 8.2.2013: Vim9: not skipping white space after unary minus
Bram Moolenaar <Bram@vim.org>
parents: 22930
diff changeset
2507 assert_equal(-99, - 99)
19848
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
2508 assert_equal(99, --99)
22932
87b62395a4d1 patch 8.2.2013: Vim9: not skipping white space after unary minus
Bram Moolenaar <Bram@vim.org>
parents: 22930
diff changeset
2509 assert_equal(99, -- 99)
87b62395a4d1 patch 8.2.2013: Vim9: not skipping white space after unary minus
Bram Moolenaar <Bram@vim.org>
parents: 22930
diff changeset
2510 assert_equal(99, - - 99)
87b62395a4d1 patch 8.2.2013: Vim9: not skipping white space after unary minus
Bram Moolenaar <Bram@vim.org>
parents: 22930
diff changeset
2511 assert_equal(99, +99)
87b62395a4d1 patch 8.2.2013: Vim9: not skipping white space after unary minus
Bram Moolenaar <Bram@vim.org>
parents: 22930
diff changeset
2512 assert_equal(-99, -+99)
87b62395a4d1 patch 8.2.2013: Vim9: not skipping white space after unary minus
Bram Moolenaar <Bram@vim.org>
parents: 22930
diff changeset
2513 assert_equal(-99, -+ 99)
87b62395a4d1 patch 8.2.2013: Vim9: not skipping white space after unary minus
Bram Moolenaar <Bram@vim.org>
parents: 22930
diff changeset
2514 assert_equal(-99, - +99)
87b62395a4d1 patch 8.2.2013: Vim9: not skipping white space after unary minus
Bram Moolenaar <Bram@vim.org>
parents: 22930
diff changeset
2515 assert_equal(-99, - + 99)
87b62395a4d1 patch 8.2.2013: Vim9: not skipping white space after unary minus
Bram Moolenaar <Bram@vim.org>
parents: 22930
diff changeset
2516 assert_equal(-99, +-99)
87b62395a4d1 patch 8.2.2013: Vim9: not skipping white space after unary minus
Bram Moolenaar <Bram@vim.org>
parents: 22930
diff changeset
2517 assert_equal(-99, + -99)
87b62395a4d1 patch 8.2.2013: Vim9: not skipping white space after unary minus
Bram Moolenaar <Bram@vim.org>
parents: 22930
diff changeset
2518 assert_equal(-99, + - 99)
87b62395a4d1 patch 8.2.2013: Vim9: not skipping white space after unary minus
Bram Moolenaar <Bram@vim.org>
parents: 22930
diff changeset
2519
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
2520 var nr = 88
19848
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
2521 assert_equal(-88, -nr)
22932
87b62395a4d1 patch 8.2.2013: Vim9: not skipping white space after unary minus
Bram Moolenaar <Bram@vim.org>
parents: 22930
diff changeset
2522 assert_equal(-88, - nr)
87b62395a4d1 patch 8.2.2013: Vim9: not skipping white space after unary minus
Bram Moolenaar <Bram@vim.org>
parents: 22930
diff changeset
2523 assert_equal(-88, - +nr)
87b62395a4d1 patch 8.2.2013: Vim9: not skipping white space after unary minus
Bram Moolenaar <Bram@vim.org>
parents: 22930
diff changeset
2524 assert_equal(88, -- nr)
87b62395a4d1 patch 8.2.2013: Vim9: not skipping white space after unary minus
Bram Moolenaar <Bram@vim.org>
parents: 22930
diff changeset
2525 assert_equal(88, + nr)
87b62395a4d1 patch 8.2.2013: Vim9: not skipping white space after unary minus
Bram Moolenaar <Bram@vim.org>
parents: 22930
diff changeset
2526 assert_equal(88, --+ nr)
87b62395a4d1 patch 8.2.2013: Vim9: not skipping white space after unary minus
Bram Moolenaar <Bram@vim.org>
parents: 22930
diff changeset
2527 assert_equal(88, - - nr)
19848
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
2528 enddef
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
2529
20029
8fb1cf4c44d5 patch 8.2.0570: Vim9: no error when omitting type from argument
Bram Moolenaar <Bram@vim.org>
parents: 20013
diff changeset
2530 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
2531 return arg
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
2532 enddef
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
2533
21650
79a8d723a3d2 patch 8.2.1375: Vim9: method name with digit not accepted
Bram Moolenaar <Bram@vim.org>
parents: 21644
diff changeset
2534 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
2535 return arg
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
2536 enddef
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
2537
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
2538 def Test_expr7_call()
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
2539 var lines =<< trim END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
2540 assert_equal('yes', 'yes'->Echo())
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
2541 assert_equal(true, !range(5)->empty())
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
2542 assert_equal([0, 1, 2], --3->range())
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
2543 END
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
2544 CheckDefAndScriptSuccess(lines)
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
2545
21455
8cc1555f2445 patch 8.2.1278: Vim9: line break after "->" only allowed in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21425
diff changeset
2546 assert_equal('yes', 'yes'
22866
52e64d340a98 patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents: 22860
diff changeset
2547 ->s:Echo4Arg())
19848
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
2548
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
2549 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
2550 CheckScriptFailure([
d55008685870 patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents: 22119
diff changeset
2551 "vim9script",
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
2552 "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
2553 ], 'E121:', 2)
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
2554 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
2555
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
2556 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
2557 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
2558 return 'found'
9ef7ae8ab51c patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21739
diff changeset
2559 enddef
9ef7ae8ab51c patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21739
diff changeset
2560 END
9ef7ae8ab51c patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21739
diff changeset
2561 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
2562 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
2563 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
2564 &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
2565 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
2566 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
2567
9ef7ae8ab51c patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents: 21739
diff changeset
2568 &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
2569 delete('Xruntime', 'rf')
19848
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
2570 enddef
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
2571
23352
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2572 def Test_expr7_method_call()
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2573 new
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2574 setline(1, ['first', 'last'])
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2575 'second'->append(1)
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2576 "third"->append(2)
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2577 assert_equal(['first', 'second', 'third', 'last'], getline(1, '$'))
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2578 bwipe!
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2579
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2580 var bufnr = bufnr()
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2581 var loclist = [{bufnr: bufnr, lnum: 42, col: 17, text: 'wrong'}]
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2582 loclist->setloclist(0)
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2583 assert_equal([{bufnr: bufnr,
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2584 lnum: 42,
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2585 col: 17,
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2586 text: 'wrong',
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2587 pattern: '',
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2588 valid: 1,
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2589 vcol: 0,
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2590 nr: 0,
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2591 type: '',
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2592 module: ''}
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2593 ], getloclist(0))
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2594
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2595 var result: bool = get({n: 0}, 'n', 0)
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2596 assert_equal(false, result)
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2597
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2598 assert_equal('+string+', 'string'->((s) => '+' .. s .. '+')())
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2599 assert_equal('-text-', 'text'->((s, c) => c .. s .. c)('-'))
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2600
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2601 var Join = (l) => join(l, 'x')
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2602 assert_equal('axb', ['a', 'b']->(Join)())
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2603 enddef
37118deff718 patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents: 23338
diff changeset
2604
19848
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
2605
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2606 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
2607 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
2608 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
2609 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
2610 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
2611 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
2612 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
2613 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
2614
22606
336ac63fb987 patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents: 22580
diff changeset
2615 assert_equal(true, ! false)
336ac63fb987 patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents: 22580
diff changeset
2616 assert_equal(true, !! true)
336ac63fb987 patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents: 22580
diff changeset
2617 assert_equal(true, ! ! true)
336ac63fb987 patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents: 22580
diff changeset
2618 assert_equal(true, !!! false)
336ac63fb987 patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents: 22580
diff changeset
2619 assert_equal(true, ! ! ! false)
336ac63fb987 patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents: 22580
diff changeset
2620
336ac63fb987 patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents: 22580
diff changeset
2621 g:true = true
336ac63fb987 patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents: 22580
diff changeset
2622 g:false = false
336ac63fb987 patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents: 22580
diff changeset
2623 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
2624 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
2625 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
2626 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
2627 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
2628 unlet g:true
336ac63fb987 patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents: 22580
diff changeset
2629 unlet g:false
336ac63fb987 patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents: 22580
diff changeset
2630
21733
1bb5adfe5966 patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents: 21725
diff changeset
2631 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
2632 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
2633
1bb5adfe5966 patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents: 21725
diff changeset
2634 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
2635 assert_equal(true, !{})
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2636 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
2637
21733
1bb5adfe5966 patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents: 21725
diff changeset
2638 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
2639 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
2640 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
2641 endif
19483
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19469
diff changeset
2642
21733
1bb5adfe5966 patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents: 21725
diff changeset
2643 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
2644 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
2645 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
2646
21733
1bb5adfe5966 patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents: 21725
diff changeset
2647 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
2648 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
2649
caf0286cf02b patch 8.2.1419: Vim9: not operator applied too early
Bram Moolenaar <Bram@vim.org>
parents: 21737
diff changeset
2650 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
2651 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
2652 END
22606
336ac63fb987 patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents: 22580
diff changeset
2653 CheckDefAndScriptSuccess(lines)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2654 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2655
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2656 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
2657 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
2658
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
2659 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
2660 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
2661 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
2662 call CheckDefExecFailure(["var x = -[8]"], "E39:", 1)
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2663 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
2664
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
2665 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
2666 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
2667
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
2668 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
2669 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
2670
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
2671 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
2672 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
2673
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
2674 call CheckDefFailure(["var x = &notexist"], '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
2675 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
2676
21863
809b1e7fbd72 patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 21859
diff changeset
2677 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
2678 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
2679
21863
809b1e7fbd72 patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 21859
diff changeset
2680 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
2681 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
2682 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
2683
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
2684 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
2685 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
2686 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
2687 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
2688
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
2689 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
2690
21863
809b1e7fbd72 patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 21859
diff changeset
2691 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
2692
21863
809b1e7fbd72 patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 21859
diff changeset
2693 call CheckDefExecFailure(["[1, 2->len()"], 'E697:', 2)
23368
a7cbdb9294c4 patch 8.2.2227: Vim9: recognizing lambda is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 23352
diff changeset
2694 call CheckDefExecFailure(["{a: 1->len()"], 'E1004:', 1)
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2695 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
2696 endfunc
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2697
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2698 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
2699
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2700 func CallMe(arg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2701 return a:arg
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2702 endfunc
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2703
19437
5d34ae66118e patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents: 19423
diff changeset
2704 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
2705 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
2706 endfunc
5d34ae66118e patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents: 19423
diff changeset
2707
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2708 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
2709 # user function call
20189
63cc54100ae4 patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents: 20170
diff changeset
2710 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
2711 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
2712 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
2713 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
2714 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
2715 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
2716
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21313
diff changeset
2717 # partial call
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
2718 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
2719 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
2720
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21313
diff changeset
2721 # 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
2722 var l = []
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2723 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
2724 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
2725
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21313
diff changeset
2726 # method call
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2727 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
2728 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
2729 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
2730
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21313
diff changeset
2731 # 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
2732 l = [2, 5]
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2733 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
2734 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
2735
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21313
diff changeset
2736 # dict member
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2737 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
2738 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
2739 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2740
21826
ccad66ac6c3e patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21823
diff changeset
2741 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
2742 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
2743 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
2744 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
2745 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
2746 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
2747 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
2748 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
2749
b1f3d8a44ab6 patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
2750 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
2751 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
2752 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
2753 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
2754 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
2755 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
2756 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
2757 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
2758 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
2759 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
2760 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
2761
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2762 assert_equal('ábçdëf', text[0 : -1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2763 assert_equal('ábçdëf', text[0 : -1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2764 assert_equal('ábçdëf', text[0 : -1])
21826
ccad66ac6c3e patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21823
diff changeset
2765 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
2766 assert_equal('ábçdëf', text[0
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2767 : -1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2768 assert_equal('ábçdëf', text[0 :
21826
ccad66ac6c3e patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21823
diff changeset
2769 -1])
ccad66ac6c3e patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21823
diff changeset
2770 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
2771 ])
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2772 assert_equal('bçdëf', text[1 : -1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2773 assert_equal('çdëf', text[2 : -1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2774 assert_equal('dëf', text[3 : -1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2775 assert_equal('ëf', text[4 : -1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2776 assert_equal('f', text[5 : -1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2777 assert_equal('', text[6 : -1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2778 assert_equal('', text[999 : -1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2779
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2780 assert_equal('ábçd', text[: 3])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2781 assert_equal('bçdëf', text[1 :])
21826
ccad66ac6c3e patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21823
diff changeset
2782 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
2783 END
b1f3d8a44ab6 patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
2784 CheckDefSuccess(lines)
b1f3d8a44ab6 patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
2785 CheckScriptSuccess(['vim9script'] + lines)
23106
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2786
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2787 lines =<< trim END
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2788 var d = 'asdf'[1 :
23106
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2789 END
23122
60a0221beab0 patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents: 23106
diff changeset
2790 CheckDefFailure(lines, 'E1097:', 3)
23106
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2791 lines =<< trim END
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2792 var d = 'asdf'[1 : xxx]
23106
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2793 END
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2794 CheckDefFailure(lines, 'E1001:', 1)
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2795 lines =<< trim END
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2796 var d = 'asdf'[1 : 2
23106
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2797 END
23122
60a0221beab0 patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents: 23106
diff changeset
2798 CheckDefFailure(lines, 'E1097:', 3)
23106
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2799 lines =<< trim END
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2800 var d = 'asdf'[1 : 2
23106
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2801 echo d
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2802 END
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2803 CheckDefFailure(lines, 'E111:', 2)
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2804 lines =<< trim END
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2805 var d = 'asdf'['1']
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2806 echo d
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2807 END
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2808 CheckDefFailure(lines, 'E1012: Type mismatch; expected number but got string', 1)
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2809 lines =<< trim END
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2810 var d = 'asdf'['1' : 2]
23106
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2811 echo d
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2812 END
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2813 CheckDefFailure(lines, 'E1012: Type mismatch; expected number but got string', 1)
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2814 lines =<< trim END
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2815 var d = 'asdf'[1 : '2']
23106
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2816 echo d
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2817 END
b0c88aa0175b patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents: 23088
diff changeset
2818 CheckDefFailure(lines, 'E1012: Type mismatch; expected number but got string', 1)
21393
320581a133d9 patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents: 21387
diff changeset
2819 enddef
320581a133d9 patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents: 21387
diff changeset
2820
21828
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
2821 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
2822 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
2823 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
2824 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
2825 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
2826 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
2827 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
2828
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2829 assert_equal([0, 1, 2, 3, 4], list[0 : 4])
21828
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
2830 assert_equal([0, 1, 2, 3, 4], list[:])
23414
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2831 assert_equal([1, 2, 3, 4], list[1 :])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2832 assert_equal([2, 3, 4], list[2 : -1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2833 assert_equal([4], list[4 : -1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2834 assert_equal([], list[5 : -1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2835 assert_equal([], list[999 : -1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2836 assert_equal([1, 2, 3, 4], list[g:theone : g:thefour])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2837
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2838 assert_equal([0, 1, 2, 3], list[0 : 3])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2839 assert_equal([0], list[0 : 0])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2840 assert_equal([0, 1, 2, 3, 4], list[0 : -1])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2841 assert_equal([0, 1, 2], list[0 : -3])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2842 assert_equal([0], list[0 : -5])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2843 assert_equal([], list[0 : -6])
9bd3873b13e2 patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23368
diff changeset
2844 assert_equal([], list[0 : -99])
21828
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
2845 END
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
2846 CheckDefSuccess(lines)
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
2847 CheckScriptSuccess(['vim9script'] + lines)
21831
d8422de73113 patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 21828
diff changeset
2848
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
2849 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
2850 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
2851 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
2852 enddef
af5db9b6d210 patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 21826
diff changeset
2853
22244
9f6b8fdea159 patch 8.2.1671: Vim9: stray error for missing white space
Bram Moolenaar <Bram@vim.org>
parents: 22238
diff changeset
2854 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
2855 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
2856 vim9script
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2857 var l = [{lnum: 2}, {lnum: 1}]
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
2858 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
2859 assert_true(res)
9f6b8fdea159 patch 8.2.1671: Vim9: stray error for missing white space
Bram Moolenaar <Bram@vim.org>
parents: 22238
diff changeset
2860 END
9f6b8fdea159 patch 8.2.1671: Vim9: stray error for missing white space
Bram Moolenaar <Bram@vim.org>
parents: 22238
diff changeset
2861 CheckScriptSuccess(lines)
9f6b8fdea159 patch 8.2.1671: Vim9: stray error for missing white space
Bram Moolenaar <Bram@vim.org>
parents: 22238
diff changeset
2862 enddef
9f6b8fdea159 patch 8.2.1671: Vim9: stray error for missing white space
Bram Moolenaar <Bram@vim.org>
parents: 22238
diff changeset
2863
20949
62912ad41aff patch 8.2.1026: Vim9: cannot break the line after "->"
Bram Moolenaar <Bram@vim.org>
parents: 20919
diff changeset
2864 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
2865 var range = range(
20949
62912ad41aff patch 8.2.1026: Vim9: cannot break the line after "->"
Bram Moolenaar <Bram@vim.org>
parents: 20919
diff changeset
2866 3)
22421
2765ae0ce02e patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents: 22419
diff changeset
2867 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
2868 ->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
2869 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
2870
20955
396fe712eb0f patch 8.2.1029: Vim9: cannot chain function calls with -> at line start
Bram Moolenaar <Bram@vim.org>
parents: 20953
diff changeset
2871 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
2872 ->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
2873 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
2874
396fe712eb0f patch 8.2.1029: Vim9: cannot chain function calls with -> at line start
Bram Moolenaar <Bram@vim.org>
parents: 20953
diff changeset
2875 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
2876 ->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
2877 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
2878
396fe712eb0f patch 8.2.1029: Vim9: cannot chain function calls with -> at line start
Bram Moolenaar <Bram@vim.org>
parents: 20953
diff changeset
2879 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
2880
396fe712eb0f patch 8.2.1029: Vim9: cannot chain function calls with -> at line start
Bram Moolenaar <Bram@vim.org>
parents: 20953
diff changeset
2881 ->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
2882 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
2883
396fe712eb0f patch 8.2.1029: Vim9: cannot chain function calls with -> at line start
Bram Moolenaar <Bram@vim.org>
parents: 20953
diff changeset
2884 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
2885 # comment
396fe712eb0f patch 8.2.1029: Vim9: cannot chain function calls with -> at line start
Bram Moolenaar <Bram@vim.org>
parents: 20953
diff changeset
2886 ->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
2887 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
2888
20949
62912ad41aff patch 8.2.1026: Vim9: cannot break the line after "->"
Bram Moolenaar <Bram@vim.org>
parents: 20919
diff changeset
2889 assert_equal('1', l[
62912ad41aff patch 8.2.1026: Vim9: cannot break the line after "->"
Bram Moolenaar <Bram@vim.org>
parents: 20919
diff changeset
2890 1])
62912ad41aff patch 8.2.1026: Vim9: cannot break the line after "->"
Bram Moolenaar <Bram@vim.org>
parents: 20919
diff changeset
2891
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 23070
diff changeset
2892 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
2893 assert_equal(33, d.
62912ad41aff patch 8.2.1026: Vim9: cannot break the line after "->"
Bram Moolenaar <Bram@vim.org>
parents: 20919
diff changeset
2894 one)
62912ad41aff patch 8.2.1026: Vim9: cannot break the line after "->"
Bram Moolenaar <Bram@vim.org>
parents: 20919
diff changeset
2895 enddef
62912ad41aff patch 8.2.1026: Vim9: cannot break the line after "->"
Bram Moolenaar <Bram@vim.org>
parents: 20919
diff changeset
2896
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2897 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
2898 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
2899 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
2900 endfunc
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2901
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2902 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
2903 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
2904 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
2905
21863
809b1e7fbd72 patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 21859
diff changeset
2906 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
2907 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
2908 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
2909 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
2910
21863
809b1e7fbd72 patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 21859
diff changeset
2911 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
2912 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
2913 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
2914
21863
809b1e7fbd72 patch 8.2.1481: Vim9: line number reported with error may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 21859
diff changeset
2915 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
2916 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
2917 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
2918 endfunc
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 21763
diff changeset
2919
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 21763
diff changeset
2920 " vim: shiftwidth=2 sts=2 expandtab