Mercurial > vim
annotate src/testdir/test_vim9_expr.vim @ 29157:a3564c0c9e06 v8.2.5098
patch 8.2.5098: spelldump test sometimes hangs
Commit: https://github.com/vim/vim/commit/fc9f0fd6d18c03d6420f84ebb374a373c830fbad
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jun 15 16:57:44 2022 +0100
patch 8.2.5098: spelldump test sometimes hangs
Problem: Spelldump test sometimes hangs.
Solution: Catch the problem of the spell file not being found to avoid
hanging in the download dialog.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 15 Jun 2022 18:00:03 +0200 |
parents | abdea69d21b6 |
children | 842690841d50 |
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 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4 import './vim9.vim' as v9 |
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 |
27901
dd7d94b911fa
patch 8.2.4476: operator name spelled wrong
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
15 def Test_expr1_ternary() |
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 |
23491
ac5ead954dcd
patch 8.2.2288: Vim9: line break and comment not always skipped
Bram Moolenaar <Bram@vim.org>
parents:
23446
diff
changeset
|
46 echo ['a'] + (1 ? ['b'] : ['c'] |
ac5ead954dcd
patch 8.2.2288: Vim9: line break and comment not always skipped
Bram Moolenaar <Bram@vim.org>
parents:
23446
diff
changeset
|
47 ) |
ac5ead954dcd
patch 8.2.2288: Vim9: line break and comment not always skipped
Bram Moolenaar <Bram@vim.org>
parents:
23446
diff
changeset
|
48 echo ['a'] + (1 ? ['b'] : ['c'] # comment |
ac5ead954dcd
patch 8.2.2288: Vim9: line break and comment not always skipped
Bram Moolenaar <Bram@vim.org>
parents:
23446
diff
changeset
|
49 ) |
ac5ead954dcd
patch 8.2.2288: Vim9: line break and comment not always skipped
Bram Moolenaar <Bram@vim.org>
parents:
23446
diff
changeset
|
50 |
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
|
51 # 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
|
52 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
|
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 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
|
55 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
|
56 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
|
57 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
|
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 RetOne: func(string): number = function('len') |
25126
b825efff9790
patch 8.2.3100: Vim9: no error when using type with unknown number of args
Bram Moolenaar <Bram@vim.org>
parents:
25094
diff
changeset
|
60 var RetTwo: func(string): number = function('charcol') |
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
|
61 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
|
62 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
|
63 |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
64 var X = g:FuncOne |
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
65 var Y = g:FuncTwo |
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
66 var Z = g:cond ? g:FuncOne : g:FuncTwo |
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
|
67 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
|
68 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
69 v9.CheckDefAndScriptSuccess(lines) |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
70 |
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
71 lines =<< trim END |
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
72 var Z = g:cond ? FuncOne : FuncTwo |
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
73 END |
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
74 v9.CheckDefAndScriptFailure(lines, ['E1001: Variable not found: FuncOne', 'E121: Undefined variable: FuncTwo']) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 |
27901
dd7d94b911fa
patch 8.2.4476: operator name spelled wrong
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
77 def Test_expr1_ternary_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
|
78 # 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
|
79 var lines =<< trim END |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
80 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
|
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('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
|
84 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
85 v9.CheckDefAndScriptSuccess(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
|
86 |
9d8634e91d1b
patch 8.2.1062: Vim9: no line break allowed inside "cond ? val1 : val2"
Bram Moolenaar <Bram@vim.org>
parents:
20992
diff
changeset
|
87 lines =<< trim END |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
88 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
|
89 ? 'yes' |
9d8634e91d1b
patch 8.2.1062: Vim9: no line break allowed inside "cond ? val1 : val2"
Bram Moolenaar <Bram@vim.org>
parents:
20992
diff
changeset
|
90 : 'no' |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
91 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
|
92 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
93 v9.CheckDefAndScriptSuccess(lines) |
21046
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
94 |
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
95 lines =<< trim END |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
96 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
|
97 'yes' : |
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
98 'no' |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
99 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
|
100 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
101 v9.CheckDefAndScriptSuccess(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
|
102 |
22580
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
103 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
|
104 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
|
105 'yes' : |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
106 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
107 '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
|
108 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
|
109 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
110 v9.CheckDefAndScriptSuccess(lines) |
22580
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
111 |
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 # 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
|
113 lines =<< trim END |
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 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
116 v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''?'' at "?1:2"', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
117 |
21644
7d3ba70a03f1
patch 8.2.1372: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21642
diff
changeset
|
118 lines =<< trim END |
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 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
121 v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
122 |
21644
7d3ba70a03f1
patch 8.2.1372: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21642
diff
changeset
|
123 lines =<< trim END |
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 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
126 v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
127 |
21644
7d3ba70a03f1
patch 8.2.1372: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21642
diff
changeset
|
128 lines =<< trim END |
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 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
131 v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after '':'' at ": 2"', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
132 |
21644
7d3ba70a03f1
patch 8.2.1372: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21642
diff
changeset
|
133 lines =<< trim END |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
134 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
|
135 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
136 v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) |
21925
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
137 |
22500
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
138 lines =<< trim END |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
139 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
|
140 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
141 v9.CheckDefAndScriptFailure(lines, 'E1135:', 1) |
22500
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
142 |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
143 lines =<< trim END |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
144 var name = [] ? 1 : 2 |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
145 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
146 v9.CheckDefExecAndScriptFailure(lines, 'E745:', 1) |
22500
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
147 |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
148 lines =<< trim END |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
149 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
|
150 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
151 v9.CheckDefExecAndScriptFailure(lines, 'E728:', 1) |
22500
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
152 |
21925
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
153 # 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
|
154 lines =<< trim END |
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
155 try |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22119
diff
changeset
|
156 eval('0 ? 1: 2') |
21925
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
157 catch |
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
158 endtry |
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
159 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
|
160 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
161 v9.CheckDefAndScriptSuccess(lines) |
21925
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
162 |
51d591dbb8df
patch 8.2.1512: failure after trinary expression fails
Bram Moolenaar <Bram@vim.org>
parents:
21909
diff
changeset
|
163 lines =<< trim END |
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 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
170 v9.CheckDefAndScriptSuccess(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 |
27901
dd7d94b911fa
patch 8.2.4476: operator name spelled wrong
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
173 func Test_expr1_ternary_fails() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
174 call v9.CheckDefAndScriptFailure(["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 '?'" |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
177 call v9.CheckDefAndScriptFailure(["var x = 1? 'one' : 'two'"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
178 call v9.CheckDefAndScriptFailure(["var x = 1 ?'one' : 'two'"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
179 call v9.CheckDefAndScriptFailure(["var x = 1?'one' : 'two'"], msg, 1) |
24713
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
180 let lines =<< trim END |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
181 var x = 1 |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
182 ?'one' : 'two' |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
183 # comment |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
184 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
185 call v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''?'' at "?''one'' : ''two''"', 2) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
186 |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
187 let msg = "White space required before and after ':'" |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
188 call v9.CheckDefAndScriptFailure(["var x = 1 ? 'one': 'two'"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
189 call v9.CheckDefAndScriptFailure(["var x = 1 ? 'one' :'two'"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
190 call v9.CheckDefAndScriptFailure(["var x = 1 ? 'one':'two'"], msg, 1) |
24713
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
191 let lines =<< trim END |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
192 var x = 1 ? 'one' |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
193 :'two' |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
194 # Comment |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
195 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
196 call v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after '':'' at ":''two''"', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
197 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
198 call v9.CheckDefAndScriptFailure(["var x = 'x' ? 'one' : 'two'"], 'E1135:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
199 call v9.CheckDefAndScriptFailure(["var x = 0z1234 ? 'one' : 'two'"], 'E974:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
200 call v9.CheckDefExecAndScriptFailure(["var x = [] ? 'one' : 'two'"], 'E745:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
201 call v9.CheckDefExecAndScriptFailure(["var x = {} ? 'one' : 'two'"], 'E728:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
202 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
203 call v9.CheckDefExecFailure(["var x = false ? "], 'E1097:', 3) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
204 call v9.CheckScriptFailure(['vim9script', "var x = false ? "], 'E15:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
205 call v9.CheckDefExecFailure(["var x = false ? 'one' : "], 'E1097:', 3) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
206 call v9.CheckScriptFailure(['vim9script', "var x = false ? 'one' : "], 'E15:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
207 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
208 call v9.CheckDefExecAndScriptFailure(["var x = true ? xxx : 'foo'"], ['E1001:', 'E121:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
209 call v9.CheckDefExecAndScriptFailure(["var x = false ? 'foo' : xxx"], ['E1001:', 'E121:'], 1) |
23106
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
210 |
22500
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
211 if has('float') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
212 call v9.CheckDefAndScriptFailure(["var x = 0.1 ? 'one' : 'two'"], 'E805:', 1) |
22500
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
213 endif |
ef8a3177edc1
patch 8.2.1798: Vim9: trinary operator condition is too permissive
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
214 |
21421
0f0fee4122d3
patch 8.2.1261: Vim9: common type of function not tested
Bram Moolenaar <Bram@vim.org>
parents:
21411
diff
changeset
|
215 " missing argument detected even when common type is used |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
216 call v9.CheckDefAndScriptFailure([ |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
217 \ 'var X = g:FuncOne', |
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
218 \ 'var Y = g:FuncTwo', |
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
219 \ 'var Z = g:cond ? g:FuncOne : g: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
|
220 \ '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
|
221 endfunc |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
222 |
22492
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
223 def Test_expr1_falsy() |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
224 var lines =<< trim END |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
225 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
|
226 assert_equal(123, 123 ?? 456) |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
227 assert_equal('yes', 'yes' ?? 456) |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
228 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
|
229 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
|
230 if has('float') |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
231 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
|
232 endif |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
233 |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
234 assert_equal(456, v:false ?? 456) |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
235 assert_equal(456, 0 ?? 456) |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
236 assert_equal(456, '' ?? 456) |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
237 assert_equal(456, [] ?? 456) |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
238 assert_equal(456, {} ?? 456) |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
239 if has('float') |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
240 assert_equal(456, 0.0 ?? 456) |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
241 endif |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
242 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
243 v9.CheckDefAndScriptSuccess(lines) |
22492
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
244 |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
245 var msg = "White space required before and after '??'" |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
246 call v9.CheckDefAndScriptFailure(["var x = 1?? 'one' : 'two'"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
247 call v9.CheckDefAndScriptFailure(["var x = 1 ??'one' : 'two'"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
248 call v9.CheckDefAndScriptFailure(["var x = 1??'one' : 'two'"], msg, 1) |
24713
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
249 lines =<< trim END |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
250 var x = 1 |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
251 ??'one' : 'two' |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
252 #comment |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
253 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
254 v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''??'' at "??''one'' : ''two''"', 2) |
22492
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
255 enddef |
0e03ef68e738
patch 8.2.1794: no falsy Coalescing operator
Bram Moolenaar <Bram@vim.org>
parents:
22482
diff
changeset
|
256 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
257 def g:Record(val: any): any |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
258 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
|
259 return val |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
260 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
261 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
262 " test || |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
263 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
|
264 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
|
265 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
|
266 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
|
267 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
|
268 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
|
269 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
|
270 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 !!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
|
272 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
|
273 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
|
274 || 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
|
275 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
|
276 |
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
|
277 g:vals = [] |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
278 assert_equal(true, g:Record(1) || g:Record(3)) |
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
|
279 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
|
280 |
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 = [] |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
282 assert_equal(true, g:Record(0) || g:Record(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
|
283 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
|
284 |
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
|
285 g:vals = [] |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
286 assert_equal(true, g:Record(0) || g:Record(true)) |
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
|
287 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
|
288 |
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 g:vals = [] |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
290 assert_equal(true, g:Record(0) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
291 || g:Record(1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
292 || g:Record(0)) |
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
|
293 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
|
294 |
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
|
295 g:vals = [] |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
296 assert_equal(true, g:Record(0) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
297 || g:Record(true) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
298 || g:Record(0)) |
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
|
299 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
|
300 |
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
|
301 g:vals = [] |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
302 assert_equal(true, g:Record(true) || g:Record(false)) |
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
|
303 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
|
304 |
52e64d340a98
patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents:
22860
diff
changeset
|
305 g:vals = [] |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
306 assert_equal(false, g:Record(0) || g:Record(false) || g:Record(0)) |
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
|
307 assert_equal([0, false, 0], g:vals) |
24430
fe71212fd202
patch 8.2.2755: Vim9: no error for using a number in a condition
Bram Moolenaar <Bram@vim.org>
parents:
24390
diff
changeset
|
308 |
fe71212fd202
patch 8.2.2755: Vim9: no error for using a number in a condition
Bram Moolenaar <Bram@vim.org>
parents:
24390
diff
changeset
|
309 g:vals = [] |
fe71212fd202
patch 8.2.2755: Vim9: no error for using a number in a condition
Bram Moolenaar <Bram@vim.org>
parents:
24390
diff
changeset
|
310 var x = 1 |
fe71212fd202
patch 8.2.2755: Vim9: no error for using a number in a condition
Bram Moolenaar <Bram@vim.org>
parents:
24390
diff
changeset
|
311 if x || true |
fe71212fd202
patch 8.2.2755: Vim9: no error for using a number in a condition
Bram Moolenaar <Bram@vim.org>
parents:
24390
diff
changeset
|
312 g:vals = [1] |
fe71212fd202
patch 8.2.2755: Vim9: no error for using a number in a condition
Bram Moolenaar <Bram@vim.org>
parents:
24390
diff
changeset
|
313 endif |
fe71212fd202
patch 8.2.2755: Vim9: no error for using a number in a condition
Bram Moolenaar <Bram@vim.org>
parents:
24390
diff
changeset
|
314 assert_equal([1], g:vals) |
fe71212fd202
patch 8.2.2755: Vim9: no error for using a number in a condition
Bram Moolenaar <Bram@vim.org>
parents:
24390
diff
changeset
|
315 |
fe71212fd202
patch 8.2.2755: Vim9: no error for using a number in a condition
Bram Moolenaar <Bram@vim.org>
parents:
24390
diff
changeset
|
316 g:vals = [] |
fe71212fd202
patch 8.2.2755: Vim9: no error for using a number in a condition
Bram Moolenaar <Bram@vim.org>
parents:
24390
diff
changeset
|
317 x = 3 |
fe71212fd202
patch 8.2.2755: Vim9: no error for using a number in a condition
Bram Moolenaar <Bram@vim.org>
parents:
24390
diff
changeset
|
318 if true || x |
fe71212fd202
patch 8.2.2755: Vim9: no error for using a number in a condition
Bram Moolenaar <Bram@vim.org>
parents:
24390
diff
changeset
|
319 g:vals = [1] |
fe71212fd202
patch 8.2.2755: Vim9: no error for using a number in a condition
Bram Moolenaar <Bram@vim.org>
parents:
24390
diff
changeset
|
320 endif |
fe71212fd202
patch 8.2.2755: Vim9: no error for using a number in a condition
Bram Moolenaar <Bram@vim.org>
parents:
24390
diff
changeset
|
321 assert_equal([1], g:vals) |
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
|
322 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
323 v9.CheckDefAndScriptSuccess(lines) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
324 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
325 |
21024
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
326 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
|
327 # 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
|
328 var lines =<< trim END |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
329 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
|
330 || 1 |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
331 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
|
332 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
333 v9.CheckDefAndScriptSuccess(lines) |
21024
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
334 |
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
335 lines =<< trim END |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
336 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
|
337 || v:true |
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
338 || v:false |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
339 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
|
340 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
341 v9.CheckDefAndScriptSuccess(lines) |
21046
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
342 |
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
343 lines =<< trim END |
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:false || |
21046
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
345 v:true || |
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
346 v:false |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
347 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
|
348 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
349 v9.CheckDefAndScriptSuccess(lines) |
21309
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
350 |
22580
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
351 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
|
352 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
|
353 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
354 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
|
355 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
356 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
|
357 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
|
358 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
359 v9.CheckDefAndScriptSuccess(lines) |
22580
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
360 |
21642
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
361 # 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
|
362 lines =<< trim END |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
363 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
|
364 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
365 v9.CheckDefExecAndScriptFailure(lines, 'E1004: White space required before and after ''||'' at "||v:true"', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
366 |
21642
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
367 lines =<< trim END |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
368 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
|
369 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
370 v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
371 |
21642
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
372 lines =<< trim END |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
373 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
|
374 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
375 v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) |
21024
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
376 enddef |
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
377 |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
378 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
|
379 var msg = "White space required before and after '||'" |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
380 v9.CheckDefAndScriptFailure(["var x = 1||0"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
381 v9.CheckDefAndScriptFailure(["var x = 1 ||0"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
382 v9.CheckDefAndScriptFailure(["var x = 1|| 0"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
383 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
384 v9.CheckDefFailure(["var x = false || "], 'E1097:', 3) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
385 v9.CheckScriptFailure(['vim9script', "var x = false || "], 'E15:', 2) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
386 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
387 # script does not fail, the second expression is skipped |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
388 v9.CheckDefFailure(["var x = 1 || xxx"], 'E1001:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
389 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
390 v9.CheckDefAndScriptFailure(["var x = [] || false"], ['E1012:', 'E745:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
391 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
392 v9.CheckDefAndScriptFailure(["if 'yes' || 0", 'echo 0', 'endif'], ['E1012: Type mismatch; expected bool but got string', 'E1135: Using a String as a Bool'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
393 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
394 v9.CheckDefAndScriptFailure(["var x = 3 || false"], ['E1012:', 'E1023:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
395 v9.CheckDefAndScriptFailure(["var x = false || 3"], ['E1012:', 'E1023:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
396 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
397 v9.CheckDefAndScriptFailure(["if 3"], 'E1023:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
398 v9.CheckDefExecAndScriptFailure(['var x = 3', 'if x', 'endif'], 'E1023:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
399 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
400 v9.CheckDefAndScriptFailure(["var x = [] || false"], ['E1012: Type mismatch; expected bool but got list<unknown>', 'E745:'], 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
401 |
24713
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
402 var lines =<< trim END |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
403 vim9script |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
404 echo false |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
405 ||true |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
406 # comment |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
407 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
408 v9.CheckScriptFailure(lines, 'E1004: White space required before and after ''||'' at "||true"', 3) |
25258
205a0126ac2d
patch 8.2.3165: Vim9: in a || expression the error line number may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
25252
diff
changeset
|
409 |
205a0126ac2d
patch 8.2.3165: Vim9: in a || expression the error line number may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
25252
diff
changeset
|
410 lines =<< trim END |
205a0126ac2d
patch 8.2.3165: Vim9: in a || expression the error line number may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
25252
diff
changeset
|
411 var x = false |
205a0126ac2d
patch 8.2.3165: Vim9: in a || expression the error line number may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
25252
diff
changeset
|
412 || false |
205a0126ac2d
patch 8.2.3165: Vim9: in a || expression the error line number may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
25252
diff
changeset
|
413 || a.b |
205a0126ac2d
patch 8.2.3165: Vim9: in a || expression the error line number may be wrong
Bram Moolenaar <Bram@vim.org>
parents:
25252
diff
changeset
|
414 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
415 v9.CheckDefFailure(lines, 'E1001:', 3) |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
416 enddef |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
417 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
418 " test && |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
419 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
|
420 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
|
421 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
|
422 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
|
423 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
|
424 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
|
425 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
|
426 && 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
|
427 && 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
|
428 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
|
429 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
|
430 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
|
431 |
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
|
432 g:vals = [] |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
433 assert_equal(true, g:Record(true) && g:Record(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
|
434 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
|
435 |
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
|
436 g:vals = [] |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
437 assert_equal(true, g:Record(1) && g:Record(true)) |
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
|
438 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
|
439 |
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
|
440 g:vals = [] |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
441 assert_equal(false, g:Record(0) && g:Record(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
|
442 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
|
443 |
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
|
444 g:vals = [] |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
445 assert_equal(false, g:Record(0) && g:Record(1) && g:Record(0)) |
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
|
446 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
|
447 |
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
|
448 g:vals = [] |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
449 assert_equal(false, g:Record(0) && g:Record(4) && g:Record(0)) |
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
|
450 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
|
451 |
52e64d340a98
patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents:
22860
diff
changeset
|
452 g:vals = [] |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
453 assert_equal(false, g:Record(1) && g:Record(true) && g:Record(0)) |
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
|
454 assert_equal([1, true, 0], g:vals) |
28899
2644e49d5147
patch 8.2.4972: Vim9: compilation fails when using dict member when skipping
Bram Moolenaar <Bram@vim.org>
parents:
28897
diff
changeset
|
455 |
2644e49d5147
patch 8.2.4972: Vim9: compilation fails when using dict member when skipping
Bram Moolenaar <Bram@vim.org>
parents:
28897
diff
changeset
|
456 var failed = false |
2644e49d5147
patch 8.2.4972: Vim9: compilation fails when using dict member when skipping
Bram Moolenaar <Bram@vim.org>
parents:
28897
diff
changeset
|
457 if false && g:a == g:b.c |
2644e49d5147
patch 8.2.4972: Vim9: compilation fails when using dict member when skipping
Bram Moolenaar <Bram@vim.org>
parents:
28897
diff
changeset
|
458 failed = true |
2644e49d5147
patch 8.2.4972: Vim9: compilation fails when using dict member when skipping
Bram Moolenaar <Bram@vim.org>
parents:
28897
diff
changeset
|
459 endif |
2644e49d5147
patch 8.2.4972: Vim9: compilation fails when using dict member when skipping
Bram Moolenaar <Bram@vim.org>
parents:
28897
diff
changeset
|
460 assert_false(failed) |
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
|
461 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
462 v9.CheckDefAndScriptSuccess(lines) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
463 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
464 |
21024
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
465 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
|
466 # 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
|
467 var lines =<< trim END |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
468 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
|
469 && 1 |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22492
diff
changeset
|
470 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
|
471 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
472 v9.CheckDefAndScriptSuccess(lines) |
21024
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
473 |
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
474 lines =<< trim END |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
475 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
|
476 && v:true |
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
477 && v:true |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
478 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
|
479 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
480 v9.CheckDefAndScriptSuccess(lines) |
21046
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
481 |
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
482 lines =<< trim END |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
483 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
|
484 v:true && |
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
485 v:true |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
486 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
|
487 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
488 v9.CheckDefAndScriptSuccess(lines) |
21309
31a3f4d408b9
patch 8.2.1205: Vim9: && and || work different when not compiled
Bram Moolenaar <Bram@vim.org>
parents:
21307
diff
changeset
|
489 |
22580
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
490 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
|
491 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
|
492 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
493 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
|
494 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
495 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
|
496 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
|
497 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
498 v9.CheckDefAndScriptSuccess(lines) |
22580
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
499 |
21642
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
500 # 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
|
501 lines =<< trim END |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
502 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
|
503 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
504 v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
505 |
21642
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
506 lines =<< trim END |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
507 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
|
508 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
509 v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''&&'' at "&&v:true"', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
510 |
21642
5ae89c8633ae
patch 8.2.1371: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21636
diff
changeset
|
511 lines =<< trim END |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
512 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
|
513 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
514 v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) |
21024
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
515 enddef |
02b03915855d
patch 8.2.1063: Vim9: no line break allowed before || or &&
Bram Moolenaar <Bram@vim.org>
parents:
21022
diff
changeset
|
516 |
24331
bd010982f0be
patch 8.2.2706: Vim9: wrong line number reported for boolean operator
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
517 def Test_expr3_fails() |
bd010982f0be
patch 8.2.2706: Vim9: wrong line number reported for boolean operator
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
518 var msg = "White space required before and after '&&'" |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
519 v9.CheckDefAndScriptFailure(["var x = 1&&0"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
520 v9.CheckDefAndScriptFailure(["var x = 1 &&0"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
521 v9.CheckDefAndScriptFailure(["var x = 1&& 0"], msg, 1) |
24713
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
522 var lines =<< trim END |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
523 var x = 1 |
25318
24bd79082d86
patch 8.2.3196: Vim9: bool expression with numbers only fails at runtime
Bram Moolenaar <Bram@vim.org>
parents:
25296
diff
changeset
|
524 &&0 |
24713
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
525 # comment |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
526 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
527 v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''&&'' at "&&0"', 2) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
528 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
529 g:vals = [] |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
530 v9.CheckDefAndScriptFailure(["if 'yes' && 0", 'echo 0', 'endif'], ['E1012: Type mismatch; expected bool but got string', 'E1135: Using a String as a Bool'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
531 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
532 v9.CheckDefExecAndScriptFailure(['assert_equal(false, g:Record(1) && g:Record(4) && g:Record(0))'], 'E1023: Using a Number as a Bool: 4', 1) |
24331
bd010982f0be
patch 8.2.2706: Vim9: wrong line number reported for boolean operator
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
533 |
24713
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
534 lines =<< trim END |
24331
bd010982f0be
patch 8.2.2706: Vim9: wrong line number reported for boolean operator
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
535 if 3 |
bd010982f0be
patch 8.2.2706: Vim9: wrong line number reported for boolean operator
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
536 && true |
bd010982f0be
patch 8.2.2706: Vim9: wrong line number reported for boolean operator
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
537 endif |
bd010982f0be
patch 8.2.2706: Vim9: wrong line number reported for boolean operator
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
538 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
539 v9.CheckDefAndScriptFailure(lines, ['E1012:', 'E1023:'], 1) |
25318
24bd79082d86
patch 8.2.3196: Vim9: bool expression with numbers only fails at runtime
Bram Moolenaar <Bram@vim.org>
parents:
25296
diff
changeset
|
540 |
24bd79082d86
patch 8.2.3196: Vim9: bool expression with numbers only fails at runtime
Bram Moolenaar <Bram@vim.org>
parents:
25296
diff
changeset
|
541 lines =<< trim END |
24bd79082d86
patch 8.2.3196: Vim9: bool expression with numbers only fails at runtime
Bram Moolenaar <Bram@vim.org>
parents:
25296
diff
changeset
|
542 if true |
24bd79082d86
patch 8.2.3196: Vim9: bool expression with numbers only fails at runtime
Bram Moolenaar <Bram@vim.org>
parents:
25296
diff
changeset
|
543 && 3 |
24bd79082d86
patch 8.2.3196: Vim9: bool expression with numbers only fails at runtime
Bram Moolenaar <Bram@vim.org>
parents:
25296
diff
changeset
|
544 endif |
24bd79082d86
patch 8.2.3196: Vim9: bool expression with numbers only fails at runtime
Bram Moolenaar <Bram@vim.org>
parents:
25296
diff
changeset
|
545 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
546 v9.CheckDefAndScriptFailure(lines, ['E1012:', 'E1023:'], 2) |
24331
bd010982f0be
patch 8.2.2706: Vim9: wrong line number reported for boolean operator
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
547 |
bd010982f0be
patch 8.2.2706: Vim9: wrong line number reported for boolean operator
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
548 lines =<< trim END |
bd010982f0be
patch 8.2.2706: Vim9: wrong line number reported for boolean operator
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
549 if 'yes' |
bd010982f0be
patch 8.2.2706: Vim9: wrong line number reported for boolean operator
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
550 && true |
bd010982f0be
patch 8.2.2706: Vim9: wrong line number reported for boolean operator
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
551 endif |
bd010982f0be
patch 8.2.2706: Vim9: wrong line number reported for boolean operator
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
552 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
553 v9.CheckDefAndScriptFailure(lines, ['E1012:', 'E1135: Using a String as a Bool'], 1) |
28852
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
554 |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
555 lines =<< trim END |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
556 var s = 'asdf' |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
557 echo true && s |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
558 END |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
559 v9.CheckDefAndScriptFailure(lines, ['E1012: Type mismatch; expected bool but got string', 'E1135: Using a String as a Bool: "asdf"']) |
24331
bd010982f0be
patch 8.2.2706: Vim9: wrong line number reported for boolean operator
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
560 enddef |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
561 |
21831
d8422de73113
patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
21828
diff
changeset
|
562 " 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
|
563 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
|
564 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
|
565 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
|
566 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
|
567 let anint = 10 |
21831
d8422de73113
patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
21828
diff
changeset
|
568 let theone = 1 |
d8422de73113
patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
21828
diff
changeset
|
569 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
|
570 if has('float') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
571 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
|
572 endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
573 let astring = 'asdf' |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
574 let ablob = 0z01ab |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
575 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
|
576 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
|
577 |
28171
b4c111ea83b1
patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
578 " test == comparator |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
579 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
|
580 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
|
581 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
|
582 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
|
583 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
|
584 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
|
585 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
|
586 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
|
587 == 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
|
588 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
|
589 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
|
590 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
|
591 |
52e64d340a98
patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents:
22860
diff
changeset
|
592 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
|
593 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
|
594 assert_equal(true, g:anone == v:none) |
23497
2247a2ce3630
patch 8.2.2291: Vim9: cannot use "null" for v:null
Bram Moolenaar <Bram@vim.org>
parents:
23491
diff
changeset
|
595 assert_equal(true, null == v:null) |
2247a2ce3630
patch 8.2.2291: Vim9: cannot use "null" for v:null
Bram Moolenaar <Bram@vim.org>
parents:
23491
diff
changeset
|
596 assert_equal(true, null == g:anull) |
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 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
|
598 |
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
|
599 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
|
600 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
|
601 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
|
602 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
|
603 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
|
604 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
|
605 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
|
606 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
|
607 |
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
|
608 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
|
609 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
|
610 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
|
611 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
|
612 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
|
613 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
|
614 |
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 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
|
616 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
|
617 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
|
618 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
|
619 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
|
620 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
|
621 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
|
622 |
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 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
|
624 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
|
625 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
|
626 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
|
627 |
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
|
628 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
|
629 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
|
630 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
|
631 |
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
|
632 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
|
633 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
|
634 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
|
635 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
|
636 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
|
637 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
|
638 |
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 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
|
640 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
|
641 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
|
642 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
|
643 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
|
644 |
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
|
645 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
|
646 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
|
647 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
|
648 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
|
649 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
|
650 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
|
651 |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
652 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
|
653 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
|
654 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
|
655 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
|
656 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
|
657 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
|
658 |
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
|
659 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
|
660 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
|
661 |
52e64d340a98
patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents:
22860
diff
changeset
|
662 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
|
663 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
|
664 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
|
665 |
26562
479022b3e7bd
patch 8.2.3810: Vim9: expr4 test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
666 if true |
479022b3e7bd
patch 8.2.3810: Vim9: expr4 test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
667 var OneFunc: func |
479022b3e7bd
patch 8.2.3810: Vim9: expr4 test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
668 var TwoFunc: func |
479022b3e7bd
patch 8.2.3810: Vim9: expr4 test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
669 OneFunc = function('len') |
479022b3e7bd
patch 8.2.3810: Vim9: expr4 test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
670 TwoFunc = function('len') |
479022b3e7bd
patch 8.2.3810: Vim9: expr4 test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
671 assert_equal(true, OneFunc('abc') == TwoFunc('123')) |
479022b3e7bd
patch 8.2.3810: Vim9: expr4 test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
672 endif |
479022b3e7bd
patch 8.2.3810: Vim9: expr4 test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
673 |
479022b3e7bd
patch 8.2.3810: Vim9: expr4 test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
674 # check this doesn't fail when skipped |
479022b3e7bd
patch 8.2.3810: Vim9: expr4 test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
25634
diff
changeset
|
675 if false |
22878
f304f84b81a6
patch 8.2.1986: expression test is flaky on Appveyor
Bram Moolenaar <Bram@vim.org>
parents:
22866
diff
changeset
|
676 var OneFunc: func |
f304f84b81a6
patch 8.2.1986: expression test is flaky on Appveyor
Bram Moolenaar <Bram@vim.org>
parents:
22866
diff
changeset
|
677 var TwoFunc: func |
f304f84b81a6
patch 8.2.1986: expression test is flaky on Appveyor
Bram Moolenaar <Bram@vim.org>
parents:
22866
diff
changeset
|
678 OneFunc = function('len') |
f304f84b81a6
patch 8.2.1986: expression test is flaky on Appveyor
Bram Moolenaar <Bram@vim.org>
parents:
22866
diff
changeset
|
679 TwoFunc = function('len') |
f304f84b81a6
patch 8.2.1986: expression test is flaky on Appveyor
Bram Moolenaar <Bram@vim.org>
parents:
22866
diff
changeset
|
680 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
|
681 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
|
682 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
683 v9.CheckDefAndScriptSuccess(lines) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
684 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
685 v9.CheckDefAndScriptFailure(["var x = 'a' == xxx"], ['E1001:', 'E121:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
686 v9.CheckDefFailure(["var x = 'a' == "], 'E1097:', 3) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
687 v9.CheckScriptFailure(['vim9script', "var x = 'a' == "], 'E15:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
688 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
689 v9.CheckDefExecAndScriptFailure(['var items: any', 'eval 1 + 1', 'eval 2 + 2', 'if items == []', 'endif'], ['E691:', 'E1072:'], 4) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
690 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
691 v9.CheckDefExecAndScriptFailure(['var x: any = "a"', 'echo x == true'], 'E1072: Cannot compare string with bool', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
692 v9.CheckDefExecAndScriptFailure(["var x: any = true", 'echo x == ""'], 'E1072: Cannot compare bool with string', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
693 v9.CheckDefExecAndScriptFailure(["var x: any = 99", 'echo x == true'], ['E1138', 'E1072:'], 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
694 v9.CheckDefExecAndScriptFailure(["var x: any = 'a'", 'echo x == 99'], ['E1030:', 'E1072:'], 2) |
26696
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
695 |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
696 lines =<< trim END |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
697 vim9script |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
698 var n: any = 2 |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
699 def Compare() |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
700 eval n == '3' |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
701 g:notReached = false |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
702 enddef |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
703 g:notReached = true |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
704 Compare() |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
705 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
706 v9.CheckScriptFailure(lines, 'E1030: Using a String as a Number: "3"') |
26696
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
707 assert_true(g:notReached) |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
708 |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
709 if has('float') |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
710 lines =<< trim END |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
711 vim9script |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
712 var n: any = 2.2 |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
713 def Compare() |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
714 eval n == '3' |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
715 g:notReached = false |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
716 enddef |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
717 g:notReached = true |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
718 Compare() |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
719 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
720 v9.CheckScriptFailure(lines, 'E892: Using a String as a Float') |
26696
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
721 assert_true(g:notReached) |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
722 endif |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
723 |
1cee572f2fd7
patch 8.2.3877: function does not abort after a type error in compare
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
724 unlet g:notReached |
25278
55c85c3a43a0
patch 8.2.3176: Vim9: no type error for comparing number with string
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
725 enddef |
55c85c3a43a0
patch 8.2.3176: Vim9: no type error for comparing number with string
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
726 |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
727 def Test_expr4_compare_null() |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
728 g:null_dict = test_null_dict() |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
729 g:not_null_list = [] |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
730 var lines =<< trim END |
28103
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
731 assert_false(true == null) |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
732 assert_false(false == null) |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
733 assert_false(null == true) |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
734 assert_false(null == false) |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
735 assert_true(true != null) |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
736 assert_true(false != null) |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
737 assert_true(null != true) |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
738 assert_true(null != false) |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
739 |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
740 assert_false(123 == null) |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
741 assert_false(0 == null) |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
742 assert_false(null == 123) |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
743 assert_false(null == 0) |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
744 assert_true(123 != null) |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
745 assert_true(0 != null) |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
746 assert_true(null != 123) |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
747 assert_true(null != 0) |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
748 |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
749 if has('float') |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
750 assert_false(12.3 == null) |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
751 assert_false(0.0 == null) |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
752 assert_false(null == 12.3) |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
753 assert_false(null == 0.0) |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
754 assert_true(12.3 != null) |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
755 assert_true(0.0 != null) |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
756 assert_true(null != 12.3) |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
757 assert_true(null != 0.0) |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
758 endif |
1615d305c71d
patch 8.2.4576: Vim9: error for comparing with null can be annoying
Bram Moolenaar <Bram@vim.org>
parents:
28031
diff
changeset
|
759 |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
760 assert_true(test_null_blob() == v:null) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
761 assert_true(null_blob == null) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
762 assert_true(v:null == test_null_blob()) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
763 assert_true(null == null_blob) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
764 assert_false(test_null_blob() != v:null) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
765 assert_false(null_blob != null) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
766 assert_false(v:null != test_null_blob()) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
767 assert_false(null != null_blob) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
768 |
28217
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
769 var nb = null_blob |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
770 assert_true(nb == null_blob) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
771 assert_true(nb == null) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
772 assert_true(null_blob == nb) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
773 assert_true(null == nb) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
774 |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
775 if has('channel') |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
776 assert_true(test_null_channel() == v:null) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
777 assert_true(null_channel == null) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
778 assert_true(v:null == test_null_channel()) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
779 assert_true(null == null_channel) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
780 assert_false(test_null_channel() != v:null) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
781 assert_false(null_channel != null) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
782 assert_false(v:null != test_null_channel()) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
783 assert_false(null != null_channel) |
28217
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
784 |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
785 var nc = null_channel |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
786 assert_true(nc == null_channel) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
787 assert_true(nc == null) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
788 assert_true(null_channel == nc) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
789 assert_true(null == nc) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
790 endif |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
791 |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
792 assert_true(test_null_dict() == v:null) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
793 assert_true(null_dict == null) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
794 assert_true(v:null == test_null_dict()) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
795 assert_true(null == null_dict) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
796 assert_false(test_null_dict() != v:null) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
797 assert_false(null_dict != null) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
798 assert_false(v:null != test_null_dict()) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
799 assert_false(null != null_dict) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
800 |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
801 assert_true(g:null_dict == v:null) |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
802 assert_true(v:null == g:null_dict) |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
803 assert_false(g:null_dict != v:null) |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
804 assert_false(v:null != g:null_dict) |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
805 |
28217
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
806 var nd = null_dict |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
807 assert_true(nd == null_dict) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
808 assert_true(nd == null) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
809 assert_true(null_dict == nd) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
810 assert_true(null == nd) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
811 |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
812 assert_true(test_null_function() == v:null) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
813 assert_true(null_function == null) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
814 assert_true(v:null == test_null_function()) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
815 assert_true(null == null_function) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
816 assert_false(test_null_function() != v:null) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
817 assert_false(null_function != null) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
818 assert_false(v:null != test_null_function()) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
819 assert_false(null != null_function) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
820 |
28217
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
821 var Nf = null_function |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
822 assert_true(Nf == null_function) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
823 assert_true(Nf == null) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
824 assert_true(null_function == Nf) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
825 assert_true(null == Nf) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
826 |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
827 if has('job') |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
828 assert_true(test_null_job() == v:null) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
829 assert_true(null_job == null) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
830 assert_true(v:null == test_null_job()) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
831 assert_true(null == null_job) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
832 assert_false(test_null_job() != v:null) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
833 assert_false(null_job != null) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
834 assert_false(v:null != test_null_job()) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
835 assert_false(null != null_job) |
28217
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
836 |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
837 var nj = null_job |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
838 assert_true(nj == null_job) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
839 assert_true(nj == null) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
840 assert_true(null_job == nj) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
841 assert_true(null == nj) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
842 endif |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
843 |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
844 assert_true(test_null_list() == v:null) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
845 assert_true(null_list == null) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
846 assert_true(v:null == test_null_list()) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
847 assert_true(null == null_list) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
848 assert_false(test_null_list() != v:null) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
849 assert_false(null_list != null) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
850 assert_false(v:null != test_null_list()) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
851 assert_false(null != null_list) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
852 |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
853 assert_false(g:not_null_list == v:null) |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
854 assert_false(v:null == g:not_null_list) |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
855 assert_true(g:not_null_list != v:null) |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
856 assert_true(v:null != g:not_null_list) |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
857 |
28217
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
858 var nl = null_list |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
859 assert_true(nl == null_list) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
860 assert_true(nl == null) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
861 assert_true(null_list == nl) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
862 assert_true(null == nl) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
863 |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
864 assert_true(test_null_partial() == v:null) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
865 assert_true(null_partial == null) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
866 assert_true(v:null == test_null_partial()) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
867 assert_true(null == null_partial) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
868 assert_false(test_null_partial() != v:null) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
869 assert_false(null_partial != null) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
870 assert_false(v:null != test_null_partial()) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
871 assert_false(null != null_partial) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
872 |
28217
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
873 var Np = null_partial |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
874 assert_true(Np == null_partial) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
875 assert_true(Np == null) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
876 assert_true(null_partial == Np) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
877 assert_true(null == Np) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
878 |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
879 assert_true(test_null_string() == v:null) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
880 assert_true(null_string == null) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
881 assert_true(v:null == test_null_string()) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
882 assert_true(null == null_string) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
883 assert_false(test_null_string() != v:null) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
884 assert_false(null_string != null) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
885 assert_false(v:null != test_null_string()) |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
886 assert_false(null != null_string) |
28019
53e2bf6032e5
patch 8.2.4534: Vim9: "is" operator with empty string and null returns true
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
887 |
53e2bf6032e5
patch 8.2.4534: Vim9: "is" operator with empty string and null returns true
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
888 assert_true(null_string is test_null_string()) |
53e2bf6032e5
patch 8.2.4534: Vim9: "is" operator with empty string and null returns true
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
889 assert_false(null_string is '') |
53e2bf6032e5
patch 8.2.4534: Vim9: "is" operator with empty string and null returns true
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
890 assert_false('' is null_string) |
53e2bf6032e5
patch 8.2.4534: Vim9: "is" operator with empty string and null returns true
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
891 assert_false(null_string isnot test_null_string()) |
53e2bf6032e5
patch 8.2.4534: Vim9: "is" operator with empty string and null returns true
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
892 assert_true(null_string isnot '') |
53e2bf6032e5
patch 8.2.4534: Vim9: "is" operator with empty string and null returns true
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
893 assert_true('' isnot null_string) |
28217
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
894 |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
895 var ns = null_string |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
896 assert_true(ns == null_string) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
897 assert_true(ns == null) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
898 assert_true(null_string == ns) |
662d2d5db9a6
patch 8.2.4634: Vim9: cannot initialize a variable to null_list
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
899 assert_true(null == ns) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
900 END |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
901 v9.CheckDefAndScriptSuccess(lines) |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
902 unlet g:null_dict |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
903 unlet g:not_null_list |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
904 |
28231
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
905 # variables declared at script level used in a :def function |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
906 lines =<< trim END |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
907 vim9script |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
908 |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
909 var l_decl: list<number> |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
910 var l_empty = [] |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
911 var l_null = null_list |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
912 |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
913 def TestList() |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
914 assert_false(l_decl == null) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
915 assert_false(l_decl is null_list) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
916 assert_false(l_empty == null) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
917 assert_false(l_empty is null_list) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
918 assert_true(l_null == null) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
919 assert_true(l_null is null_list) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
920 assert_true(l_null == null_list) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
921 |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
922 add(l_decl, 6) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
923 assert_equal([6], l_decl) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
924 add(l_empty, 7) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
925 assert_equal([7], l_empty) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
926 var caught = false |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
927 try |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
928 add(l_null, 9) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
929 catch /E1130:/ |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
930 caught = true |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
931 endtry |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
932 assert_true(caught) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
933 enddef |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
934 TestList() |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
935 |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
936 var b_decl: blob |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
937 var b_empty = 0z |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
938 var b_null = null_blob |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
939 |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
940 def TestBlob() |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
941 assert_false(b_decl == null) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
942 assert_false(b_decl is null_blob) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
943 assert_false(b_empty == null) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
944 assert_false(b_empty is null_blob) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
945 assert_true(b_null == null) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
946 assert_true(b_null is null_blob) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
947 assert_true(b_null == null_blob) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
948 |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
949 add(b_decl, 6) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
950 assert_equal(0z06, b_decl) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
951 add(b_empty, 7) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
952 assert_equal(0z07, b_empty) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
953 var caught = false |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
954 try |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
955 add(b_null, 9) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
956 catch /E1131:/ |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
957 caught = true |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
958 endtry |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
959 assert_true(caught) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
960 enddef |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
961 TestBlob() |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
962 |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
963 var d_decl: dict<number> |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
964 var d_empty = {} |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
965 var d_null = null_dict |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
966 |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
967 def TestDict() |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
968 assert_false(d_decl == null) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
969 assert_false(d_decl is null_dict) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
970 assert_false(d_empty == null) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
971 assert_false(d_empty is null_dict) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
972 assert_true(d_null == null) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
973 assert_true(d_null is null_dict) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
974 assert_true(d_null == null_dict) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
975 |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
976 d_decl['a'] = 6 |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
977 assert_equal({a: 6}, d_decl) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
978 d_empty['b'] = 7 |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
979 assert_equal({b: 7}, d_empty) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
980 var caught = false |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
981 try |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
982 d_null['c'] = 9 |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
983 catch /E1103:/ |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
984 caught = true |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
985 endtry |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
986 assert_true(caught) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
987 enddef |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
988 TestDict() |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
989 END |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
990 v9.CheckScriptSuccess(lines) |
66b245d84f37
patch 8.2.4642: Vim9: in :def function script var cannot be null
Bram Moolenaar <Bram@vim.org>
parents:
28217
diff
changeset
|
991 |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
992 lines =<< trim END |
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
993 var d: dict<func> = {f: null_function} |
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
994 assert_equal(null_function, d.f) |
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
995 END |
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
27924
diff
changeset
|
996 v9.CheckDefAndScriptSuccess(lines) |
28029
0ed38a4e028d
patch 8.2.4539: when comparing special v:none and v:null are handled the same
Bram Moolenaar <Bram@vim.org>
parents:
28019
diff
changeset
|
997 enddef |
0ed38a4e028d
patch 8.2.4539: when comparing special v:none and v:null are handled the same
Bram Moolenaar <Bram@vim.org>
parents:
28019
diff
changeset
|
998 |
0ed38a4e028d
patch 8.2.4539: when comparing special v:none and v:null are handled the same
Bram Moolenaar <Bram@vim.org>
parents:
28019
diff
changeset
|
999 def Test_expr4_compare_none() |
0ed38a4e028d
patch 8.2.4539: when comparing special v:none and v:null are handled the same
Bram Moolenaar <Bram@vim.org>
parents:
28019
diff
changeset
|
1000 var lines =<< trim END |
0ed38a4e028d
patch 8.2.4539: when comparing special v:none and v:null are handled the same
Bram Moolenaar <Bram@vim.org>
parents:
28019
diff
changeset
|
1001 assert_false('' == v:none) |
0ed38a4e028d
patch 8.2.4539: when comparing special v:none and v:null are handled the same
Bram Moolenaar <Bram@vim.org>
parents:
28019
diff
changeset
|
1002 assert_false('text' == v:none) |
0ed38a4e028d
patch 8.2.4539: when comparing special v:none and v:null are handled the same
Bram Moolenaar <Bram@vim.org>
parents:
28019
diff
changeset
|
1003 assert_true(v:none == v:none) |
0ed38a4e028d
patch 8.2.4539: when comparing special v:none and v:null are handled the same
Bram Moolenaar <Bram@vim.org>
parents:
28019
diff
changeset
|
1004 assert_false(v:none == '') |
0ed38a4e028d
patch 8.2.4539: when comparing special v:none and v:null are handled the same
Bram Moolenaar <Bram@vim.org>
parents:
28019
diff
changeset
|
1005 assert_false(v:none == 'text') |
0ed38a4e028d
patch 8.2.4539: when comparing special v:none and v:null are handled the same
Bram Moolenaar <Bram@vim.org>
parents:
28019
diff
changeset
|
1006 assert_true(v:none == v:none) |
0ed38a4e028d
patch 8.2.4539: when comparing special v:none and v:null are handled the same
Bram Moolenaar <Bram@vim.org>
parents:
28019
diff
changeset
|
1007 END |
0ed38a4e028d
patch 8.2.4539: when comparing special v:none and v:null are handled the same
Bram Moolenaar <Bram@vim.org>
parents:
28019
diff
changeset
|
1008 v9.CheckDefAndScriptSuccess(lines) |
0ed38a4e028d
patch 8.2.4539: when comparing special v:none and v:null are handled the same
Bram Moolenaar <Bram@vim.org>
parents:
28019
diff
changeset
|
1009 |
0ed38a4e028d
patch 8.2.4539: when comparing special v:none and v:null are handled the same
Bram Moolenaar <Bram@vim.org>
parents:
28019
diff
changeset
|
1010 v9.CheckDefAndScriptFailure(['echo [] == v:none'], 'E1072: Cannot compare list with special') |
0ed38a4e028d
patch 8.2.4539: when comparing special v:none and v:null are handled the same
Bram Moolenaar <Bram@vim.org>
parents:
28019
diff
changeset
|
1011 v9.CheckDefAndScriptFailure(['echo 123 == v:none'], 'E1072: Cannot compare number with special') |
0ed38a4e028d
patch 8.2.4539: when comparing special v:none and v:null are handled the same
Bram Moolenaar <Bram@vim.org>
parents:
28019
diff
changeset
|
1012 v9.CheckDefAndScriptFailure(['echo 0z00 == v:none'], 'E1072: Cannot compare blob with special') |
28031
4aa79224acd2
patch 8.2.4540: line number for error is off by one
Bram Moolenaar <Bram@vim.org>
parents:
28029
diff
changeset
|
1013 |
4aa79224acd2
patch 8.2.4540: line number for error is off by one
Bram Moolenaar <Bram@vim.org>
parents:
28029
diff
changeset
|
1014 lines =<< trim END |
4aa79224acd2
patch 8.2.4540: line number for error is off by one
Bram Moolenaar <Bram@vim.org>
parents:
28029
diff
changeset
|
1015 echo [] == v:none |
4aa79224acd2
patch 8.2.4540: line number for error is off by one
Bram Moolenaar <Bram@vim.org>
parents:
28029
diff
changeset
|
1016 |
4aa79224acd2
patch 8.2.4540: line number for error is off by one
Bram Moolenaar <Bram@vim.org>
parents:
28029
diff
changeset
|
1017 eval 0 + 0 |
4aa79224acd2
patch 8.2.4540: line number for error is off by one
Bram Moolenaar <Bram@vim.org>
parents:
28029
diff
changeset
|
1018 END |
4aa79224acd2
patch 8.2.4540: line number for error is off by one
Bram Moolenaar <Bram@vim.org>
parents:
28029
diff
changeset
|
1019 v9.CheckDefAndScriptFailure(lines, 'E1072:', 1) |
27924
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
1020 enddef |
e6e3abc28c7a
patch 8.2.4487: Vim9: cannot compare with v:null
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
1021 |
25278
55c85c3a43a0
patch 8.2.3176: Vim9: no type error for comparing number with string
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
1022 def Test_expr4_wrong_type() |
23555
0f7bb6f706f0
patch 8.2.2320: Vim9: no error for comparing bool with string
Bram Moolenaar <Bram@vim.org>
parents:
23551
diff
changeset
|
1023 for op in ['>', '>=', '<', '<=', '=~', '!~'] |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1024 v9.CheckDefExecAndScriptFailure([ |
23555
0f7bb6f706f0
patch 8.2.2320: Vim9: no error for comparing bool with string
Bram Moolenaar <Bram@vim.org>
parents:
23551
diff
changeset
|
1025 "var a: any = 'a'", |
0f7bb6f706f0
patch 8.2.2320: Vim9: no error for comparing bool with string
Bram Moolenaar <Bram@vim.org>
parents:
23551
diff
changeset
|
1026 'var b: any = true', |
0f7bb6f706f0
patch 8.2.2320: Vim9: no error for comparing bool with string
Bram Moolenaar <Bram@vim.org>
parents:
23551
diff
changeset
|
1027 'echo a ' .. op .. ' b'], 'E1072:', 3) |
0f7bb6f706f0
patch 8.2.2320: Vim9: no error for comparing bool with string
Bram Moolenaar <Bram@vim.org>
parents:
23551
diff
changeset
|
1028 endfor |
25278
55c85c3a43a0
patch 8.2.3176: Vim9: no type error for comparing number with string
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
1029 for op in ['>', '>=', '<', '<='] |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1030 v9.CheckDefExecAndScriptFailure([ |
25278
55c85c3a43a0
patch 8.2.3176: Vim9: no type error for comparing number with string
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
1031 "var n: any = 2", |
26650
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
26612
diff
changeset
|
1032 'echo n ' .. op .. ' "3"'], ['E1030:', 'E1072:'], 2) |
25278
55c85c3a43a0
patch 8.2.3176: Vim9: no type error for comparing number with string
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
1033 endfor |
55c85c3a43a0
patch 8.2.3176: Vim9: no type error for comparing number with string
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
1034 for op in ['=~', '!~'] |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1035 v9.CheckDefExecAndScriptFailure([ |
25278
55c85c3a43a0
patch 8.2.3176: Vim9: no type error for comparing number with string
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
1036 "var n: any = 2", |
55c85c3a43a0
patch 8.2.3176: Vim9: no type error for comparing number with string
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
1037 'echo n ' .. op .. ' "3"'], 'E1072:', 2) |
55c85c3a43a0
patch 8.2.3176: Vim9: no type error for comparing number with string
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
1038 endfor |
55c85c3a43a0
patch 8.2.3176: Vim9: no type error for comparing number with string
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
1039 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1040 v9.CheckDefAndScriptFailure([ |
25278
55c85c3a43a0
patch 8.2.3176: Vim9: no type error for comparing number with string
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
1041 'echo v:none == true'], 'E1072:', 1) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1042 v9.CheckDefAndScriptFailure([ |
25278
55c85c3a43a0
patch 8.2.3176: Vim9: no type error for comparing number with string
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
1043 'echo false >= true'], 'E1072:', 1) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1044 v9.CheckDefExecAndScriptFailure([ |
25278
55c85c3a43a0
patch 8.2.3176: Vim9: no type error for comparing number with string
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
1045 "var n: any = v:none", |
55c85c3a43a0
patch 8.2.3176: Vim9: no type error for comparing number with string
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
1046 'echo n == true'], 'E1072:', 2) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1047 v9.CheckDefExecAndScriptFailure([ |
25278
55c85c3a43a0
patch 8.2.3176: Vim9: no type error for comparing number with string
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
1048 "var n: any = v:none", |
55c85c3a43a0
patch 8.2.3176: Vim9: no type error for comparing number with string
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
1049 'echo n < true'], 'E1072:', 2) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1050 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1051 |
28171
b4c111ea83b1
patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
1052 " test != comparator |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1053 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
|
1054 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
|
1055 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
|
1056 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
|
1057 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
|
1058 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
|
1059 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
|
1060 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
|
1061 != 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
|
1062 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
|
1063 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
|
1064 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
|
1065 |
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
|
1066 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
|
1067 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
|
1068 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
|
1069 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
|
1070 |
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
|
1071 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
|
1072 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
|
1073 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
|
1074 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
|
1075 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
|
1076 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
|
1077 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
|
1078 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
|
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 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
|
1081 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
|
1082 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
|
1083 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
|
1084 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
|
1085 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
|
1086 |
52e64d340a98
patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents:
22860
diff
changeset
|
1087 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
|
1088 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
|
1089 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
|
1090 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
|
1091 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
|
1092 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
|
1093 endif |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1094 |
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
|
1095 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
|
1096 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
|
1097 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
|
1098 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
|
1099 |
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
|
1100 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
|
1101 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
|
1102 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
|
1103 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
|
1104 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
|
1105 set noignorecase |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1106 |
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
|
1107 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
|
1108 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
|
1109 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
|
1110 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
|
1111 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
|
1112 |
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
|
1113 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
|
1114 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
|
1115 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
|
1116 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
|
1117 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
|
1118 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
|
1119 |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
1120 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
|
1121 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
|
1122 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
|
1123 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
|
1124 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
|
1125 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
|
1126 |
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
|
1127 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
|
1128 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
|
1129 |
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
|
1130 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
|
1131 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
|
1132 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
|
1133 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1134 v9.CheckDefAndScriptSuccess(lines) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1135 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1136 |
28171
b4c111ea83b1
patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
1137 " test > comparator |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1138 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
|
1139 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
|
1140 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
|
1141 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
|
1142 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
|
1143 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
|
1144 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
|
1145 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
|
1146 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
|
1147 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
|
1148 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
|
1149 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
|
1150 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
|
1151 > 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
|
1152 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
|
1153 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
|
1154 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
|
1155 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
|
1156 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
|
1157 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
|
1158 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
|
1159 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1160 v9.CheckDefAndScriptSuccess(lines) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1161 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1162 |
28171
b4c111ea83b1
patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
1163 " test >= comparator |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1164 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
|
1165 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
|
1166 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
|
1167 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
|
1168 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
|
1169 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
|
1170 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
|
1171 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
|
1172 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
|
1173 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
|
1174 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
|
1175 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
|
1176 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
|
1177 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
|
1178 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
|
1179 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
|
1180 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1181 v9.CheckDefAndScriptSuccess(lines) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1182 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1183 |
28171
b4c111ea83b1
patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
1184 " test < comparator |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1185 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
|
1186 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
|
1187 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
|
1188 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
|
1189 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
|
1190 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
|
1191 < 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
|
1192 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
|
1193 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
|
1194 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
|
1195 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
|
1196 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
|
1197 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
|
1198 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
|
1199 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
|
1200 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
|
1201 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
|
1202 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1203 v9.CheckDefAndScriptSuccess(lines) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1204 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1205 |
28171
b4c111ea83b1
patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
1206 " test <= comparator |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1207 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
|
1208 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
|
1209 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
|
1210 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
|
1211 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
|
1212 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
|
1213 <= 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
|
1214 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
|
1215 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
|
1216 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
|
1217 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
|
1218 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
|
1219 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
|
1220 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
|
1221 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
|
1222 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
|
1223 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
|
1224 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
|
1225 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
|
1226 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
|
1227 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1228 v9.CheckDefAndScriptSuccess(lines) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1229 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1230 |
28171
b4c111ea83b1
patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
1231 " test =~ comparator |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1232 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
|
1233 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
|
1234 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
|
1235 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
|
1236 =~ '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
|
1237 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
|
1238 '[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
|
1239 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
|
1240 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
|
1241 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
|
1242 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
|
1243 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
|
1244 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1245 v9.CheckDefAndScriptSuccess(lines) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1246 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1247 |
28171
b4c111ea83b1
patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
1248 " test !~ comparator |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1249 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
|
1250 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
|
1251 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
|
1252 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
|
1253 !~ '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
|
1254 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
|
1255 '[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
|
1256 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1257 v9.CheckDefAndScriptSuccess(lines) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1258 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1259 |
28171
b4c111ea83b1
patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
1260 " test is comparator |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1261 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
|
1262 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
|
1263 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
|
1264 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
|
1265 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
|
1266 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
|
1267 other) |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
1268 |
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
|
1269 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
|
1270 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
|
1271 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
|
1272 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
|
1273 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
|
1274 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1275 v9.CheckDefAndScriptSuccess(lines) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1276 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1277 |
28171
b4c111ea83b1
patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents:
28156
diff
changeset
|
1278 " test isnot comparator |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1279 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
|
1280 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
|
1281 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
|
1282 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
|
1283 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
|
1284 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
|
1285 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
|
1286 other) |
19461
08ef11a81daa
patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents:
19451
diff
changeset
|
1287 |
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
|
1288 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
|
1289 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
|
1290 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
|
1291 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
|
1292 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
|
1293 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1294 v9.CheckDefAndScriptSuccess(lines) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1295 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1296 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1297 def g:RetVoid() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1298 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
|
1299 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1300 |
21737
a849c984b485
patch 8.2.1418: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
21733
diff
changeset
|
1301 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
|
1302 # 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
|
1303 var lines =<< trim END |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1304 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
|
1305 < 1 |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1306 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
|
1307 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1308 v9.CheckDefAndScriptSuccess(lines) |
21026
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
1309 |
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
1310 lines =<< trim END |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1311 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
|
1312 # comment |
21026
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
1313 != 123 |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1314 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
|
1315 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1316 v9.CheckDefAndScriptSuccess(lines) |
21026
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
1317 |
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
1318 lines =<< trim END |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1319 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
|
1320 123 |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1321 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
|
1322 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1323 v9.CheckDefAndScriptSuccess(lines) |
21046
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
1324 |
0ca7e04d39e3
patch 8.2.1074: Vim9: no line break allowed after some operators
Bram Moolenaar <Bram@vim.org>
parents:
21044
diff
changeset
|
1325 lines =<< trim END |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1326 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
|
1327 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
|
1328 is list |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1329 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
|
1330 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1331 v9.CheckDefAndScriptSuccess(lines) |
21026
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
1332 |
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
1333 lines =<< trim END |
22580
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1334 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
|
1335 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
|
1336 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1337 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
|
1338 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
|
1339 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1340 v9.CheckDefAndScriptSuccess(lines) |
22580
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1341 |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1342 lines =<< trim END |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1343 var myblob = 0z1234 |
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1344 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
|
1345 isnot 0z11 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1346 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
|
1347 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1348 v9.CheckDefAndScriptSuccess(lines) |
21251
d1215fcdbca8
patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21248
diff
changeset
|
1349 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
1350 # 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
|
1351 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
|
1352 echo '' == 0 |
d1215fcdbca8
patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21248
diff
changeset
|
1353 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1354 v9.CheckDefAndScriptFailure(lines, 'E1072:', 1) |
21251
d1215fcdbca8
patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21248
diff
changeset
|
1355 |
d1215fcdbca8
patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21248
diff
changeset
|
1356 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
|
1357 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
|
1358 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1359 v9.CheckDefAndScriptFailure(lines, 'Cannot compare bool with bool', 1) |
21251
d1215fcdbca8
patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21248
diff
changeset
|
1360 |
d1215fcdbca8
patch 8.2.1176: Vim9: not enough type checking in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21248
diff
changeset
|
1361 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
|
1362 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
|
1363 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1364 v9.CheckDefAndScriptFailure(lines, 'Cannot use "is" with number', 1) |
21425
a6c316ef161a
patch 8.2.1263: Vim9: comperators use 'ignorecase' in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
21421
diff
changeset
|
1365 |
21636
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
1366 # 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
|
1367 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
|
1368 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
|
1369 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1370 v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''>'' at ">3"', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1371 |
21636
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
1372 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
|
1373 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
|
1374 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1375 v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1376 |
21636
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
1377 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
|
1378 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
|
1379 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1380 v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1381 |
21636
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
1382 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
|
1383 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
|
1384 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1385 v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1386 |
21636
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
1387 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
|
1388 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
|
1389 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1390 v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''!='' at "!=3"', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1391 |
21636
dcfcb6163f3d
patch 8.2.1368: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21634
diff
changeset
|
1392 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
|
1393 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
|
1394 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1395 v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) |
21737
a849c984b485
patch 8.2.1418: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
21733
diff
changeset
|
1396 |
24713
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
1397 for op in ['==', '>', '>=', '<', '<=', '=~', '!~', 'is', 'isnot'] |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
1398 lines = ["echo 'aaa'", op .. "'bbb'", '# comment'] |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
1399 var msg = printf("E1004: White space required before and after '%s'", op) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1400 v9.CheckDefAndScriptFailure(lines, msg, 2) |
24713
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
1401 endfor |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
1402 |
21737
a849c984b485
patch 8.2.1418: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
21733
diff
changeset
|
1403 lines =<< trim END |
a849c984b485
patch 8.2.1418: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
21733
diff
changeset
|
1404 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
|
1405 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1406 v9.CheckDefAndScriptSuccess(lines) |
21837
2b941fbab4d9
patch 8.2.1468: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
1407 |
2b941fbab4d9
patch 8.2.1468: Vim9: invalid error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
21833
diff
changeset
|
1408 lines =<< trim END |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1409 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
|
1410 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
|
1411 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1412 v9.CheckDefAndScriptSuccess(lines) |
21026
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
1413 enddef |
fe2ed85db946
patch 8.2.1064: Vim9: no line break allowed before comperators
Bram Moolenaar <Bram@vim.org>
parents:
21024
diff
changeset
|
1414 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1415 func Test_expr4_fails() |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1416 let msg = "White space required before and after '>'" |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1417 call v9.CheckDefAndScriptFailure(["var x = 1>2"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1418 call v9.CheckDefAndScriptFailure(["var x = 1 >2"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1419 call v9.CheckDefAndScriptFailure(["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
|
1420 |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1421 let msg = "White space required before and after '=='" |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1422 call v9.CheckDefAndScriptFailure(["var x = 1==2"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1423 call v9.CheckDefAndScriptFailure(["var x = 1 ==2"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1424 call v9.CheckDefAndScriptFailure(["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
|
1425 |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1426 let msg = "White space required before and after 'is'" |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1427 call v9.CheckDefAndScriptFailure(["var x = '1'is'2'"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1428 call v9.CheckDefAndScriptFailure(["var x = '1' is'2'"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1429 call v9.CheckDefAndScriptFailure(["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
|
1430 |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1431 let msg = "White space required before and after 'isnot'" |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1432 call v9.CheckDefAndScriptFailure(["var x = '1'isnot'2'"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1433 call v9.CheckDefAndScriptFailure(["var x = '1' isnot'2'"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1434 call v9.CheckDefAndScriptFailure(["var x = '1'isnot '2'"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1435 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1436 call v9.CheckDefAndScriptFailure(["var x = 1 is# 2"], 'E15:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1437 call v9.CheckDefAndScriptFailure(["var x = 1 is? 2"], 'E15:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1438 call v9.CheckDefAndScriptFailure(["var x = 1 isnot# 2"], 'E15:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1439 call v9.CheckDefAndScriptFailure(["var x = 1 isnot? 2"], 'E15:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1440 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1441 call v9.CheckDefAndScriptFailure(["var x = 1 == '2'"], 'Cannot compare number with string', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1442 call v9.CheckDefAndScriptFailure(["var x = '1' == 2"], 'Cannot compare string with number', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1443 call v9.CheckDefAndScriptFailure(["var x = 1 == g:RetVoid()"], 'Cannot compare number with void', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1444 call v9.CheckDefAndScriptFailure(["var x = g:RetVoid() == 1"], 'Cannot compare void with number', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1445 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1446 call v9.CheckDefAndScriptFailure(["var x = true > false"], 'Cannot compare bool with bool', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1447 call v9.CheckDefAndScriptFailure(["var x = true >= false"], 'Cannot compare bool with bool', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1448 call v9.CheckDefAndScriptFailure(["var x = true < false"], 'Cannot compare bool with bool', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1449 call v9.CheckDefAndScriptFailure(["var x = true <= false"], 'Cannot compare bool with bool', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1450 call v9.CheckDefAndScriptFailure(["var x = true =~ false"], 'Cannot compare bool with bool', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1451 call v9.CheckDefAndScriptFailure(["var x = true !~ false"], 'Cannot compare bool with bool', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1452 call v9.CheckDefAndScriptFailure(["var x = true is false"], 'Cannot use "is" with bool', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1453 call v9.CheckDefAndScriptFailure(["var x = true isnot false"], 'Cannot use "isnot" with bool', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1454 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1455 call v9.CheckDefAndScriptFailure(["var x = v:none is v:null"], 'Cannot use "is" with special', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1456 call v9.CheckDefAndScriptFailure(["var x = v:none isnot v:null"], 'Cannot use "isnot" with special', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1457 call v9.CheckDefAndScriptFailure(["var x = 123 is 123"], 'Cannot use "is" with number', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1458 call v9.CheckDefAndScriptFailure(["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
|
1459 if has('float') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1460 call v9.CheckDefAndScriptFailure(["var x = 1.3 is 1.3"], 'Cannot use "is" with float', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1461 call v9.CheckDefAndScriptFailure(["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
|
1462 endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1463 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1464 call v9.CheckDefAndScriptFailure(["var x = 0za1 > 0z34"], 'Cannot compare blob with blob', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1465 call v9.CheckDefAndScriptFailure(["var x = 0za1 >= 0z34"], 'Cannot compare blob with blob', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1466 call v9.CheckDefAndScriptFailure(["var x = 0za1 < 0z34"], 'Cannot compare blob with blob', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1467 call v9.CheckDefAndScriptFailure(["var x = 0za1 <= 0z34"], 'Cannot compare blob with blob', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1468 call v9.CheckDefAndScriptFailure(["var x = 0za1 =~ 0z34"], 'Cannot compare blob with blob', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1469 call v9.CheckDefAndScriptFailure(["var x = 0za1 !~ 0z34"], 'Cannot compare blob with blob', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1470 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1471 call v9.CheckDefAndScriptFailure(["var x = [13] > [88]"], 'Cannot compare list with list', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1472 call v9.CheckDefAndScriptFailure(["var x = [13] >= [88]"], 'Cannot compare list with list', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1473 call v9.CheckDefAndScriptFailure(["var x = [13] < [88]"], 'Cannot compare list with list', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1474 call v9.CheckDefAndScriptFailure(["var x = [13] <= [88]"], 'Cannot compare list with list', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1475 call v9.CheckDefAndScriptFailure(["var x = [13] =~ [88]"], 'Cannot compare list with list', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1476 call v9.CheckDefAndScriptFailure(["var x = [13] !~ [88]"], 'Cannot compare list with list', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1477 |
28751
0c5c6a693d12
patch 8.2.4900: Vim9 expression test fails without the job feature
Bram Moolenaar <Bram@vim.org>
parents:
28735
diff
changeset
|
1478 if has('job') |
0c5c6a693d12
patch 8.2.4900: Vim9 expression test fails without the job feature
Bram Moolenaar <Bram@vim.org>
parents:
28735
diff
changeset
|
1479 call v9.CheckDefAndScriptFailure(['var j: job', 'var chan: channel', 'var r = j == chan'], 'Cannot compare job with channel', 3) |
0c5c6a693d12
patch 8.2.4900: Vim9 expression test fails without the job feature
Bram Moolenaar <Bram@vim.org>
parents:
28735
diff
changeset
|
1480 call v9.CheckDefAndScriptFailure(['var j: job', 'var x: list<any>', 'var r = j == x'], 'Cannot compare job with list', 3) |
0c5c6a693d12
patch 8.2.4900: Vim9 expression test fails without the job feature
Bram Moolenaar <Bram@vim.org>
parents:
28735
diff
changeset
|
1481 call v9.CheckDefAndScriptFailure(['var j: job', 'var Xx: func', 'var r = j == Xx'], 'Cannot compare job with func', 3) |
0c5c6a693d12
patch 8.2.4900: Vim9 expression test fails without the job feature
Bram Moolenaar <Bram@vim.org>
parents:
28735
diff
changeset
|
1482 call v9.CheckDefAndScriptFailure(['var j: job', 'var Xx: func', 'var r = j == Xx'], 'Cannot compare job with func', 3) |
0c5c6a693d12
patch 8.2.4900: Vim9 expression test fails without the job feature
Bram Moolenaar <Bram@vim.org>
parents:
28735
diff
changeset
|
1483 endif |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1484 endfunc |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1485 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
1486 " test bitwise left and right shift operators |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
1487 " The tests for this is in test_expr.vim (Test_bitwise_shift) |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
1488 " def Test_expr5() |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
1489 " enddef |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
1490 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1491 " test addition, subtraction, concatenation |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
1492 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
|
1493 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
|
1494 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
|
1495 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
|
1496 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
|
1497 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
|
1498 + 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
|
1499 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
|
1500 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
|
1501 |
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
|
1502 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
|
1503 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
|
1504 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
|
1505 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
|
1506 - 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
|
1507 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
|
1508 |
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
|
1509 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
|
1510 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
|
1511 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
|
1512 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
|
1513 .. 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
|
1514 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
|
1515 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
|
1516 |
23438
4c6ebf531284
patch 8.2.2262: Vim9: converting bool to string prefixes v:
Bram Moolenaar <Bram@vim.org>
parents:
23436
diff
changeset
|
1517 assert_equal('atrue', 'a' .. true) |
4c6ebf531284
patch 8.2.2262: Vim9: converting bool to string prefixes v:
Bram Moolenaar <Bram@vim.org>
parents:
23436
diff
changeset
|
1518 assert_equal('afalse', 'a' .. false) |
23497
2247a2ce3630
patch 8.2.2291: Vim9: cannot use "null" for v:null
Bram Moolenaar <Bram@vim.org>
parents:
23491
diff
changeset
|
1519 assert_equal('anull', 'a' .. v:null) |
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
|
1520 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
|
1521 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
|
1522 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
|
1523 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
|
1524 |
23806
c0f2c6c56147
patch 8.2.2444: Vim9: compile error with combination of operator and list
Bram Moolenaar <Bram@vim.org>
parents:
23673
diff
changeset
|
1525 assert_equal(3, 1 + [2, 3, 4][0]) |
c0f2c6c56147
patch 8.2.2444: Vim9: compile error with combination of operator and list
Bram Moolenaar <Bram@vim.org>
parents:
23673
diff
changeset
|
1526 assert_equal(5, 2 + {key: 3}['key']) |
c0f2c6c56147
patch 8.2.2444: Vim9: compile error with combination of operator and list
Bram Moolenaar <Bram@vim.org>
parents:
23673
diff
changeset
|
1527 |
23438
4c6ebf531284
patch 8.2.2262: Vim9: converting bool to string prefixes v:
Bram Moolenaar <Bram@vim.org>
parents:
23436
diff
changeset
|
1528 set digraph |
4c6ebf531284
patch 8.2.2262: Vim9: converting bool to string prefixes v:
Bram Moolenaar <Bram@vim.org>
parents:
23436
diff
changeset
|
1529 assert_equal('val: true', 'val: ' .. &digraph) |
4c6ebf531284
patch 8.2.2262: Vim9: converting bool to string prefixes v:
Bram Moolenaar <Bram@vim.org>
parents:
23436
diff
changeset
|
1530 set nodigraph |
4c6ebf531284
patch 8.2.2262: Vim9: converting bool to string prefixes v:
Bram Moolenaar <Bram@vim.org>
parents:
23436
diff
changeset
|
1531 assert_equal('val: false', 'val: ' .. &digraph) |
4c6ebf531284
patch 8.2.2262: Vim9: converting bool to string prefixes v:
Bram Moolenaar <Bram@vim.org>
parents:
23436
diff
changeset
|
1532 |
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
|
1533 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
|
1534 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
|
1535 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
|
1536 + 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
|
1537 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
|
1538 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
|
1539 |
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
|
1540 # 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
|
1541 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
|
1542 &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
|
1543 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
|
1544 &path = save_path |
21903
1fc2ffadf412
patch 8.2.1501: Vim9: concatenating to constant reverses order
Bram Moolenaar <Bram@vim.org>
parents:
21865
diff
changeset
|
1545 |
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
|
1546 @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
|
1547 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
|
1548 |
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
|
1549 $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
|
1550 assert_equal('aenv', 'a' .. $ENVVAR) |
23515
8cce160b9183
patch 8.2.2300: Vim9: wrong order on type stack when using dict
Bram Moolenaar <Bram@vim.org>
parents:
23497
diff
changeset
|
1551 |
8cce160b9183
patch 8.2.2300: Vim9: wrong order on type stack when using dict
Bram Moolenaar <Bram@vim.org>
parents:
23497
diff
changeset
|
1552 assert_equal('val', '' .. {key: 'val'}['key']) |
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
|
1553 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1554 v9.CheckDefAndScriptSuccess(lines) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1555 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1556 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
1557 def Test_expr6_vim9script() |
21546
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1558 # 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
|
1559 var lines =<< trim END |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1560 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
|
1561 + 77 |
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1562 - 22 |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1563 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
|
1564 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1565 v9.CheckDefAndScriptSuccess(lines) |
20992
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1566 |
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1567 lines =<< trim END |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1568 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
|
1569 77 - |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1570 22 |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1571 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
|
1572 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1573 v9.CheckDefAndScriptSuccess(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
|
1574 |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1575 lines =<< trim END |
22580
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1576 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
|
1577 77 - |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1578 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1579 22 |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1580 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
|
1581 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1582 v9.CheckDefAndScriptSuccess(lines) |
22580
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1583 |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1584 lines =<< trim END |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1585 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
|
1586 .. 'two' |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1587 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
|
1588 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1589 v9.CheckDefAndScriptSuccess(lines) |
21546
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1590 |
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1591 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
|
1592 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
|
1593 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1594 v9.CheckDefAndScriptFailure(lines, 'E15:', 1) |
21546
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1595 |
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1596 lines =<< trim END |
22681
674ba3200e1f
patch 8.2.1889: Vim9: errornous error for missing white space after {}
Bram Moolenaar <Bram@vim.org>
parents:
22639
diff
changeset
|
1597 echo {} - 22 |
674ba3200e1f
patch 8.2.1889: Vim9: errornous error for missing white space after {}
Bram Moolenaar <Bram@vim.org>
parents:
22639
diff
changeset
|
1598 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1599 v9.CheckDefAndScriptFailure(lines, ['E1036:', 'E728:'], 1) |
22683
5cbcd3768125
patch 8.2.1890: Vim9: strange error for subtracting from a list
Bram Moolenaar <Bram@vim.org>
parents:
22681
diff
changeset
|
1600 |
5cbcd3768125
patch 8.2.1890: Vim9: strange error for subtracting from a list
Bram Moolenaar <Bram@vim.org>
parents:
22681
diff
changeset
|
1601 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
|
1602 echo [] - 33 |
5cbcd3768125
patch 8.2.1890: Vim9: strange error for subtracting from a list
Bram Moolenaar <Bram@vim.org>
parents:
22681
diff
changeset
|
1603 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1604 v9.CheckDefAndScriptFailure(lines, ['E1036:', 'E745:'], 1) |
22683
5cbcd3768125
patch 8.2.1890: Vim9: strange error for subtracting from a list
Bram Moolenaar <Bram@vim.org>
parents:
22681
diff
changeset
|
1605 |
5cbcd3768125
patch 8.2.1890: Vim9: strange error for subtracting from a list
Bram Moolenaar <Bram@vim.org>
parents:
22681
diff
changeset
|
1606 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
|
1607 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
|
1608 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1609 v9.CheckDefAndScriptFailure(lines, ['E1036', 'E974:'], 1) |
22681
674ba3200e1f
patch 8.2.1889: Vim9: errornous error for missing white space after {}
Bram Moolenaar <Bram@vim.org>
parents:
22639
diff
changeset
|
1610 |
674ba3200e1f
patch 8.2.1889: Vim9: errornous error for missing white space after {}
Bram Moolenaar <Bram@vim.org>
parents:
22639
diff
changeset
|
1611 lines =<< trim END |
21546
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1612 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
|
1613 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1614 v9.CheckDefAndScriptFailure(lines, 'E15:', 1) |
21546
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1615 |
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1616 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
|
1617 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
|
1618 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1619 v9.CheckDefAndScriptFailure(lines, 'E15:', 1) |
21546
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1620 |
4d3e983313dc
patch 8.2.1323: Vim9: invalid operators only rejected in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1621 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
|
1622 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
|
1623 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1624 v9.CheckDefAndScriptFailure(lines, 'E15:', 1) |
21630
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1625 |
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1626 # 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
|
1627 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
|
1628 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
|
1629 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1630 v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) |
21630
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1631 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
|
1632 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
|
1633 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1634 v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1635 |
21630
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1636 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
|
1637 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
|
1638 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1639 v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) |
21630
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1640 |
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1641 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
|
1642 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
|
1643 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1644 v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''..'' at "..''b''"', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1645 |
21630
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1646 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
|
1647 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
|
1648 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1649 v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1650 |
21630
3c6c52fbc8ea
patch 8.2.1365: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21614
diff
changeset
|
1651 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
|
1652 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
|
1653 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1654 v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''..'' at ".. ''b''"', 1) |
24707
ad7cac75b2d1
patch 8.2.2892: error message contains random characters
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
1655 |
ad7cac75b2d1
patch 8.2.2892: error message contains random characters
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
1656 lines =<< trim END |
ad7cac75b2d1
patch 8.2.2892: error message contains random characters
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
1657 echo 'a' |
ad7cac75b2d1
patch 8.2.2892: error message contains random characters
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
1658 ..'b' |
ad7cac75b2d1
patch 8.2.2892: error message contains random characters
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
1659 # comment |
ad7cac75b2d1
patch 8.2.2892: error message contains random characters
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
1660 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1661 v9.CheckDefAndScriptFailure(lines, 'E1004: White space required before and after ''..'' at "..''b''"', 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
|
1662 |
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1663 # 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
|
1664 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
|
1665 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
|
1666 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1667 v9.CheckDefAndScriptFailure(lines, ['E1105:', 'E730:'], 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1668 |
21771
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1669 lines =<< trim END |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
1670 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
|
1671 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1672 v9.CheckDefAndScriptFailure(lines, ['E1105:', 'E731:'], 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1673 |
21771
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1674 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
|
1675 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
|
1676 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1677 v9.CheckDefAndScriptFailure(lines, ['E1105:', 'E908:'], 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1678 |
21771
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1679 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
|
1680 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
|
1681 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1682 v9.CheckDefAndScriptFailure(lines, ['E1105:', 'E976:'], 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1683 |
21771
fcf978444298
patch 8.2.1435: Vim9: always converting to string for ".." leads to mistakes
Bram Moolenaar <Bram@vim.org>
parents:
21769
diff
changeset
|
1684 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
|
1685 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
|
1686 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1687 v9.CheckDefAndScriptFailure(lines, ['E1105:', 'E729:'], 1) |
24063
d8f3a993dc9a
patch 8.2.2573: Vim9: using inalid pointer for error message
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1688 |
d8f3a993dc9a
patch 8.2.2573: Vim9: using inalid pointer for error message
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1689 lines =<< trim END |
d8f3a993dc9a
patch 8.2.2573: Vim9: using inalid pointer for error message
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1690 new |
d8f3a993dc9a
patch 8.2.2573: Vim9: using inalid pointer for error message
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1691 ['']->setline(1) |
d8f3a993dc9a
patch 8.2.2573: Vim9: using inalid pointer for error message
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1692 /pattern |
d8f3a993dc9a
patch 8.2.2573: Vim9: using inalid pointer for error message
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1693 |
d8f3a993dc9a
patch 8.2.2573: Vim9: using inalid pointer for error message
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1694 eval 0 |
d8f3a993dc9a
patch 8.2.2573: Vim9: using inalid pointer for error message
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1695 bwipe! |
d8f3a993dc9a
patch 8.2.2573: Vim9: using inalid pointer for error message
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1696 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1697 v9.CheckDefAndScriptFailure(lines, "E1004: White space required before and after '/' at \"/pattern", 3) |
24713
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
1698 |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
1699 for op in ['+', '-'] |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
1700 lines = ['var x = 1', op .. '2', '# comment'] |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
1701 var msg = printf("E1004: White space required before and after '%s' at \"%s2\"", op, op) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1702 v9.CheckDefAndScriptFailure(lines, msg, 2) |
24713
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
1703 endfor |
22119
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1704 enddef |
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1705 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
1706 def Test_expr6_vim9script_channel() |
22119
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1707 if !has('channel') |
25545
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25403
diff
changeset
|
1708 MissingFeature 'channel' |
22119
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1709 else |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
1710 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
|
1711 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
|
1712 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1713 v9.CheckDefAndScriptFailure(lines, ['E1105:', 'E908:'], 1) |
22119
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1714 lines =<< trim END |
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1715 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
|
1716 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1717 v9.CheckDefAndScriptFailure(lines, ['E1105:', 'E908:'], 1) |
22119
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1718 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
|
1719 enddef |
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1720 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
1721 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
|
1722 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
|
1723 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
|
1724 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
|
1725 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
|
1726 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
|
1727 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
|
1728 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
|
1729 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
|
1730 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
|
1731 + 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
|
1732 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
|
1733 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
|
1734 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
|
1735 |
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
|
1736 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
|
1737 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
|
1738 - 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
|
1739 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
|
1740 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
|
1741 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
|
1742 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
|
1743 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
|
1744 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1745 v9.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
|
1746 endif |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1747 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1748 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
1749 func Test_expr6_fails() |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1750 let msg = "White space required before and after '+'" |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1751 call v9.CheckDefAndScriptFailure(["var x = 1+2"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1752 call v9.CheckDefAndScriptFailure(["var x = 1 +2"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1753 call v9.CheckDefAndScriptFailure(["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
|
1754 |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1755 let msg = "White space required before and after '-'" |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1756 call v9.CheckDefAndScriptFailure(["var x = 1-2"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1757 call v9.CheckDefAndScriptFailure(["var x = 1 -2"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1758 call v9.CheckDefAndScriptFailure(["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
|
1759 |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1760 let msg = "White space required before and after '..'" |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1761 call v9.CheckDefAndScriptFailure(["var x = '1'..'2'"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1762 call v9.CheckDefAndScriptFailure(["var x = '1' ..'2'"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1763 call v9.CheckDefAndScriptFailure(["var x = '1'.. '2'"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1764 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1765 call v9.CheckDefAndScriptFailure(["var x = 0z1122 + 33"], ['E1051:', 'E974:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1766 call v9.CheckDefAndScriptFailure(["var x = 0z1122 + [3]"], ['E1051:', 'E974:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1767 call v9.CheckDefAndScriptFailure(["var x = 0z1122 + 'asd'"], ['E1051:', 'E974:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1768 call v9.CheckDefAndScriptFailure(["var x = 33 + 0z1122"], ['E1051:', 'E974:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1769 call v9.CheckDefAndScriptFailure(["var x = [3] + 0z1122"], ['E1051:', 'E745:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1770 call v9.CheckDefAndScriptFailure(["var x = 'asdf' + 0z1122"], ['E1051:', 'E1030:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1771 call v9.CheckDefAndScriptFailure(["var x = 6 + xxx"], ['E1001:', 'E121:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1772 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1773 call v9.CheckDefAndScriptFailure(["var x = 'a' .. [1]"], ['E1105:', 'E730:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1774 call v9.CheckDefAndScriptFailure(["var x = 'a' .. {a: 1}"], ['E1105:', 'E731:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1775 call v9.CheckDefAndScriptFailure(["var x = 'a' .. test_void()"], ['E1105:', 'E908:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1776 call v9.CheckDefAndScriptFailure(["var x = 'a' .. 0z32"], ['E1105:', 'E976:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1777 call v9.CheckDefAndScriptFailure(["var x = 'a' .. function('len')"], ['E1105:', 'E729:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1778 call v9.CheckDefAndScriptFailure(["var x = 'a' .. function('len', ['a'])"], ['E1105:', 'E729:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1779 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1780 call v9.CheckDefAndScriptFailure(['var x = 1 + v:none'], ['E1051:', 'E611:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1781 call v9.CheckDefAndScriptFailure(['var x = 1 + v:null'], ['E1051:', 'E611:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1782 call v9.CheckDefAndScriptFailure(['var x = 1 + v:true'], ['E1051:', 'E1138:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1783 call v9.CheckDefAndScriptFailure(['var x = 1 + v:false'], ['E1051:', 'E1138:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1784 call v9.CheckDefAndScriptFailure(['var x = 1 + true'], ['E1051:', 'E1138:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1785 call v9.CheckDefAndScriptFailure(['var x = 1 + false'], ['E1051:', 'E1138:'], 1) |
22119
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1786 endfunc |
11dbf7e1f65c
patch 8.2.1609: Vim9: test fails when build without +channel
Bram Moolenaar <Bram@vim.org>
parents:
21959
diff
changeset
|
1787 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
1788 func Test_expr6_fails_channel() |
27488
07da466dcf6d
patch 8.2.4272: Vim9 expr test fails without the channel feature
Bram Moolenaar <Bram@vim.org>
parents:
27464
diff
changeset
|
1789 CheckFeature channel |
07da466dcf6d
patch 8.2.4272: Vim9 expr test fails without the channel feature
Bram Moolenaar <Bram@vim.org>
parents:
27464
diff
changeset
|
1790 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1791 call v9.CheckDefAndScriptFailure(["var x = 'a' .. test_null_job()"], ['E1105:', 'E908:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1792 call v9.CheckDefAndScriptFailure(["var x = 'a' .. test_null_channel()"], ['E1105:', 'E908:'], 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1793 endfunc |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1794 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
1795 def Test_expr6_list_add() |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1796 var lines =<< trim END |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1797 # concatenating two lists with same member types is OK |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1798 var d = {} |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1799 for i in ['a'] + ['b'] |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1800 d = {[i]: 0} |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1801 endfor |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1802 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1803 # concatenating two lists with different member types results in "any" |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1804 var dany = {} |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1805 for i in ['a'] + [12] |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1806 dany[i] = i |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1807 endfor |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1808 assert_equal({a: 'a', 12: 12}, dany) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1809 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1810 # result of glob() is "any", runtime type check |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1811 var sl: list<string> = glob('*.txt', false, true) + [''] |
27531
4ca0ee7b4f86
patch 8.2.4293: Vim9: when copying a list it gets type list<any>
Bram Moolenaar <Bram@vim.org>
parents:
27488
diff
changeset
|
1812 |
4ca0ee7b4f86
patch 8.2.4293: Vim9: when copying a list it gets type list<any>
Bram Moolenaar <Bram@vim.org>
parents:
27488
diff
changeset
|
1813 var lln: list<list<number>> = [[1] + [2]] |
4ca0ee7b4f86
patch 8.2.4293: Vim9: when copying a list it gets type list<any>
Bram Moolenaar <Bram@vim.org>
parents:
27488
diff
changeset
|
1814 assert_equal([[1, 2]], lln) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1815 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1816 v9.CheckDefAndScriptSuccess(lines) |
27535
e2bb28237695
patch 8.2.4295: Vim9: concatenating two lists may result in wrong type
Bram Moolenaar <Bram@vim.org>
parents:
27531
diff
changeset
|
1817 |
e2bb28237695
patch 8.2.4295: Vim9: concatenating two lists may result in wrong type
Bram Moolenaar <Bram@vim.org>
parents:
27531
diff
changeset
|
1818 lines =<< trim END |
e2bb28237695
patch 8.2.4295: Vim9: concatenating two lists may result in wrong type
Bram Moolenaar <Bram@vim.org>
parents:
27531
diff
changeset
|
1819 var ln: list<number> = [0] |
e2bb28237695
patch 8.2.4295: Vim9: concatenating two lists may result in wrong type
Bram Moolenaar <Bram@vim.org>
parents:
27531
diff
changeset
|
1820 var lln: list<list<number>> = [ln + []] |
e2bb28237695
patch 8.2.4295: Vim9: concatenating two lists may result in wrong type
Bram Moolenaar <Bram@vim.org>
parents:
27531
diff
changeset
|
1821 END |
e2bb28237695
patch 8.2.4295: Vim9: concatenating two lists may result in wrong type
Bram Moolenaar <Bram@vim.org>
parents:
27531
diff
changeset
|
1822 v9.CheckDefAndScriptSuccess(lines) |
23199
59f31d2eb4cf
patch 8.2.2145: Vim9: concatenating lists does not adjust type of result
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
1823 enddef |
59f31d2eb4cf
patch 8.2.2145: Vim9: concatenating lists does not adjust type of result
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
1824 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1825 " test multiply, divide, modulo |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
1826 def Test_expr7() |
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
|
1827 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
|
1828 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
|
1829 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
|
1830 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
|
1831 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
|
1832 * 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
|
1833 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
|
1834 |
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
|
1835 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
|
1836 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
|
1837 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
|
1838 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
|
1839 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
|
1840 / g:thefour) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1841 |
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
|
1842 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
|
1843 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
|
1844 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
|
1845 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
|
1846 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
|
1847 % g:thefour) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1848 |
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
|
1849 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
|
1850 |
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
|
1851 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
|
1852 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
|
1853 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
|
1854 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
|
1855 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
|
1856 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
|
1857 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
|
1858 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
|
1859 + 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
|
1860 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
|
1861 * 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
|
1862 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
|
1863 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1864 v9.CheckDefAndScriptSuccess(lines) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1865 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1866 v9.CheckDefAndScriptFailure(["var x = 6 * xxx"], ['E1001:', 'E121:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1867 v9.CheckDefFailure(["var d = 6 * "], 'E1097:', 3) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1868 v9.CheckScriptFailure(['vim9script', "var d = 6 * "], 'E15:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1869 |
28621
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28343
diff
changeset
|
1870 v9.CheckDefAndScriptFailure(['echo 1 / 0'], 'E1154', 1) |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28343
diff
changeset
|
1871 v9.CheckDefAndScriptFailure(['echo 1 % 0'], 'E1154', 1) |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28343
diff
changeset
|
1872 |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28343
diff
changeset
|
1873 g:zero = 0 |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28343
diff
changeset
|
1874 v9.CheckDefExecFailure(['echo 123 / g:zero'], 'E1154: Divide by zero') |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28343
diff
changeset
|
1875 v9.CheckDefExecFailure(['echo 123 % g:zero'], 'E1154: Divide by zero') |
25545
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25403
diff
changeset
|
1876 |
27768
b081ba78675a
patch 8.2.4410: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27669
diff
changeset
|
1877 if has('float') |
b081ba78675a
patch 8.2.4410: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27669
diff
changeset
|
1878 v9.CheckDefExecAndScriptFailure([ |
b081ba78675a
patch 8.2.4410: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27669
diff
changeset
|
1879 'g:one = 1.0' |
b081ba78675a
patch 8.2.4410: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27669
diff
changeset
|
1880 'g:two = 2.0' |
b081ba78675a
patch 8.2.4410: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27669
diff
changeset
|
1881 'echo g:one % g:two' |
b081ba78675a
patch 8.2.4410: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27669
diff
changeset
|
1882 ], 'E804', 3) |
b081ba78675a
patch 8.2.4410: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27669
diff
changeset
|
1883 endif |
b081ba78675a
patch 8.2.4410: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27669
diff
changeset
|
1884 |
25545
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25403
diff
changeset
|
1885 lines =<< trim END |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25403
diff
changeset
|
1886 var n = 0 |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25403
diff
changeset
|
1887 eval 1 / n |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25403
diff
changeset
|
1888 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1889 v9.CheckDefExecAndScriptFailure(lines, 'E1154', 2) |
25545
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25403
diff
changeset
|
1890 |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25403
diff
changeset
|
1891 lines =<< trim END |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25403
diff
changeset
|
1892 var n = 0 |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25403
diff
changeset
|
1893 eval 1 % n |
08a0abcb46c1
patch 8.2.3309: Vim9: divide by zero causes a crash
Bram Moolenaar <Bram@vim.org>
parents:
25403
diff
changeset
|
1894 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1895 v9.CheckDefExecAndScriptFailure(lines, 'E1154', 2) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1896 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1897 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
1898 def Test_expr7_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
|
1899 # 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
|
1900 var lines =<< trim END |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1901 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
|
1902 * 22 |
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1903 / 3 |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1904 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
|
1905 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1906 v9.CheckDefAndScriptSuccess(lines) |
20992
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1907 |
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1908 lines =<< trim END |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1909 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
|
1910 % 10 |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1911 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
|
1912 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1913 v9.CheckDefAndScriptSuccess(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
|
1914 |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1915 lines =<< trim END |
22580
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1916 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
|
1917 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1918 |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1919 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1920 % 10 |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1921 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
|
1922 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1923 v9.CheckDefAndScriptSuccess(lines) |
22580
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1924 |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
1925 lines =<< trim END |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1926 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
|
1927 22 / |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1928 3 |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22421
diff
changeset
|
1929 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
|
1930 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1931 v9.CheckDefAndScriptSuccess(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
|
1932 |
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1933 # 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
|
1934 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
|
1935 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
|
1936 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1937 v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1938 |
21634
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1939 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
|
1940 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
|
1941 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1942 v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
1943 |
21634
3a86e41fdffd
patch 8.2.1367: Vim9: no error for missing white space around operator
Bram Moolenaar <Bram@vim.org>
parents:
21630
diff
changeset
|
1944 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
|
1945 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
|
1946 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1947 v9.CheckDefAndScriptFailure(lines, 'E1004:', 1) |
20992
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1948 enddef |
7ee565134d4a
patch 8.2.1047: Vim9: script cannot use line continuation like :def function
Bram Moolenaar <Bram@vim.org>
parents:
20988
diff
changeset
|
1949 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
1950 def Test_expr7_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
|
1951 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
|
1952 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
|
1953 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
|
1954 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
|
1955 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
|
1956 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
|
1957 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
|
1958 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
|
1959 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
|
1960 |
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
|
1961 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
|
1962 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
|
1963 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
|
1964 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
|
1965 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
|
1966 |
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
|
1967 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
|
1968 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
|
1969 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
|
1970 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
|
1971 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
|
1972 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
|
1973 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
|
1974 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
|
1975 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
|
1976 |
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
|
1977 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
|
1978 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1979 v9.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
|
1980 endif |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1981 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1982 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
1983 func Test_expr7_fails() |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1984 let msg = "White space required before and after '*'" |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1985 call v9.CheckDefAndScriptFailure(["var x = 1*2"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1986 call v9.CheckDefAndScriptFailure(["var x = 1 *2"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1987 call v9.CheckDefAndScriptFailure(["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
|
1988 |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1989 let msg = "White space required before and after '/'" |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1990 call v9.CheckDefAndScriptFailure(["var x = 1/2"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1991 call v9.CheckDefAndScriptFailure(["var x = 1 /2"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1992 call v9.CheckDefAndScriptFailure(["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
|
1993 |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1994 let msg = "White space required before and after '%'" |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1995 call v9.CheckDefAndScriptFailure(["var x = 1%2"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1996 call v9.CheckDefAndScriptFailure(["var x = 1 %2"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1997 call v9.CheckDefAndScriptFailure(["var x = 1% 2"], msg, 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1998 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
1999 call v9.CheckDefAndScriptFailure(["var x = '1' * '2'"], ['E1036:', 'E1030:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2000 call v9.CheckDefAndScriptFailure(["var x = '1' / '2'"], ['E1036:', 'E1030:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2001 call v9.CheckDefAndScriptFailure(["var x = '1' % '2'"], ['E1035:', 'E1030:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2002 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2003 call v9.CheckDefAndScriptFailure(["var x = 0z01 * 0z12"], ['E1036:', 'E974:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2004 call v9.CheckDefAndScriptFailure(["var x = 0z01 / 0z12"], ['E1036:', 'E974:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2005 call v9.CheckDefAndScriptFailure(["var x = 0z01 % 0z12"], ['E1035:', 'E974:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2006 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2007 call v9.CheckDefAndScriptFailure(["var x = [1] * [2]"], ['E1036:', 'E745:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2008 call v9.CheckDefAndScriptFailure(["var x = [1] / [2]"], ['E1036:', 'E745:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2009 call v9.CheckDefAndScriptFailure(["var x = [1] % [2]"], ['E1035:', 'E745:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2010 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2011 call v9.CheckDefAndScriptFailure(["var x = {one: 1} * {two: 2}"], ['E1036:', 'E728:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2012 call v9.CheckDefAndScriptFailure(["var x = {one: 1} / {two: 2}"], ['E1036:', 'E728:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2013 call v9.CheckDefAndScriptFailure(["var x = {one: 1} % {two: 2}"], ['E1035:', 'E728:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2014 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2015 call v9.CheckDefAndScriptFailure(["var x = 0xff[1]"], ['E1107:', 'E1062:'], 1) |
19423
f3e8e74cb747
patch 8.2.0269: Vim9: operator after list index does not work
Bram Moolenaar <Bram@vim.org>
parents:
19259
diff
changeset
|
2016 if has('float') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2017 call v9.CheckDefAndScriptFailure(["var x = 0.7[1]"], ['E1107:', 'E806:'], 1) |
19423
f3e8e74cb747
patch 8.2.0269: Vim9: operator after list index does not work
Bram Moolenaar <Bram@vim.org>
parents:
19259
diff
changeset
|
2018 endif |
24713
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
2019 |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
2020 for op in ['*', '/', '%'] |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
2021 let lines = ['var x = 1', op .. '2', '# comment'] |
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
2022 let msg = printf("E1004: White space required before and after '%s' at \"%s2\"", op, op) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2023 call v9.CheckDefAndScriptFailure(lines, msg, 2) |
24713
34a5329b85aa
patch 8.2.2895: Vim9: random characters appear in some error messages
Bram Moolenaar <Bram@vim.org>
parents:
24707
diff
changeset
|
2024 endfor |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2025 endfunc |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2026 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2027 func Test_expr7_float_fails() |
27488
07da466dcf6d
patch 8.2.4272: Vim9 expr test fails without the channel feature
Bram Moolenaar <Bram@vim.org>
parents:
27464
diff
changeset
|
2028 CheckFeature float |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2029 call v9.CheckDefAndScriptFailure(["var x = 1.0 % 2"], ['E1035:', 'E804:'], 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2030 endfunc |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2031 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2032 " 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
|
2033 if has('float') |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2034 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
|
2035 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
|
2036 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
|
2037 endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2038 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
|
2039 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
|
2040 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
|
2041 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2042 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
|
2043 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
|
2044 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
|
2045 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
|
2046 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2047 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
|
2048 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
|
2049 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
|
2050 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
|
2051 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2052 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
|
2053 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
|
2054 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2055 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
|
2056 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
|
2057 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2058 let $TESTVAR = 'testvar' |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2059 |
21717
ef3b31d510d2
patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents:
21715
diff
changeset
|
2060 " type casts |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2061 def Test_expr8() |
24518
cf334a353c30
patch 8.2.2799: Vim9: type casts don't fully work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2062 var lines =<< trim END |
cf334a353c30
patch 8.2.2799: Vim9: type casts don't fully work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2063 var ls: list<string> = ['a', <string>g:string_empty] |
cf334a353c30
patch 8.2.2799: Vim9: type casts don't fully work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2064 var ln: list<number> = [<number>g:anint, <number>g:thefour] |
cf334a353c30
patch 8.2.2799: Vim9: type casts don't fully work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2065 var nr = <number>234 |
cf334a353c30
patch 8.2.2799: Vim9: type casts don't fully work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2066 assert_equal(234, nr) |
24695
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24685
diff
changeset
|
2067 var b: bool = <bool>1 |
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24685
diff
changeset
|
2068 assert_equal(true, b) |
24518
cf334a353c30
patch 8.2.2799: Vim9: type casts don't fully work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2069 var text = |
cf334a353c30
patch 8.2.2799: Vim9: type casts don't fully work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2070 <string> |
cf334a353c30
patch 8.2.2799: Vim9: type casts don't fully work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2071 'text' |
cf334a353c30
patch 8.2.2799: Vim9: type casts don't fully work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2072 if false |
cf334a353c30
patch 8.2.2799: Vim9: type casts don't fully work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2073 text = <number>'xxx' |
cf334a353c30
patch 8.2.2799: Vim9: type casts don't fully work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2074 endif |
cf334a353c30
patch 8.2.2799: Vim9: type casts don't fully work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
24432
diff
changeset
|
2075 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2076 v9.CheckDefAndScriptSuccess(lines) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2077 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2078 v9.CheckDefAndScriptFailure(["var x = <nr>123"], 'E1010:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2079 v9.CheckDefFailure(["var x = <number>"], 'E1097:', 3) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2080 v9.CheckDefFailure(["var x = <number>string(1)"], 'E1012:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2081 v9.CheckScriptFailure(['vim9script', "var x = <number>"], 'E15:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2082 v9.CheckDefAndScriptFailure(["var x = <number >123"], 'E1068:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2083 v9.CheckDefAndScriptFailure(["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
|
2084 enddef |
ef3b31d510d2
patch 8.2.1408: Vim9: type casting not supported
Bram Moolenaar <Bram@vim.org>
parents:
21715
diff
changeset
|
2085 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2086 " test low level expression |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2087 def Test_expr9_number() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
2088 # 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
|
2089 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
|
2090 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
|
2091 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
|
2092 |
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
|
2093 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
|
2094 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
|
2095 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
|
2096 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2097 v9.CheckDefAndScriptSuccess(lines) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2098 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2099 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2100 def Test_expr9_float() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
2101 # 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
|
2102 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
|
2103 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
|
2104 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
|
2105 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
|
2106 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
|
2107 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
|
2108 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
|
2109 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
|
2110 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2111 v9.CheckDefAndScriptSuccess(lines) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2112 endif |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2113 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2114 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2115 def Test_expr9_blob() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
2116 # 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
|
2117 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
|
2118 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
|
2119 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
|
2120 assert_equal(g:blob_long, 0z0102.0304) |
24432
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24430
diff
changeset
|
2121 |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24430
diff
changeset
|
2122 var testblob = 0z010203 |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24430
diff
changeset
|
2123 assert_equal(0x01, testblob[0]) |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24430
diff
changeset
|
2124 assert_equal(0x02, testblob[1]) |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24430
diff
changeset
|
2125 assert_equal(0x03, testblob[-1]) |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24430
diff
changeset
|
2126 assert_equal(0x02, testblob[-2]) |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24430
diff
changeset
|
2127 |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24430
diff
changeset
|
2128 assert_equal(0z01, testblob[0 : 0]) |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24430
diff
changeset
|
2129 assert_equal(0z0102, testblob[0 : 1]) |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24430
diff
changeset
|
2130 assert_equal(0z010203, testblob[0 : 2]) |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24430
diff
changeset
|
2131 assert_equal(0z010203, testblob[0 : ]) |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24430
diff
changeset
|
2132 assert_equal(0z0203, testblob[1 : ]) |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24430
diff
changeset
|
2133 assert_equal(0z0203, testblob[1 : 2]) |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24430
diff
changeset
|
2134 assert_equal(0z0203, testblob[1 : -1]) |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24430
diff
changeset
|
2135 assert_equal(0z03, testblob[-1 : -1]) |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24430
diff
changeset
|
2136 assert_equal(0z02, testblob[-2 : -2]) |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24430
diff
changeset
|
2137 |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24430
diff
changeset
|
2138 # blob slice accepts out of range |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24430
diff
changeset
|
2139 assert_equal(0z, testblob[3 : 3]) |
aa150abca273
patch 8.2.2756: Vim9: blob index and slice not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
24430
diff
changeset
|
2140 assert_equal(0z, testblob[0 : -4]) |
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
|
2141 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2142 v9.CheckDefAndScriptSuccess(lines) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2143 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2144 v9.CheckDefAndScriptFailure(["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
|
2145 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2146 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2147 def Test_expr9_string() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
2148 # 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
|
2149 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
|
2150 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
|
2151 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
|
2152 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
|
2153 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
|
2154 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
|
2155 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
|
2156 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
|
2157 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2158 v9.CheckDefAndScriptSuccess(lines) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2159 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2160 v9.CheckDefAndScriptFailure(['var x = "abc'], 'E114:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2161 v9.CheckDefAndScriptFailure(["var x = 'abc"], 'E115:', 1) |
27539
ce4c2f4ce1f9
patch 8.2.4296: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27535
diff
changeset
|
2162 v9.CheckDefFailure(["if 0", "echo 'xx", "endif"], 'E115', 2) |
28780
acca2214cabf
patch 8.2.4914: string interpolation in :def function may fail
Bram Moolenaar <Bram@vim.org>
parents:
28751
diff
changeset
|
2163 |
acca2214cabf
patch 8.2.4914: string interpolation in :def function may fail
Bram Moolenaar <Bram@vim.org>
parents:
28751
diff
changeset
|
2164 # interpolated string |
acca2214cabf
patch 8.2.4914: string interpolation in :def function may fail
Bram Moolenaar <Bram@vim.org>
parents:
28751
diff
changeset
|
2165 var val = 'val' |
acca2214cabf
patch 8.2.4914: string interpolation in :def function may fail
Bram Moolenaar <Bram@vim.org>
parents:
28751
diff
changeset
|
2166 var vv = $"some {val}" |
acca2214cabf
patch 8.2.4914: string interpolation in :def function may fail
Bram Moolenaar <Bram@vim.org>
parents:
28751
diff
changeset
|
2167 assert_equal('some val', vv) |
acca2214cabf
patch 8.2.4914: string interpolation in :def function may fail
Bram Moolenaar <Bram@vim.org>
parents:
28751
diff
changeset
|
2168 vv = $'other {val}' |
acca2214cabf
patch 8.2.4914: string interpolation in :def function may fail
Bram Moolenaar <Bram@vim.org>
parents:
28751
diff
changeset
|
2169 assert_equal('other val', vv) |
acca2214cabf
patch 8.2.4914: string interpolation in :def function may fail
Bram Moolenaar <Bram@vim.org>
parents:
28751
diff
changeset
|
2170 |
28846
0541b9c09e21
patch 8.2.4946: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28833
diff
changeset
|
2171 v9.CheckDefAndScriptFailure(['var x = $"foo'], 'E114:', 1) |
0541b9c09e21
patch 8.2.4946: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28833
diff
changeset
|
2172 v9.CheckDefAndScriptFailure(['var x = $"foo{xxx}"'], ['E1001: Variable not found: xxx', 'E121: Undefined variable: xxx'], 1) |
0541b9c09e21
patch 8.2.4946: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28833
diff
changeset
|
2173 |
28780
acca2214cabf
patch 8.2.4914: string interpolation in :def function may fail
Bram Moolenaar <Bram@vim.org>
parents:
28751
diff
changeset
|
2174 var x = 'x' |
acca2214cabf
patch 8.2.4914: string interpolation in :def function may fail
Bram Moolenaar <Bram@vim.org>
parents:
28751
diff
changeset
|
2175 var vl = 'foo xxx bar xxx baz' |
acca2214cabf
patch 8.2.4914: string interpolation in :def function may fail
Bram Moolenaar <Bram@vim.org>
parents:
28751
diff
changeset
|
2176 ->split($'x{x}x') |
acca2214cabf
patch 8.2.4914: string interpolation in :def function may fail
Bram Moolenaar <Bram@vim.org>
parents:
28751
diff
changeset
|
2177 ->map((_, v: string) => v =~ 'bar') |
acca2214cabf
patch 8.2.4914: string interpolation in :def function may fail
Bram Moolenaar <Bram@vim.org>
parents:
28751
diff
changeset
|
2178 assert_equal([false, true, false], vl) |
28821
006d525419fa
patch 8.2.4934: string interpolation fails when not evaluating
Bram Moolenaar <Bram@vim.org>
parents:
28780
diff
changeset
|
2179 |
006d525419fa
patch 8.2.4934: string interpolation fails when not evaluating
Bram Moolenaar <Bram@vim.org>
parents:
28780
diff
changeset
|
2180 # interpolated string in a lambda |
006d525419fa
patch 8.2.4934: string interpolation fails when not evaluating
Bram Moolenaar <Bram@vim.org>
parents:
28780
diff
changeset
|
2181 lines =<< trim END |
006d525419fa
patch 8.2.4934: string interpolation fails when not evaluating
Bram Moolenaar <Bram@vim.org>
parents:
28780
diff
changeset
|
2182 assert_equal(['gnome-256color', 'xterm-256color'], ['gnome', 'xterm'] |
006d525419fa
patch 8.2.4934: string interpolation fails when not evaluating
Bram Moolenaar <Bram@vim.org>
parents:
28780
diff
changeset
|
2183 ->map((_, term: string) => $'{term}-256color')) |
006d525419fa
patch 8.2.4934: string interpolation fails when not evaluating
Bram Moolenaar <Bram@vim.org>
parents:
28780
diff
changeset
|
2184 END |
006d525419fa
patch 8.2.4934: string interpolation fails when not evaluating
Bram Moolenaar <Bram@vim.org>
parents:
28780
diff
changeset
|
2185 v9.CheckDefAndScriptSuccess(lines) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2186 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2187 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2188 def Test_expr9_vimvar() |
26723
c3cffd372c6f
patch 8.2.3890: Vim9: type check for using v: variables is basic
Bram Moolenaar <Bram@vim.org>
parents:
26696
diff
changeset
|
2189 v:errors = [] |
c3cffd372c6f
patch 8.2.3890: Vim9: type check for using v: variables is basic
Bram Moolenaar <Bram@vim.org>
parents:
26696
diff
changeset
|
2190 var errs: list<string> = v:errors |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2191 v9.CheckDefFailure(['var errs: list<number> = v:errors'], 'E1012:') |
26723
c3cffd372c6f
patch 8.2.3890: Vim9: type check for using v: variables is basic
Bram Moolenaar <Bram@vim.org>
parents:
26696
diff
changeset
|
2192 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2193 var old: list<string> = v:oldfiles |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2194 v9.CheckDefFailure(['var old: list<number> = v:oldfiles'], 'E1012:') |
26723
c3cffd372c6f
patch 8.2.3890: Vim9: type check for using v: variables is basic
Bram Moolenaar <Bram@vim.org>
parents:
26696
diff
changeset
|
2195 |
c3cffd372c6f
patch 8.2.3890: Vim9: type check for using v: variables is basic
Bram Moolenaar <Bram@vim.org>
parents:
26696
diff
changeset
|
2196 var compl: dict<string> = v:completed_item |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2197 v9.CheckDefFailure(['var compl: dict<number> = v:completed_item'], 'E1012:') |
26723
c3cffd372c6f
patch 8.2.3890: Vim9: type check for using v: variables is basic
Bram Moolenaar <Bram@vim.org>
parents:
26696
diff
changeset
|
2198 |
c3cffd372c6f
patch 8.2.3890: Vim9: type check for using v: variables is basic
Bram Moolenaar <Bram@vim.org>
parents:
26696
diff
changeset
|
2199 var args: list<string> = v:argv |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2200 v9.CheckDefFailure(['var args: list<number> = v:argv'], 'E1012:') |
26723
c3cffd372c6f
patch 8.2.3890: Vim9: type check for using v: variables is basic
Bram Moolenaar <Bram@vim.org>
parents:
26696
diff
changeset
|
2201 |
c3cffd372c6f
patch 8.2.3890: Vim9: type check for using v: variables is basic
Bram Moolenaar <Bram@vim.org>
parents:
26696
diff
changeset
|
2202 var colors: dict<string> = v:colornames |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2203 v9.CheckDefFailure(['var colors: dict<number> = v:colornames'], 'E1012:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2204 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2205 v9.CheckDefFailure(["var old: list<number> = v:oldfiles"], 'E1012: Type mismatch; expected list<number> but got list<string>', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2206 v9.CheckScriptFailure(['vim9script', 'v:oldfiles = ["foo"]', "var old: list<number> = v:oldfiles"], 'E1012: Type mismatch; expected list<number> but got list<string>', 3) |
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
|
2207 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
|
2208 exec "normal! afoo fo\<C-N>\<Esc>" |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2209 v9.CheckDefExecAndScriptFailure(["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
|
2210 bwipe! |
19960
3c11b9f6fa03
patch 8.2.0536: Vim9: some compilation code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19912
diff
changeset
|
2211 enddef |
3c11b9f6fa03
patch 8.2.0536: Vim9: some compilation code not tested
Bram Moolenaar <Bram@vim.org>
parents:
19912
diff
changeset
|
2212 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2213 def Test_expr9_special() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
2214 # 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
|
2215 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
|
2216 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
|
2217 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
|
2218 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
|
2219 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
|
2220 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
|
2221 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
|
2222 |
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
|
2223 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
|
2224 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
|
2225 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
|
2226 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
|
2227 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
|
2228 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
|
2229 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
|
2230 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
|
2231 |
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
|
2232 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
|
2233 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
|
2234 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
|
2235 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
|
2236 |
52e64d340a98
patch 8.2.1980: Vim9: some tests are not done at the script level
Bram Moolenaar <Bram@vim.org>
parents:
22860
diff
changeset
|
2237 assert_equal(g:special_null, v:null) |
23497
2247a2ce3630
patch 8.2.2291: Vim9: cannot use "null" for v:null
Bram Moolenaar <Bram@vim.org>
parents:
23491
diff
changeset
|
2238 assert_equal(g:special_null, null) |
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
|
2239 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
|
2240 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2241 v9.CheckDefAndScriptSuccess(lines) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2242 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2243 v9.CheckDefAndScriptFailure(['v:true = true'], 'E46:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2244 v9.CheckDefAndScriptFailure(['v:true = false'], 'E46:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2245 v9.CheckDefAndScriptFailure(['v:false = true'], 'E46:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2246 v9.CheckDefAndScriptFailure(['v:null = 11'], 'E46:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2247 v9.CheckDefAndScriptFailure(['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
|
2248 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2249 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2250 def Test_expr9_list() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
2251 # 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
|
2252 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
|
2253 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
|
2254 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
|
2255 |
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
|
2256 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
|
2257 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
|
2258 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
|
2259 |
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
|
2260 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
|
2261 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
|
2262 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
|
2263 |
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
|
2264 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
|
2265 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
|
2266 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
|
2267 |
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
|
2268 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
|
2269 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
|
2270 4] |
21562
55aa283a0e5e
patch 8.2.1331: Vim9: :echo with two lists doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21546
diff
changeset
|
2271 |
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
|
2272 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
|
2273 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
|
2274 llstring = [[], []] |
28113
9ef1bbe6707e
patch 8.2.4581: null types not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
28103
diff
changeset
|
2275 |
9ef1bbe6707e
patch 8.2.4581: null types not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
28103
diff
changeset
|
2276 var ls = [null_string] |
9ef1bbe6707e
patch 8.2.4581: null types not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
28103
diff
changeset
|
2277 assert_equal('list<string>', typename(ls)) |
9ef1bbe6707e
patch 8.2.4581: null types not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
28103
diff
changeset
|
2278 var lb = [null_blob] |
9ef1bbe6707e
patch 8.2.4581: null types not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
28103
diff
changeset
|
2279 assert_equal('list<blob>', typename(lb)) |
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
|
2280 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2281 v9.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
|
2282 |
22419
6a9e5c087c86
patch 8.2.1758: Vim9: type of unmaterialized list is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
2283 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
|
2284 g:rangelist = range(3) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2285 v9.CheckDefExecAndScriptFailure(["var x: list<string> = g:rangelist"], 'E1012: Type mismatch; expected list<string> but got list<number>', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2286 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2287 v9.CheckDefAndScriptFailure(["var x = 1234[3]"], ['E1107:', 'E1062:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2288 v9.CheckDefExecAndScriptFailure(["var x = g:anint[3]"], 'E1062:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2289 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2290 v9.CheckDefAndScriptFailure(["var x = g:list_mixed[xxx]"], ['E1001:', 'E121:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2291 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2292 v9.CheckDefAndScriptFailure(["var x = [1,2,3]"], 'E1069:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2293 v9.CheckDefAndScriptFailure(["var x = [1 ,2, 3]"], 'E1068:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2294 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2295 v9.CheckDefExecAndScriptFailure(["echo 1", "var x = [][0]", "echo 3"], 'E684:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2296 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2297 v9.CheckDefExecAndScriptFailure(["var x = g:list_mixed['xx']"], ['E1012:', 'E1030:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2298 v9.CheckDefFailure(["var x = g:list_mixed["], 'E1097:', 3) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2299 v9.CheckScriptFailure(['vim9script', "var x = g:list_mixed["], 'E15:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2300 v9.CheckDefFailure(["var x = g:list_mixed[0"], 'E1097:', 3) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2301 v9.CheckScriptFailure(['vim9script', "var x = g:list_mixed[0"], 'E111:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2302 v9.CheckDefExecAndScriptFailure(["var x = g:list_empty[3]"], 'E684:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2303 v9.CheckDefExecAndScriptFailure(["var l: list<number> = [234, 'x']"], 'E1012:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2304 v9.CheckDefExecAndScriptFailure(["var l: list<number> = ['x', 234]"], 'E1012:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2305 v9.CheckDefExecAndScriptFailure(["var l: list<string> = [234, 'x']"], 'E1012:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2306 v9.CheckDefExecAndScriptFailure(["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
|
2307 |
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
|
2308 lines =<< trim END |
22482
a1b3804163ca
patch 8.2.1789: Vim9: crash with invalid list constant
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2309 var datalist: list<string> |
a1b3804163ca
patch 8.2.1789: Vim9: crash with invalid list constant
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2310 def Main() |
a1b3804163ca
patch 8.2.1789: Vim9: crash with invalid list constant
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2311 datalist += ['x'. |
a1b3804163ca
patch 8.2.1789: Vim9: crash with invalid list constant
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2312 enddef |
a1b3804163ca
patch 8.2.1789: Vim9: crash with invalid list constant
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2313 Main() |
a1b3804163ca
patch 8.2.1789: Vim9: crash with invalid list constant
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2314 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2315 v9.CheckDefAndScriptFailure(lines, 'E1127:') |
23414
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
2316 |
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
2317 lines =<< trim END |
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
2318 var numbers = [1, 2, 3, 4] |
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
2319 var a = 1 |
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
2320 var b = 2 |
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
2321 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2322 v9.CheckDefAndScriptFailure(lines + ['echo numbers[1:b]'], |
23446
b1dbbc81a011
patch 8.2.2266: Vim9: it can be hard to see where white space is missing
Bram Moolenaar <Bram@vim.org>
parents:
23438
diff
changeset
|
2323 'E1004: White space required before and after '':'' at ":b]"', 4) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2324 v9.CheckDefAndScriptFailure(lines + ['echo numbers[1: b]'], 'E1004:', 4) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2325 v9.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
|
2326 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2327 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2328 def Test_expr9_list_vim9script() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2329 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
|
2330 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
|
2331 11, |
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
2332 22, |
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
2333 ] |
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
2334 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
|
2335 |
55aa283a0e5e
patch 8.2.1331: Vim9: :echo with two lists doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21546
diff
changeset
|
2336 echo [1, |
55aa283a0e5e
patch 8.2.1331: Vim9: :echo with two lists doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21546
diff
changeset
|
2337 2] [3, |
55aa283a0e5e
patch 8.2.1331: Vim9: :echo with two lists doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21546
diff
changeset
|
2338 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
|
2339 |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
2340 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
|
2341 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
2342 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
|
2343 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
2344 4] |
21028
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
2345 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2346 v9.CheckDefAndScriptSuccess(lines) |
21028
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
2347 |
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
2348 lines =<< trim END |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2349 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
|
2350 22] |
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
2351 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
|
2352 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2353 v9.CheckDefAndScriptSuccess(lines) |
21034
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
2354 |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
2355 lines =<< trim END |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2356 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
|
2357 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2358 v9.CheckDefAndScriptFailure(lines, 'E1069:', 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
|
2359 |
5a2373c25a86
patch 8.2.1430: Vim9: error for missing comma instead of extra white space
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
2360 lines =<< trim END |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2361 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
|
2362 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2363 v9.CheckDefAndScriptFailure(lines, 'E1068:', 1) |
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
|
2364 |
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
2365 lines =<< trim END |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2366 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
|
2367 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2368 v9.CheckDefAndScriptFailure(lines, 'E1012:', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
2369 |
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
|
2370 lines =<< trim END |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2371 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
|
2372 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2373 v9.CheckDefAndScriptFailure(lines, 'E1012:', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
2374 |
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
|
2375 lines =<< trim END |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2376 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
|
2377 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2378 v9.CheckDefAndScriptFailure(lines, 'E1012:', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
2379 |
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
|
2380 lines =<< trim END |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2381 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
|
2382 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2383 v9.CheckDefAndScriptFailure(lines, 'E1012:', 1) |
22804
af26fadf333d
patch 8.2.1950: Vim9: crash when compiling function fails when getting type
Bram Moolenaar <Bram@vim.org>
parents:
22752
diff
changeset
|
2384 |
af26fadf333d
patch 8.2.1950: Vim9: crash when compiling function fails when getting type
Bram Moolenaar <Bram@vim.org>
parents:
22752
diff
changeset
|
2385 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
|
2386 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
|
2387 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
|
2388 enddef |
af26fadf333d
patch 8.2.1950: Vim9: crash when compiling function fails when getting type
Bram Moolenaar <Bram@vim.org>
parents:
22752
diff
changeset
|
2389 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
|
2390 END |
22836
b129f28b0e35
patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents:
22808
diff
changeset
|
2391 if has('channel') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2392 v9.CheckDefAndScriptFailure(lines, 'E119:', 0) |
22836
b129f28b0e35
patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents:
22808
diff
changeset
|
2393 else |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2394 v9.CheckDefAndScriptFailure(lines, 'E117:', 0) |
22836
b129f28b0e35
patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents:
22808
diff
changeset
|
2395 endif |
21028
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
2396 enddef |
7acceb76669f
patch 8.2.1065: Vim9: no line break allowed inside a list
Bram Moolenaar <Bram@vim.org>
parents:
21026
diff
changeset
|
2397 |
21767
9529a2367d3e
patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
2398 def LambdaWithComments(): func |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23418
diff
changeset
|
2399 return (x) => |
21767
9529a2367d3e
patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
2400 # some comment |
9529a2367d3e
patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
2401 x == 1 |
9529a2367d3e
patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
2402 # some comment |
9529a2367d3e
patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
2403 || |
9529a2367d3e
patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
2404 x == 2 |
9529a2367d3e
patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
2405 enddef |
9529a2367d3e
patch 8.2.1433: Vim9: cannot mingle comments in multi-line lambda
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
2406 |
21769
f37c1330b15c
patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents:
21767
diff
changeset
|
2407 def LambdaUsingArg(x: number): func |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23418
diff
changeset
|
2408 return () => |
21769
f37c1330b15c
patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents:
21767
diff
changeset
|
2409 # some comment |
f37c1330b15c
patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents:
21767
diff
changeset
|
2410 x == 1 |
f37c1330b15c
patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents:
21767
diff
changeset
|
2411 # some comment |
f37c1330b15c
patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents:
21767
diff
changeset
|
2412 || |
f37c1330b15c
patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents:
21767
diff
changeset
|
2413 x == 2 |
f37c1330b15c
patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents:
21767
diff
changeset
|
2414 enddef |
f37c1330b15c
patch 8.2.1434: Vim9: crash when lambda uses outer function argument
Bram Moolenaar <Bram@vim.org>
parents:
21767
diff
changeset
|
2415 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2416 def Test_expr9_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
|
2417 var lines =<< trim END |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23418
diff
changeset
|
2418 var La = () => 'result' |
24553
cb0d344bd381
patch 8.2.2816: Vim9: comment below expression in lambda causes problems
Bram Moolenaar <Bram@vim.org>
parents:
24533
diff
changeset
|
2419 # comment |
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
|
2420 assert_equal('result', La()) |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23418
diff
changeset
|
2421 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
|
2422 |
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
|
2423 # 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
|
2424 var ll = range(3) |
23565
34aa2907082a
patch 8.2.2325: Vim9: crash if map() changes the item type
Bram Moolenaar <Bram@vim.org>
parents:
23561
diff
changeset
|
2425 var dll = mapnew(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
|
2426 ['111']: 111 } : {} |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23418
diff
changeset
|
2427 ) |
23565
34aa2907082a
patch 8.2.2325: Vim9: crash if map() changes the item type
Bram Moolenaar <Bram@vim.org>
parents:
23561
diff
changeset
|
2428 assert_equal([{}, {111: 111}, {}], dll) |
21277
1e5c29d4e5b3
patch 8.2.1189: Vim9: line continuation in lambda doesn't always work
Bram Moolenaar <Bram@vim.org>
parents:
21263
diff
changeset
|
2429 |
24553
cb0d344bd381
patch 8.2.2816: Vim9: comment below expression in lambda causes problems
Bram Moolenaar <Bram@vim.org>
parents:
24533
diff
changeset
|
2430 # comment halfway an expression |
cb0d344bd381
patch 8.2.2816: Vim9: comment below expression in lambda causes problems
Bram Moolenaar <Bram@vim.org>
parents:
24533
diff
changeset
|
2431 var Ref = () => 4 |
cb0d344bd381
patch 8.2.2816: Vim9: comment below expression in lambda causes problems
Bram Moolenaar <Bram@vim.org>
parents:
24533
diff
changeset
|
2432 # comment |
cb0d344bd381
patch 8.2.2816: Vim9: comment below expression in lambda causes problems
Bram Moolenaar <Bram@vim.org>
parents:
24533
diff
changeset
|
2433 + 6 |
cb0d344bd381
patch 8.2.2816: Vim9: comment below expression in lambda causes problems
Bram Moolenaar <Bram@vim.org>
parents:
24533
diff
changeset
|
2434 assert_equal(10, Ref()) |
cb0d344bd381
patch 8.2.2816: Vim9: comment below expression in lambda causes problems
Bram Moolenaar <Bram@vim.org>
parents:
24533
diff
changeset
|
2435 |
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
|
2436 ll = range(3) |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23418
diff
changeset
|
2437 map(ll, (k, v) => v == 8 || v |
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
|
2438 == 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
|
2439 || v % 2 ? 111 : 222 |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23418
diff
changeset
|
2440 ) |
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
|
2441 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
|
2442 |
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
|
2443 ll = range(3) |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23418
diff
changeset
|
2444 map(ll, (k, v) => v != 8 && v |
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
|
2445 != 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
|
2446 && v % 2 == 0 ? 111 : 222 |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23418
diff
changeset
|
2447 ) |
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
|
2448 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
|
2449 |
26737
10d3105030ab
patch 8.2.3897: Vim9: second argument of map() and filter() not checked
Bram Moolenaar <Bram@vim.org>
parents:
26723
diff
changeset
|
2450 var dl = [{key: 0}, {key: 22}]->filter(( _, v) => !!v['key'] ) |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2451 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
|
2452 |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2453 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
|
2454 assert_equal([{key: 12}], filter(dl, |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23418
diff
changeset
|
2455 (_, 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
|
2456 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2457 assert_equal(false, g:LambdaWithComments()(0)) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2458 assert_equal(true, g:LambdaWithComments()(1)) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2459 assert_equal(true, g:LambdaWithComments()(2)) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2460 assert_equal(false, g:LambdaWithComments()(3)) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2461 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2462 assert_equal(false, g:LambdaUsingArg(0)()) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2463 assert_equal(true, g:LambdaUsingArg(1)()) |
23013
a0a998d2e443
patch 8.2.2053: Vim9: lamba doesn't accept argument types
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
2464 |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23418
diff
changeset
|
2465 var res = map([1, 2, 3], (i: number, v: number) => i + v) |
23013
a0a998d2e443
patch 8.2.2053: Vim9: lamba doesn't accept argument types
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
2466 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
|
2467 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2468 v9.CheckDefAndScriptSuccess(lines) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2469 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2470 v9.CheckDefAndScriptFailure(["var Ref = (a)=>a + 1"], 'E1004:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2471 v9.CheckDefAndScriptFailure(["var Ref = (a)=> a + 1"], 'E1004: White space required before and after ''=>'' at "=> a + 1"') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2472 v9.CheckDefAndScriptFailure(["var Ref = (a) =>a + 1"], 'E1004:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2473 v9.CheckDefAndScriptFailure(["var Ref = (a) =< a + 1"], ['E1001:', 'E121:']) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2474 v9.CheckDefAndScriptFailure(["var Ref = (a: int) => a + 1"], 'E1010:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2475 v9.CheckDefAndScriptFailure(["var Ref = (a): int => a + 1"], 'E1010:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2476 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2477 v9.CheckDefAndScriptFailure(["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
|
2478 # error is in first line of the lambda |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2479 v9.CheckDefAndScriptFailure(["var L = (a) => a + b"], 'E1001:', 0) |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23418
diff
changeset
|
2480 |
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23418
diff
changeset
|
2481 assert_equal('xxxyyy', 'xxx'->((a, b) => a .. b)('yyy')) |
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23418
diff
changeset
|
2482 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2483 v9.CheckDefExecFailure(["var s = 'asdf'->((a) => a)('x')"], 'E118:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2484 v9.CheckDefExecFailure(["var s = 'asdf'->((a) => a)('x', 'y')"], 'E118:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2485 v9.CheckDefAndScriptFailure(["echo 'asdf'->((a) => a)(x)"], ['E1001:', 'E121:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2486 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2487 v9.CheckDefAndScriptSuccess(['var Fx = (a) => ({k1: 0,', ' k2: 1})']) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2488 v9.CheckDefAndScriptFailure(['var Fx = (a) => ({k1: 0', ' k2: 1})'], 'E722:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2489 v9.CheckDefAndScriptFailure(['var Fx = (a) => ({k1: 0,', ' k2 1})'], 'E720:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2490 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2491 v9.CheckDefAndScriptSuccess(['var Fx = (a) => [0,', ' 1]']) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2492 v9.CheckDefAndScriptFailure(['var Fx = (a) => [0', ' 1]'], 'E696:', 2) |
24004
90fbe1a3b23c
patch 8.2.2544: Vim9: error for argument when checking for lambda
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
2493 |
90fbe1a3b23c
patch 8.2.2544: Vim9: error for argument when checking for lambda
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
2494 # no error for existing script variable when checking for lambda |
90fbe1a3b23c
patch 8.2.2544: Vim9: error for argument when checking for lambda
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
2495 lines =<< trim END |
90fbe1a3b23c
patch 8.2.2544: Vim9: error for argument when checking for lambda
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
2496 var name = 0 |
90fbe1a3b23c
patch 8.2.2544: Vim9: error for argument when checking for lambda
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
2497 eval (name + 2) / 3 |
90fbe1a3b23c
patch 8.2.2544: Vim9: error for argument when checking for lambda
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
2498 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2499 v9.CheckDefAndScriptSuccess(lines) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2500 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2501 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2502 def Test_expr9_lambda_block() |
24188
c20e763bc73c
patch 8.2.2635: Vim9: cannot define an inline function
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
2503 var lines =<< trim END |
c20e763bc73c
patch 8.2.2635: Vim9: cannot define an inline function
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
2504 var Func = (s: string): string => { |
c20e763bc73c
patch 8.2.2635: Vim9: cannot define an inline function
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
2505 return 'hello ' .. s |
c20e763bc73c
patch 8.2.2635: Vim9: cannot define an inline function
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
2506 } |
c20e763bc73c
patch 8.2.2635: Vim9: cannot define an inline function
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
2507 assert_equal('hello there', Func('there')) |
c20e763bc73c
patch 8.2.2635: Vim9: cannot define an inline function
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
2508 |
c20e763bc73c
patch 8.2.2635: Vim9: cannot define an inline function
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
2509 var ll = range(3) |
c20e763bc73c
patch 8.2.2635: Vim9: cannot define an inline function
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
2510 var dll = mapnew(ll, (k, v): string => { |
c20e763bc73c
patch 8.2.2635: Vim9: cannot define an inline function
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
2511 if v % 2 |
c20e763bc73c
patch 8.2.2635: Vim9: cannot define an inline function
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
2512 return 'yes' |
c20e763bc73c
patch 8.2.2635: Vim9: cannot define an inline function
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
2513 endif |
c20e763bc73c
patch 8.2.2635: Vim9: cannot define an inline function
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
2514 return 'no' |
c20e763bc73c
patch 8.2.2635: Vim9: cannot define an inline function
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
2515 }) |
c20e763bc73c
patch 8.2.2635: Vim9: cannot define an inline function
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
2516 assert_equal(['no', 'yes', 'no'], dll) |
24208
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2517 |
25296
ec0421c25be9
patch 8.2.3185: Vim9: start of inline function found in comment line
Bram Moolenaar <Bram@vim.org>
parents:
25278
diff
changeset
|
2518 # ignored_inline(0, (_) => { |
ec0421c25be9
patch 8.2.3185: Vim9: start of inline function found in comment line
Bram Moolenaar <Bram@vim.org>
parents:
25278
diff
changeset
|
2519 # echo 'body' |
ec0421c25be9
patch 8.2.3185: Vim9: start of inline function found in comment line
Bram Moolenaar <Bram@vim.org>
parents:
25278
diff
changeset
|
2520 # }) |
ec0421c25be9
patch 8.2.3185: Vim9: start of inline function found in comment line
Bram Moolenaar <Bram@vim.org>
parents:
25278
diff
changeset
|
2521 |
24208
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2522 sandbox var Safe = (nr: number): number => { |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2523 return nr + 7 |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2524 } |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2525 assert_equal(10, Safe(3)) |
24188
c20e763bc73c
patch 8.2.2635: Vim9: cannot define an inline function
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
2526 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2527 v9.CheckDefAndScriptSuccess(lines) |
24202
c50c5464e6dc
patch 8.2.2642: Vim9: no clear error for wrong inline function
Bram Moolenaar <Bram@vim.org>
parents:
24188
diff
changeset
|
2528 |
c50c5464e6dc
patch 8.2.2642: Vim9: no clear error for wrong inline function
Bram Moolenaar <Bram@vim.org>
parents:
24188
diff
changeset
|
2529 lines =<< trim END |
c50c5464e6dc
patch 8.2.2642: Vim9: no clear error for wrong inline function
Bram Moolenaar <Bram@vim.org>
parents:
24188
diff
changeset
|
2530 map([1, 2], (k, v) => { redrawt }) |
c50c5464e6dc
patch 8.2.2642: Vim9: no clear error for wrong inline function
Bram Moolenaar <Bram@vim.org>
parents:
24188
diff
changeset
|
2531 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2532 v9.CheckDefAndScriptFailure(lines, 'E488') |
24208
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2533 |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2534 lines =<< trim END |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2535 var Func = (nr: int) => { |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2536 echo nr |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2537 } |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2538 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2539 v9.CheckDefAndScriptFailure(lines, 'E1010', 1) |
24208
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2540 |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2541 lines =<< trim END |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2542 var Func = (nr: number): int => { |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2543 return nr |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2544 } |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2545 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2546 v9.CheckDefAndScriptFailure(lines, 'E1010', 1) |
24208
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2547 |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2548 lines =<< trim END |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2549 var Func = (nr: number): int => { |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2550 return nr |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2551 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2552 v9.CheckDefFailure(lines, 'E1171', 0) # line nr is function start |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2553 v9.CheckScriptFailure(['vim9script'] + lines, 'E1171', 2) |
24208
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2554 |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2555 lines =<< trim END |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2556 var Func = (nr: number): int => { |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2557 var ll =<< ENDIT |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2558 nothing |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24202
diff
changeset
|
2559 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2560 v9.CheckDefFailure(lines, 'E1145: Missing heredoc end marker: ENDIT', 0) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2561 v9.CheckScriptFailure(['vim9script'] + lines, 'E1145: Missing heredoc end marker: ENDIT', 2) |
24188
c20e763bc73c
patch 8.2.2635: Vim9: cannot define an inline function
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
2562 enddef |
c20e763bc73c
patch 8.2.2635: Vim9: cannot define an inline function
Bram Moolenaar <Bram@vim.org>
parents:
24176
diff
changeset
|
2563 |
23318
c76240efdf02
patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents:
23310
diff
changeset
|
2564 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
|
2565 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
|
2566 # 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
|
2567 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
|
2568 # 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
|
2569 || |
c76240efdf02
patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents:
23310
diff
changeset
|
2570 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
|
2571 enddef |
c76240efdf02
patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents:
23310
diff
changeset
|
2572 |
c76240efdf02
patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents:
23310
diff
changeset
|
2573 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
|
2574 return () => |
c76240efdf02
patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents:
23310
diff
changeset
|
2575 # 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
|
2576 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
|
2577 # 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
|
2578 || |
c76240efdf02
patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents:
23310
diff
changeset
|
2579 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
|
2580 enddef |
c76240efdf02
patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents:
23310
diff
changeset
|
2581 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2582 def Test_expr9_new_lambda() |
23318
c76240efdf02
patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents:
23310
diff
changeset
|
2583 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
|
2584 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
|
2585 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
|
2586 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
|
2587 |
c76240efdf02
patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents:
23310
diff
changeset
|
2588 # 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
|
2589 var ll = range(3) |
23565
34aa2907082a
patch 8.2.2325: Vim9: crash if map() changes the item type
Bram Moolenaar <Bram@vim.org>
parents:
23561
diff
changeset
|
2590 var dll = mapnew(ll, (k, v) => v % 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
|
2591 ['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
|
2592 ) |
23565
34aa2907082a
patch 8.2.2325: Vim9: crash if map() changes the item type
Bram Moolenaar <Bram@vim.org>
parents:
23561
diff
changeset
|
2593 assert_equal([{}, {111: 111}, {}], dll) |
23318
c76240efdf02
patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents:
23310
diff
changeset
|
2594 |
c76240efdf02
patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents:
23310
diff
changeset
|
2595 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
|
2596 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
|
2597 == 9 |
c76240efdf02
patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents:
23310
diff
changeset
|
2598 || 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
|
2599 ) |
c76240efdf02
patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents:
23310
diff
changeset
|
2600 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
|
2601 |
c76240efdf02
patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents:
23310
diff
changeset
|
2602 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
|
2603 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
|
2604 != 9 |
c76240efdf02
patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents:
23310
diff
changeset
|
2605 && 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
|
2606 ) |
c76240efdf02
patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents:
23310
diff
changeset
|
2607 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
|
2608 |
26737
10d3105030ab
patch 8.2.3897: Vim9: second argument of map() and filter() not checked
Bram Moolenaar <Bram@vim.org>
parents:
26723
diff
changeset
|
2609 var dl = [{key: 0}, {key: 22}]->filter(( _, v) => !!v['key'] ) |
23318
c76240efdf02
patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents:
23310
diff
changeset
|
2610 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
|
2611 |
c76240efdf02
patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents:
23310
diff
changeset
|
2612 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
|
2613 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
|
2614 (_, 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
|
2615 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2616 assert_equal(false, g:NewLambdaWithComments()(0)) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2617 assert_equal(true, g:NewLambdaWithComments()(1)) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2618 assert_equal(true, g:NewLambdaWithComments()(2)) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2619 assert_equal(false, g:NewLambdaWithComments()(3)) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2620 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2621 assert_equal(false, g:NewLambdaUsingArg(0)()) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2622 assert_equal(true, g:NewLambdaUsingArg(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
|
2623 |
c76240efdf02
patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents:
23310
diff
changeset
|
2624 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
|
2625 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
|
2626 |
c76240efdf02
patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents:
23310
diff
changeset
|
2627 # 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
|
2628 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
|
2629 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
|
2630 |
9c5275b1c763
patch 8.2.2212: Vim9: lambda with => does not work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23332
diff
changeset
|
2631 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
|
2632 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
|
2633 |
9c5275b1c763
patch 8.2.2212: Vim9: lambda with => does not work at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23332
diff
changeset
|
2634 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
|
2635 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
|
2636 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
|
2637 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
|
2638 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2639 v9.CheckDefAndScriptSuccess(lines) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2640 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2641 v9.CheckDefAndScriptFailure(["var Ref = (a)=>a + 1"], 'E1004:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2642 v9.CheckDefAndScriptFailure(["var Ref = (a)=> a + 1"], 'E1004:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2643 v9.CheckDefAndScriptFailure(["var Ref = (a) =>a + 1"], |
23446
b1dbbc81a011
patch 8.2.2266: Vim9: it can be hard to see where white space is missing
Bram Moolenaar <Bram@vim.org>
parents:
23438
diff
changeset
|
2644 'E1004: White space required before and after ''=>'' at " =>a + 1"') |
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
|
2645 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2646 v9.CheckDefAndScriptFailure(["var Ref: func(number): number = (a: number): string => 'x'"], 'E1012:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2647 v9.CheckDefAndScriptFailure(["var Ref: func(number): string = (a: number): string => 99"], 'E1012:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2648 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2649 v9.CheckDefAndScriptFailure(["filter([1, 2], (k,v) => 1)"], 'E1069:', 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
|
2650 # error is in first line of the lambda |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2651 v9.CheckDefAndScriptFailure(["var L = (a) -> a + b"], ['E1001:', 'E121:'], 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
2652 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
2653 assert_equal('xxxyyy', 'xxx'->((a, b) => a .. b)('yyy')) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
2654 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2655 v9.CheckDefExecFailure(["var s = 'asdf'->((a) => a)('x')"], |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
2656 'E118: Too many arguments for function:') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2657 v9.CheckDefExecFailure(["var s = 'asdf'->((a) => a)('x', 'y')"], |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
2658 'E118: Too many arguments for function:') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2659 v9.CheckDefFailure(["echo 'asdf'->((a) => a)(x)"], 'E1001:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2660 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2661 v9.CheckDefAndScriptFailure(['var Fx = (a) => ({k1: 0', ' k2: 1})'], 'E722:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2662 v9.CheckDefAndScriptFailure(['var Fx = (a) => ({k1: 0,', ' k2 1})'], 'E720:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2663 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2664 v9.CheckDefAndScriptFailure(['var Fx = (a) => [0', ' 1]'], 'E696:', 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
|
2665 enddef |
c76240efdf02
patch 8.2.2204: Vim9: using -> both for method and lambda is confusing
Bram Moolenaar <Bram@vim.org>
parents:
23310
diff
changeset
|
2666 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2667 def Test_expr9_lambda_vim9script() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2668 var lines =<< trim END |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23418
diff
changeset
|
2669 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
|
2670 a |
d9e0db9b2b99
patch 8.2.1071: Vim9: no line break allowed inside a lambda
Bram Moolenaar <Bram@vim.org>
parents:
21034
diff
changeset
|
2671 + 2 |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23418
diff
changeset
|
2672 )() |
21040
d9e0db9b2b99
patch 8.2.1071: Vim9: no line break allowed inside a lambda
Bram Moolenaar <Bram@vim.org>
parents:
21034
diff
changeset
|
2673 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
|
2674 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2675 v9.CheckDefAndScriptSuccess(lines) |
21865
c16af87df654
patch 8.2.1482: Vim9: crash when using a nested lambda
Bram Moolenaar <Bram@vim.org>
parents:
21863
diff
changeset
|
2676 |
c16af87df654
patch 8.2.1482: Vim9: crash when using a nested lambda
Bram Moolenaar <Bram@vim.org>
parents:
21863
diff
changeset
|
2677 # 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
|
2678 lines =<< trim END |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23418
diff
changeset
|
2679 search('"', 'cW', 0, 0, () => |
21865
c16af87df654
patch 8.2.1482: Vim9: crash when using a nested lambda
Bram Moolenaar <Bram@vim.org>
parents:
21863
diff
changeset
|
2680 synstack('.', col('.')) |
26737
10d3105030ab
patch 8.2.3897: Vim9: second argument of map() and filter() not checked
Bram Moolenaar <Bram@vim.org>
parents:
26723
diff
changeset
|
2681 ->mapnew((_, v) => synIDattr(v, 'name'))->len()) |
21865
c16af87df654
patch 8.2.1482: Vim9: crash when using a nested lambda
Bram Moolenaar <Bram@vim.org>
parents:
21863
diff
changeset
|
2682 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2683 v9.CheckDefAndScriptSuccess(lines) |
21040
d9e0db9b2b99
patch 8.2.1071: Vim9: no line break allowed inside a lambda
Bram Moolenaar <Bram@vim.org>
parents:
21034
diff
changeset
|
2684 enddef |
d9e0db9b2b99
patch 8.2.1071: Vim9: no line break allowed inside a lambda
Bram Moolenaar <Bram@vim.org>
parents:
21034
diff
changeset
|
2685 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2686 def Test_expr9funcref() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2687 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
|
2688 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
|
2689 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
|
2690 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
|
2691 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
|
2692 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
|
2693 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2694 v9.CheckDefAndScriptSuccess(lines) |
24390
492f7b54f691
patch 8.2.2735: Vim9: function reference found with prefix, not without
Bram Moolenaar <Bram@vim.org>
parents:
24388
diff
changeset
|
2695 |
492f7b54f691
patch 8.2.2735: Vim9: function reference found with prefix, not without
Bram Moolenaar <Bram@vim.org>
parents:
24388
diff
changeset
|
2696 lines =<< trim END |
492f7b54f691
patch 8.2.2735: Vim9: function reference found with prefix, not without
Bram Moolenaar <Bram@vim.org>
parents:
24388
diff
changeset
|
2697 vim9script |
492f7b54f691
patch 8.2.2735: Vim9: function reference found with prefix, not without
Bram Moolenaar <Bram@vim.org>
parents:
24388
diff
changeset
|
2698 func g:GlobalFunc() |
492f7b54f691
patch 8.2.2735: Vim9: function reference found with prefix, not without
Bram Moolenaar <Bram@vim.org>
parents:
24388
diff
changeset
|
2699 return 'global' |
492f7b54f691
patch 8.2.2735: Vim9: function reference found with prefix, not without
Bram Moolenaar <Bram@vim.org>
parents:
24388
diff
changeset
|
2700 endfunc |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27539
diff
changeset
|
2701 func ScriptFunc() |
24390
492f7b54f691
patch 8.2.2735: Vim9: function reference found with prefix, not without
Bram Moolenaar <Bram@vim.org>
parents:
24388
diff
changeset
|
2702 return 'script' |
492f7b54f691
patch 8.2.2735: Vim9: function reference found with prefix, not without
Bram Moolenaar <Bram@vim.org>
parents:
24388
diff
changeset
|
2703 endfunc |
492f7b54f691
patch 8.2.2735: Vim9: function reference found with prefix, not without
Bram Moolenaar <Bram@vim.org>
parents:
24388
diff
changeset
|
2704 def Test() |
492f7b54f691
patch 8.2.2735: Vim9: function reference found with prefix, not without
Bram Moolenaar <Bram@vim.org>
parents:
24388
diff
changeset
|
2705 var Ref = g:GlobalFunc |
492f7b54f691
patch 8.2.2735: Vim9: function reference found with prefix, not without
Bram Moolenaar <Bram@vim.org>
parents:
24388
diff
changeset
|
2706 assert_equal('global', Ref()) |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
2707 Ref = g:GlobalFunc |
24390
492f7b54f691
patch 8.2.2735: Vim9: function reference found with prefix, not without
Bram Moolenaar <Bram@vim.org>
parents:
24388
diff
changeset
|
2708 assert_equal('global', Ref()) |
492f7b54f691
patch 8.2.2735: Vim9: function reference found with prefix, not without
Bram Moolenaar <Bram@vim.org>
parents:
24388
diff
changeset
|
2709 |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27539
diff
changeset
|
2710 Ref = ScriptFunc |
24390
492f7b54f691
patch 8.2.2735: Vim9: function reference found with prefix, not without
Bram Moolenaar <Bram@vim.org>
parents:
24388
diff
changeset
|
2711 assert_equal('script', Ref()) |
492f7b54f691
patch 8.2.2735: Vim9: function reference found with prefix, not without
Bram Moolenaar <Bram@vim.org>
parents:
24388
diff
changeset
|
2712 Ref = ScriptFunc |
492f7b54f691
patch 8.2.2735: Vim9: function reference found with prefix, not without
Bram Moolenaar <Bram@vim.org>
parents:
24388
diff
changeset
|
2713 assert_equal('script', Ref()) |
492f7b54f691
patch 8.2.2735: Vim9: function reference found with prefix, not without
Bram Moolenaar <Bram@vim.org>
parents:
24388
diff
changeset
|
2714 enddef |
492f7b54f691
patch 8.2.2735: Vim9: function reference found with prefix, not without
Bram Moolenaar <Bram@vim.org>
parents:
24388
diff
changeset
|
2715 Test() |
492f7b54f691
patch 8.2.2735: Vim9: function reference found with prefix, not without
Bram Moolenaar <Bram@vim.org>
parents:
24388
diff
changeset
|
2716 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2717 v9.CheckScriptSuccess(lines) |
28833
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28821
diff
changeset
|
2718 |
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28821
diff
changeset
|
2719 # using funcref in legacy script |
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28821
diff
changeset
|
2720 lines =<< trim END |
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28821
diff
changeset
|
2721 def s:Refme(): string |
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28821
diff
changeset
|
2722 return 'yes' |
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28821
diff
changeset
|
2723 enddef |
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28821
diff
changeset
|
2724 |
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28821
diff
changeset
|
2725 def TestFunc() |
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28821
diff
changeset
|
2726 var TheRef = s:Refme |
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28821
diff
changeset
|
2727 assert_equal('yes', TheRef()) |
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28821
diff
changeset
|
2728 enddef |
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28821
diff
changeset
|
2729 |
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28821
diff
changeset
|
2730 call TestFunc() |
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28821
diff
changeset
|
2731 END |
bf013128ccf4
patch 8.2.4940: some code is never used
Bram Moolenaar <Bram@vim.org>
parents:
28821
diff
changeset
|
2732 v9.CheckScriptSuccess(lines) |
21955
3991a6df522e
patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents:
21925
diff
changeset
|
2733 enddef |
3991a6df522e
patch 8.2.1527: Vim9: cannot use a function name at script level
Bram Moolenaar <Bram@vim.org>
parents:
21925
diff
changeset
|
2734 |
22936
00b0275ffe7f
patch 8.2.2015: Vim9: literal dict #{} is not like any other language
Bram Moolenaar <Bram@vim.org>
parents:
22932
diff
changeset
|
2735 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
|
2736 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
|
2737 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2738 def Test_expr9_dict() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
2739 # 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
|
2740 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
|
2741 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
|
2742 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
|
2743 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
|
2744 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
|
2745 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
|
2746 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
|
2747 |
22936
00b0275ffe7f
patch 8.2.2015: Vim9: literal dict #{} is not like any other language
Bram Moolenaar <Bram@vim.org>
parents:
22932
diff
changeset
|
2748 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
|
2749 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
|
2750 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
|
2751 |
22936
00b0275ffe7f
patch 8.2.2015: Vim9: literal dict #{} is not like any other language
Bram Moolenaar <Bram@vim.org>
parents:
22932
diff
changeset
|
2752 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
|
2753 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
|
2754 strings = {} |
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2755 |
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2756 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
|
2757 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
|
2758 |
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2759 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
|
2760 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
|
2761 |
22936
00b0275ffe7f
patch 8.2.2015: Vim9: literal dict #{} is not like any other language
Bram Moolenaar <Bram@vim.org>
parents:
22932
diff
changeset
|
2762 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
|
2763 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
|
2764 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
|
2765 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
|
2766 |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2767 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
|
2768 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
|
2769 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
|
2770 |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2771 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
|
2772 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
|
2773 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
|
2774 |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2775 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
|
2776 |
00b0275ffe7f
patch 8.2.2015: Vim9: literal dict #{} is not like any other language
Bram Moolenaar <Bram@vim.org>
parents:
22932
diff
changeset
|
2777 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
|
2778 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
|
2779 |
285cde4b8d0e
patch 8.2.2090: Vim9: dict does not accept a key in quotes
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
2780 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
|
2781 |
681f042ae5ac
patch 8.2.2252: Vim9: crash when using lambda without return type in dict
Bram Moolenaar <Bram@vim.org>
parents:
23414
diff
changeset
|
2782 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
|
2783 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
|
2784 assert_equal(7, d.b()) |
23491
ac5ead954dcd
patch 8.2.2288: Vim9: line break and comment not always skipped
Bram Moolenaar <Bram@vim.org>
parents:
23446
diff
changeset
|
2785 |
ac5ead954dcd
patch 8.2.2288: Vim9: line break and comment not always skipped
Bram Moolenaar <Bram@vim.org>
parents:
23446
diff
changeset
|
2786 var cd = { # comment |
ac5ead954dcd
patch 8.2.2288: Vim9: line break and comment not always skipped
Bram Moolenaar <Bram@vim.org>
parents:
23446
diff
changeset
|
2787 key: 'val' # comment |
ac5ead954dcd
patch 8.2.2288: Vim9: line break and comment not always skipped
Bram Moolenaar <Bram@vim.org>
parents:
23446
diff
changeset
|
2788 } |
23827
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23806
diff
changeset
|
2789 |
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23806
diff
changeset
|
2790 # different types used for the key |
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23806
diff
changeset
|
2791 var dkeys = {['key']: 'string', |
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23806
diff
changeset
|
2792 [12]: 'numberexpr', |
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23806
diff
changeset
|
2793 34: 'number', |
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23806
diff
changeset
|
2794 [true]: 'bool'} |
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23806
diff
changeset
|
2795 assert_equal('string', dkeys['key']) |
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23806
diff
changeset
|
2796 assert_equal('numberexpr', dkeys[12]) |
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23806
diff
changeset
|
2797 assert_equal('number', dkeys[34]) |
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23806
diff
changeset
|
2798 assert_equal('bool', dkeys[true]) |
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23806
diff
changeset
|
2799 if has('float') |
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23806
diff
changeset
|
2800 dkeys = {[1.2]: 'floatexpr', [3.4]: 'float'} |
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23806
diff
changeset
|
2801 assert_equal('floatexpr', dkeys[1.2]) |
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23806
diff
changeset
|
2802 assert_equal('float', dkeys[3.4]) |
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23806
diff
changeset
|
2803 endif |
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23806
diff
changeset
|
2804 |
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23806
diff
changeset
|
2805 # automatic conversion from number to string |
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23806
diff
changeset
|
2806 var n = 123 |
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23806
diff
changeset
|
2807 var dictnr = {[n]: 1} |
24176
12378fbc99bc
patch 8.2.2629: Vim9: error for #{{ is not desired
Bram Moolenaar <Bram@vim.org>
parents:
24174
diff
changeset
|
2808 |
12378fbc99bc
patch 8.2.2629: Vim9: error for #{{ is not desired
Bram Moolenaar <Bram@vim.org>
parents:
24174
diff
changeset
|
2809 # comment to start fold is OK |
12378fbc99bc
patch 8.2.2629: Vim9: error for #{{ is not desired
Bram Moolenaar <Bram@vim.org>
parents:
24174
diff
changeset
|
2810 var x1: number #{{ fold |
12378fbc99bc
patch 8.2.2629: Vim9: error for #{{ is not desired
Bram Moolenaar <Bram@vim.org>
parents:
24174
diff
changeset
|
2811 var x2 = 9 #{{ fold |
28113
9ef1bbe6707e
patch 8.2.4581: null types not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
28103
diff
changeset
|
2812 |
9ef1bbe6707e
patch 8.2.4581: null types not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
28103
diff
changeset
|
2813 var ds = {k: null_string} |
9ef1bbe6707e
patch 8.2.4581: null types not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
28103
diff
changeset
|
2814 assert_equal('dict<string>', typename(ds)) |
9ef1bbe6707e
patch 8.2.4581: null types not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
28103
diff
changeset
|
2815 var dl = {a: null_list} |
9ef1bbe6707e
patch 8.2.4581: null types not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
28103
diff
changeset
|
2816 assert_equal('dict<list<unknown>>', typename(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
|
2817 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2818 v9.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
|
2819 |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2820 # legacy syntax doesn't work |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2821 v9.CheckDefAndScriptFailure(["var x = #{key: 8}"], 'E1170:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2822 v9.CheckDefAndScriptFailure(["var x = 'a' #{a: 1}"], 'E1170:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2823 v9.CheckDefAndScriptFailure(["var x = 'a' .. #{a: 1}"], 'E1170:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2824 v9.CheckDefAndScriptFailure(["var x = true ? #{a: 1}"], 'E1170:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2825 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2826 v9.CheckDefAndScriptFailure(["var x = {a:8}"], 'E1069:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2827 v9.CheckDefAndScriptFailure(["var x = {a : 8}"], 'E1068:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2828 v9.CheckDefAndScriptFailure(["var x = {a :8}"], 'E1068:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2829 v9.CheckDefAndScriptFailure(["var x = {a: 8 , b: 9}"], 'E1068:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2830 v9.CheckDefAndScriptFailure(["var x = {a: 1,b: 2}"], 'E1069:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2831 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2832 v9.CheckDefAndScriptFailure(["var x = {xxx}"], 'E720:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2833 v9.CheckDefAndScriptFailure(["var x = {xxx: 1", "var y = 2"], 'E722:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2834 v9.CheckDefFailure(["var x = {xxx: 1,"], 'E723:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2835 v9.CheckScriptFailure(['vim9script', "var x = {xxx: 1,"], 'E723:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2836 v9.CheckDefAndScriptFailure(["var x = {['a']: xxx}"], ['E1001:', 'E121:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2837 v9.CheckDefAndScriptFailure(["var x = {a: 1, a: 2}"], 'E721:', 1) |
28343
909994047400
patch 8.2.4697: Vim9: crash when adding a duplicate key to a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
28263
diff
changeset
|
2838 g:key = 'x' |
909994047400
patch 8.2.4697: Vim9: crash when adding a duplicate key to a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
28263
diff
changeset
|
2839 v9.CheckDefExecAndScriptFailure(["var x = {[g:key]: 'text', [g:key]: 'text'}"], 'E721:', 1) |
909994047400
patch 8.2.4697: Vim9: crash when adding a duplicate key to a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
28263
diff
changeset
|
2840 unlet g:key |
28846
0541b9c09e21
patch 8.2.4946: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28833
diff
changeset
|
2841 v9.CheckDefExecAndScriptFailure(["var x = {[notexists]: 'text'}"], ['E1001:', 'E121: Undefined variable: notexists'], 1) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2842 v9.CheckDefExecAndScriptFailure(["var x = g:anint.member"], ['E715:', 'E488:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2843 v9.CheckDefExecAndScriptFailure(["var x = g:dict_empty.member"], 'E716:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2844 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2845 v9.CheckDefExecAndScriptFailure(['var x: dict<number> = {a: 234, b: "1"}'], 'E1012:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2846 v9.CheckDefExecAndScriptFailure(['var x: dict<number> = {a: "x", b: 134}'], 'E1012:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2847 v9.CheckDefExecAndScriptFailure(['var x: dict<string> = {a: 234, b: "1"}'], 'E1012:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2848 v9.CheckDefExecAndScriptFailure(['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
|
2849 |
23827
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23806
diff
changeset
|
2850 # invalid types for the key |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2851 v9.CheckDefAndScriptFailure(["var x = {[[1, 2]]: 0}"], ['E1105:', 'E730:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2852 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2853 v9.CheckDefFailure(['var x = ({'], 'E723:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2854 v9.CheckScriptFailure(['vim9script', 'var x = ({'], 'E723:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2855 v9.CheckDefExecAndScriptFailure(['{}[getftype("file")]'], 'E716: Key not present in Dictionary: ""', 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2856 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2857 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2858 def Test_expr9_dict_vim9script() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
2859 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
|
2860 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
|
2861 ['one']: |
21034
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
2862 1, |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2863 ['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
|
2864 } |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2865 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
|
2866 |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
2867 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
|
2868 ['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
|
2869 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
2870 |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
2871 1, |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
2872 # comment |
eb54d34ecd27
patch 8.2.1838: Vim9: cannot insert a comment line in an expression
Bram Moolenaar <Bram@vim.org>
parents:
22508
diff
changeset
|
2873 # comment |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2874 ['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
|
2875 } |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2876 assert_equal({one: 1, two: 2}, d) |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23418
diff
changeset
|
2877 |
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23418
diff
changeset
|
2878 var dd = {k: 123->len()} |
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23418
diff
changeset
|
2879 assert_equal(3, dd.k) |
21034
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
2880 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2881 v9.CheckDefAndScriptSuccess(lines) |
21034
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
2882 |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
2883 lines =<< trim END |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2884 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
|
2885 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
|
2886 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2887 v9.CheckDefAndScriptSuccess(lines) |
21118
b0baa80cb53f
patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents:
21046
diff
changeset
|
2888 |
b0baa80cb53f
patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents:
21046
diff
changeset
|
2889 lines =<< trim END |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2890 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
|
2891 two: 2, |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
2892 } |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2893 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
|
2894 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2895 v9.CheckDefAndScriptSuccess(lines) |
21034
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
2896 |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
2897 lines =<< trim END |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2898 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
|
2899 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2900 v9.CheckDefAndScriptFailure(lines, 'E1069:', 1) |
21034
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
2901 |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
2902 lines =<< trim END |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2903 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
|
2904 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2905 v9.CheckDefAndScriptFailure(lines, 'E1069:', 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
|
2906 |
5a2373c25a86
patch 8.2.1430: Vim9: error for missing comma instead of extra white space
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
2907 lines =<< trim END |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2908 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
|
2909 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2910 v9.CheckDefAndScriptFailure(lines, '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
|
2911 |
5a2373c25a86
patch 8.2.1430: Vim9: error for missing comma instead of extra white space
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
2912 lines =<< trim END |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2913 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
|
2914 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2915 v9.CheckDefAndScriptFailure(lines, 'E1069:', 1) |
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
|
2916 |
703ea7603d3e
patch 8.2.1431: Vim9: no error for white space before comma in dict
Bram Moolenaar <Bram@vim.org>
parents:
21761
diff
changeset
|
2917 lines =<< trim END |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2918 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
|
2919 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2920 v9.CheckDefAndScriptFailure(lines, 'E1068:', 1) |
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
|
2921 |
e591b448a670
patch 8.2.1451: Vim9: list type at script level only uses first item
Bram Moolenaar <Bram@vim.org>
parents:
21771
diff
changeset
|
2922 lines =<< trim END |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2923 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
|
2924 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2925 v9.CheckDefAndScriptFailure(lines, 'E1012:', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
2926 |
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
|
2927 lines =<< trim END |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2928 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
|
2929 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2930 v9.CheckDefAndScriptFailure(lines, 'E1012:', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
2931 |
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
|
2932 lines =<< trim END |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2933 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
|
2934 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2935 v9.CheckDefAndScriptFailure(lines, 'E1012:', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
2936 |
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
|
2937 lines =<< trim END |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2938 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
|
2939 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2940 v9.CheckDefAndScriptFailure(lines, 'E1012:', 1) |
22804
af26fadf333d
patch 8.2.1950: Vim9: crash when compiling function fails when getting type
Bram Moolenaar <Bram@vim.org>
parents:
22752
diff
changeset
|
2941 |
af26fadf333d
patch 8.2.1950: Vim9: crash when compiling function fails when getting type
Bram Moolenaar <Bram@vim.org>
parents:
22752
diff
changeset
|
2942 lines =<< trim END |
23106
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
2943 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
|
2944 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2945 v9.CheckDefAndScriptFailure(lines, 'E1139:', 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
2946 |
23106
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
2947 lines =<< trim END |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
2948 def Func() |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
2949 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
|
2950 enddef |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
2951 defcompile |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
2952 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2953 v9.CheckDefAndScriptFailure(lines, 'E1139:', 0) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
2954 |
23106
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
2955 lines =<< trim END |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
2956 var d = {'a': |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
2957 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2958 v9.CheckDefFailure(lines, 'E723:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2959 v9.CheckScriptFailure(['vim9script'] + lines, 'E15:', 2) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
2960 |
23106
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
2961 lines =<< trim END |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
2962 def Func() |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
2963 var d = {'a': |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
2964 enddef |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
2965 defcompile |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
2966 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2967 v9.CheckDefAndScriptFailure(lines, 'E723:', 0) |
23106
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
2968 |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
2969 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
|
2970 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
|
2971 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
|
2972 enddef |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
2973 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
|
2974 END |
22836
b129f28b0e35
patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents:
22808
diff
changeset
|
2975 if has('channel') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2976 v9.CheckDefAndScriptFailure(lines, 'E119:', 0) |
22836
b129f28b0e35
patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents:
22808
diff
changeset
|
2977 else |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2978 v9.CheckDefAndScriptFailure(lines, 'E117:', 0) |
22836
b129f28b0e35
patch 8.2.1965: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents:
22808
diff
changeset
|
2979 endif |
25232
346002a63bc6
patch 8.2.3152: Vim9: accessing "s:" results in an error
Bram Moolenaar <Bram@vim.org>
parents:
25202
diff
changeset
|
2980 |
346002a63bc6
patch 8.2.3152: Vim9: accessing "s:" results in an error
Bram Moolenaar <Bram@vim.org>
parents:
25202
diff
changeset
|
2981 lines =<< trim END |
346002a63bc6
patch 8.2.3152: Vim9: accessing "s:" results in an error
Bram Moolenaar <Bram@vim.org>
parents:
25202
diff
changeset
|
2982 vim9script |
346002a63bc6
patch 8.2.3152: Vim9: accessing "s:" results in an error
Bram Moolenaar <Bram@vim.org>
parents:
25202
diff
changeset
|
2983 var x = 99 |
346002a63bc6
patch 8.2.3152: Vim9: accessing "s:" results in an error
Bram Moolenaar <Bram@vim.org>
parents:
25202
diff
changeset
|
2984 assert_equal({x: 99}, s:) |
346002a63bc6
patch 8.2.3152: Vim9: accessing "s:" results in an error
Bram Moolenaar <Bram@vim.org>
parents:
25202
diff
changeset
|
2985 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
2986 v9.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
|
2987 enddef |
2f8b0812819f
patch 8.2.1068: Vim9: no line break allowed inside a dict
Bram Moolenaar <Bram@vim.org>
parents:
21032
diff
changeset
|
2988 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
2989 def Test_expr9_dict_in_block() |
26572
9f7568104726
patch 8.2.3815: Vim9: cannot have a multi-line dict inside a block
Bram Moolenaar <Bram@vim.org>
parents:
26562
diff
changeset
|
2990 var lines =<< trim END |
9f7568104726
patch 8.2.3815: Vim9: cannot have a multi-line dict inside a block
Bram Moolenaar <Bram@vim.org>
parents:
26562
diff
changeset
|
2991 vim9script |
9f7568104726
patch 8.2.3815: Vim9: cannot have a multi-line dict inside a block
Bram Moolenaar <Bram@vim.org>
parents:
26562
diff
changeset
|
2992 command MyCommand { |
9f7568104726
patch 8.2.3815: Vim9: cannot have a multi-line dict inside a block
Bram Moolenaar <Bram@vim.org>
parents:
26562
diff
changeset
|
2993 echo { |
9f7568104726
patch 8.2.3815: Vim9: cannot have a multi-line dict inside a block
Bram Moolenaar <Bram@vim.org>
parents:
26562
diff
changeset
|
2994 k: 0, } |
9f7568104726
patch 8.2.3815: Vim9: cannot have a multi-line dict inside a block
Bram Moolenaar <Bram@vim.org>
parents:
26562
diff
changeset
|
2995 } |
9f7568104726
patch 8.2.3815: Vim9: cannot have a multi-line dict inside a block
Bram Moolenaar <Bram@vim.org>
parents:
26562
diff
changeset
|
2996 MyCommand |
26612
2586659245db
patch 8.2.3835: the inline-function example does not work
Bram Moolenaar <Bram@vim.org>
parents:
26572
diff
changeset
|
2997 |
2586659245db
patch 8.2.3835: the inline-function example does not work
Bram Moolenaar <Bram@vim.org>
parents:
26572
diff
changeset
|
2998 command YourCommand { |
2586659245db
patch 8.2.3835: the inline-function example does not work
Bram Moolenaar <Bram@vim.org>
parents:
26572
diff
changeset
|
2999 g:global = { |
2586659245db
patch 8.2.3835: the inline-function example does not work
Bram Moolenaar <Bram@vim.org>
parents:
26572
diff
changeset
|
3000 key: 'value' } |
2586659245db
patch 8.2.3835: the inline-function example does not work
Bram Moolenaar <Bram@vim.org>
parents:
26572
diff
changeset
|
3001 } |
2586659245db
patch 8.2.3835: the inline-function example does not work
Bram Moolenaar <Bram@vim.org>
parents:
26572
diff
changeset
|
3002 YourCommand |
2586659245db
patch 8.2.3835: the inline-function example does not work
Bram Moolenaar <Bram@vim.org>
parents:
26572
diff
changeset
|
3003 assert_equal({key: 'value'}, g:global) |
2586659245db
patch 8.2.3835: the inline-function example does not work
Bram Moolenaar <Bram@vim.org>
parents:
26572
diff
changeset
|
3004 unlet g:global |
26572
9f7568104726
patch 8.2.3815: Vim9: cannot have a multi-line dict inside a block
Bram Moolenaar <Bram@vim.org>
parents:
26562
diff
changeset
|
3005 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3006 v9.CheckScriptSuccess(lines) |
26572
9f7568104726
patch 8.2.3815: Vim9: cannot have a multi-line dict inside a block
Bram Moolenaar <Bram@vim.org>
parents:
26562
diff
changeset
|
3007 |
9f7568104726
patch 8.2.3815: Vim9: cannot have a multi-line dict inside a block
Bram Moolenaar <Bram@vim.org>
parents:
26562
diff
changeset
|
3008 delcommand MyCommand |
26612
2586659245db
patch 8.2.3835: the inline-function example does not work
Bram Moolenaar <Bram@vim.org>
parents:
26572
diff
changeset
|
3009 delcommand YourCommand |
26572
9f7568104726
patch 8.2.3815: Vim9: cannot have a multi-line dict inside a block
Bram Moolenaar <Bram@vim.org>
parents:
26562
diff
changeset
|
3010 enddef |
9f7568104726
patch 8.2.3815: Vim9: cannot have a multi-line dict inside a block
Bram Moolenaar <Bram@vim.org>
parents:
26562
diff
changeset
|
3011 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3012 def Test_expr9_call_2bool() |
24796
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24713
diff
changeset
|
3013 var lines =<< trim END |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24713
diff
changeset
|
3014 vim9script |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24713
diff
changeset
|
3015 |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24713
diff
changeset
|
3016 def BrokenCall(nr: number, mode: bool, use: string): void |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24713
diff
changeset
|
3017 assert_equal(3, nr) |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24713
diff
changeset
|
3018 assert_equal(false, mode) |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24713
diff
changeset
|
3019 assert_equal('ab', use) |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24713
diff
changeset
|
3020 enddef |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24713
diff
changeset
|
3021 |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24713
diff
changeset
|
3022 def TestBrokenCall(): void |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24713
diff
changeset
|
3023 BrokenCall(3, 0, 'ab') |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24713
diff
changeset
|
3024 enddef |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24713
diff
changeset
|
3025 |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24713
diff
changeset
|
3026 TestBrokenCall() |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24713
diff
changeset
|
3027 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3028 v9.CheckScriptSuccess(lines) |
24796
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24713
diff
changeset
|
3029 enddef |
7c1375eb1636
patch 8.2.2936: Vim9: converting number to bool uses wrong stack offset
Bram Moolenaar <Bram@vim.org>
parents:
24713
diff
changeset
|
3030 |
21168
f26a606e6dbc
patch 8.2.1135: Vim9: getting a dict member may not work
Bram Moolenaar <Bram@vim.org>
parents:
21166
diff
changeset
|
3031 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
|
3032 |
19848
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
3033 def Test_expr_member() |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3034 var lines =<< trim END |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3035 assert_equal(1, g:dict_one.one) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3036 var d: dict<number> = g:dict_one |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3037 assert_equal(1, d['one']) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3038 assert_equal(1, d[ |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3039 'one' |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3040 ]) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3041 assert_equal(1, d |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3042 .one) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3043 d = {1: 1, _: 2} |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3044 assert_equal(1, d |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3045 .1) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3046 assert_equal(2, d |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3047 ._) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3048 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3049 # getting the one member should clear the dict after getting the item |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3050 assert_equal('one', {one: 'one'}.one) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3051 assert_equal('one', {one: 'one'}[g:oneString]) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3052 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3053 v9.CheckDefAndScriptSuccess(lines) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3054 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3055 v9.CheckDefAndScriptFailure(["var x = g:dict_one.#$!"], ['E1002:', 'E15:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3056 v9.CheckDefExecAndScriptFailure(["var d: dict<any>", "echo d['a']"], 'E716:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3057 v9.CheckDefExecAndScriptFailure(["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
|
3058 enddef |
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
3059 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3060 def Test_expr9_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
|
3061 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
|
3062 # 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
|
3063 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
|
3064 |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
3065 # 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
|
3066 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
|
3067 assert_equal('b', g:teststring[1]) |
23551
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23525
diff
changeset
|
3068 assert_equal('f', g:teststring[-1]) |
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
|
3069 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
|
3070 |
23414
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
3071 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
|
3072 assert_equal('bcdef', g:teststring[1 :]) |
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
3073 assert_equal('abcd', g:teststring[: 3]) |
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
3074 assert_equal('cdef', g:teststring[-4 :]) |
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
3075 assert_equal('abcdef', g:teststring[-9 :]) |
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
3076 assert_equal('abcd', g:teststring[: -3]) |
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
3077 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
|
3078 |
24128
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3079 # composing characters are included |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3080 g:teststring = 'àéû' |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3081 assert_equal('à', g:teststring[0]) |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3082 assert_equal('é', g:teststring[1]) |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3083 assert_equal('û', g:teststring[2]) |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3084 assert_equal('', g:teststring[3]) |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3085 assert_equal('', g:teststring[4]) |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3086 |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3087 assert_equal('û', g:teststring[-1]) |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3088 assert_equal('é', g:teststring[-2]) |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3089 assert_equal('à', g:teststring[-3]) |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3090 assert_equal('', g:teststring[-4]) |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3091 assert_equal('', g:teststring[-5]) |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3092 |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3093 assert_equal('à', g:teststring[0 : 0]) |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3094 assert_equal('é', g:teststring[1 : 1]) |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3095 assert_equal('àé', g:teststring[0 : 1]) |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3096 assert_equal('àéû', g:teststring[0 : -1]) |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3097 assert_equal('àé', g:teststring[0 : -2]) |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3098 assert_equal('à', g:teststring[0 : -3]) |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3099 assert_equal('', g:teststring[0 : -4]) |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3100 assert_equal('', g:teststring[0 : -5]) |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3101 assert_equal('àéû', g:teststring[ : ]) |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3102 assert_equal('àéû', g:teststring[0 : ]) |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3103 assert_equal('éû', g:teststring[1 : ]) |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3104 assert_equal('û', g:teststring[2 : ]) |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3105 assert_equal('', g:teststring[3 : ]) |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3106 assert_equal('', g:teststring[4 : ]) |
fcbb1d4df15b
patch 8.2.2605: Vim9: string index and slice does not include composing chars
Bram Moolenaar <Bram@vim.org>
parents:
24085
diff
changeset
|
3107 |
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
|
3108 # 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
|
3109 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
|
3110 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
|
3111 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
|
3112 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
|
3113 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
|
3114 |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
3115 # 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
|
3116 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
|
3117 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
|
3118 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
|
3119 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
|
3120 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
|
3121 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
|
3122 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
|
3123 |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
3124 # 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
|
3125 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
|
3126 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
|
3127 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
|
3128 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
|
3129 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
|
3130 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
|
3131 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
|
3132 |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
3133 # 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
|
3134 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
|
3135 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
|
3136 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
|
3137 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
|
3138 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
|
3139 assert_equal([], g:testlist[-1 : 1]) |
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
3140 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
|
3141 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
|
3142 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
|
3143 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
|
3144 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
|
3145 assert_equal([], g:testlist[1 : -4]) |
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
3146 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
|
3147 |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
3148 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
|
3149 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
|
3150 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
|
3151 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
|
3152 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3153 v9.CheckDefAndScriptSuccess(lines) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3154 |
27918
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27901
diff
changeset
|
3155 lines =<< trim END |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27901
diff
changeset
|
3156 vim9script |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27901
diff
changeset
|
3157 |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27901
diff
changeset
|
3158 def PosIdx(s: string): string |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27901
diff
changeset
|
3159 return s[1] |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27901
diff
changeset
|
3160 enddef |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27901
diff
changeset
|
3161 def NegIdx(s: string): string |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27901
diff
changeset
|
3162 return s[-1] |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27901
diff
changeset
|
3163 enddef |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27901
diff
changeset
|
3164 |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27901
diff
changeset
|
3165 set enc=latin1 |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27901
diff
changeset
|
3166 assert_equal("\xe4", PosIdx("a\xe4\xe5")) |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27901
diff
changeset
|
3167 assert_equal("\xe5", NegIdx("a\xe4\xe5")) |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27901
diff
changeset
|
3168 set enc=utf-8 |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27901
diff
changeset
|
3169 END |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27901
diff
changeset
|
3170 v9.CheckScriptSuccess(lines) |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27901
diff
changeset
|
3171 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3172 v9.CheckDefExecAndScriptFailure(['echo g:testblob[2]'], 'E979:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3173 v9.CheckDefExecAndScriptFailure(['echo g:testblob[-3]'], 'E979:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3174 |
28735
c428a4e53b9c
patch 8.2.4892: test failures because of changed error messages
Bram Moolenaar <Bram@vim.org>
parents:
28621
diff
changeset
|
3175 v9.CheckDefExecAndScriptFailure(['echo g:testlist[4]'], 'E684: List index out of range: 4', 1) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3176 v9.CheckDefExecAndScriptFailure(['echo g:testlist[-5]'], 'E684:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3177 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3178 v9.CheckDefExecAndScriptFailure(['echo g:testdict["a" : "b"]'], 'E719:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3179 v9.CheckDefExecAndScriptFailure(['echo g:testdict[1]'], 'E716:', 1) |
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
|
3180 |
e3f9528bddda
patch 8.2.1466: Vim9: cannot index or slice a variable with type "any"
Bram Moolenaar <Bram@vim.org>
parents:
21831
diff
changeset
|
3181 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
|
3182 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
|
3183 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
|
3184 enddef |
64f664f9b23a
patch 8.2.1134: Vim9: getting a list member may not work
Bram Moolenaar <Bram@vim.org>
parents:
21152
diff
changeset
|
3185 |
21142
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3186 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
|
3187 var lines =<< trim END |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
3188 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
|
3189 '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
|
3190 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
|
3191 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
|
3192 _: 2} |
21142
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3193 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
|
3194 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
|
3195 .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
|
3196 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
|
3197 .1) |
81c47a694479
patch 8.2.1306: checking for first character of dict key is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
21465
diff
changeset
|
3198 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
|
3199 ._) |
21142
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3200 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
|
3201 'one' |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3202 ]) |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3203 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3204 v9.CheckDefAndScriptSuccess(lines) |
21142
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3205 |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3206 lines =<< trim END |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
3207 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
|
3208 2, |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3209 3, 4 |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3210 ] |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3211 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
|
3212 1 |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3213 ]) |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3214 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
|
3215 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
|
3216 : |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3217 2 |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3218 ]) |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3219 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
|
3220 2 |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3221 : |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3222 ]) |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3223 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3224 v9.CheckDefAndScriptSuccess(lines) |
21142
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3225 enddef |
165cea61e974
patch 8.2.1122: Vim9: line continuation in dict member not recognized
Bram Moolenaar <Bram@vim.org>
parents:
21122
diff
changeset
|
3226 |
23519
cb66613dd9d5
patch 8.2.2302: Vim9: using an option value may use uninitialized memory
Bram Moolenaar <Bram@vim.org>
parents:
23515
diff
changeset
|
3227 def SetSomeVar() |
cb66613dd9d5
patch 8.2.2302: Vim9: using an option value may use uninitialized memory
Bram Moolenaar <Bram@vim.org>
parents:
23515
diff
changeset
|
3228 b:someVar = &fdm |
cb66613dd9d5
patch 8.2.2302: Vim9: using an option value may use uninitialized memory
Bram Moolenaar <Bram@vim.org>
parents:
23515
diff
changeset
|
3229 enddef |
cb66613dd9d5
patch 8.2.2302: Vim9: using an option value may use uninitialized memory
Bram Moolenaar <Bram@vim.org>
parents:
23515
diff
changeset
|
3230 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3231 def Test_expr9_option() |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3232 var lines =<< trim END |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3233 # option |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3234 set ts=11 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3235 assert_equal(11, &ts) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3236 &ts = 9 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3237 assert_equal(9, &ts) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3238 set ts=8 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3239 set grepprg=some\ text |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3240 assert_equal('some text', &grepprg) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3241 &grepprg = test_null_string() |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3242 assert_equal('', &grepprg) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3243 set grepprg& |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3244 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3245 # check matching type |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3246 var bval: bool = &tgc |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3247 var nval: number = &ts |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3248 var sval: string = &path |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3249 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3250 # check v_lock is cleared (requires using valgrind, doesn't always show) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3251 g:SetSomeVar() |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3252 b:someVar = 0 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3253 unlet b:someVar |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3254 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3255 v9.CheckDefAndScriptSuccess(lines) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3256 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3257 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3258 def Test_expr9_environment() |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3259 var lines =<< trim END |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3260 # environment variable |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3261 assert_equal('testvar', $TESTVAR) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3262 assert_equal('', $ASDF_ASD_XXX) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3263 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3264 v9.CheckDefAndScriptSuccess(lines) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3265 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3266 v9.CheckDefAndScriptFailure(["var x = $$$"], ['E1002:', 'E15:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3267 v9.CheckDefAndScriptFailure(["$"], ['E1002:', 'E15:'], 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3268 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3269 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3270 def Test_expr9_register() |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3271 var lines =<< trim END |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3272 @a = 'register a' |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3273 assert_equal('register a', @a) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3274 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3275 var fname = expand('%') |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3276 assert_equal(fname, @%) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3277 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3278 feedkeys(":echo 'some'\<CR>", "xt") |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3279 assert_equal("echo 'some'", @:) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3280 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3281 normal axyz |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3282 assert_equal("xyz", @.) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3283 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3284 @/ = 'slash' |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3285 assert_equal('slash', @/) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3286 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3287 @= = 'equal' |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3288 assert_equal('equal', @=) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3289 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3290 v9.CheckDefAndScriptSuccess(lines) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3291 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3292 v9.CheckDefAndScriptFailure(["@. = 'yes'"], ['E354:', 'E488:'], 1) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3293 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3294 |
24349
21c72f782ae1
patch 8.2.2715: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents:
24339
diff
changeset
|
3295 " This is slow when run under valgrind. |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3296 def Test_expr9_namespace() |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3297 var lines =<< trim END |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3298 g:some_var = 'some' |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3299 assert_equal('some', get(g:, 'some_var')) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3300 assert_equal('some', get(g:, 'some_var', 'xxx')) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3301 assert_equal('xxx', get(g:, 'no_var', 'xxx')) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3302 unlet g:some_var |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3303 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3304 b:some_var = 'some' |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3305 assert_equal('some', get(b:, 'some_var')) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3306 assert_equal('some', get(b:, 'some_var', 'xxx')) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3307 assert_equal('xxx', get(b:, 'no_var', 'xxx')) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3308 unlet b:some_var |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3309 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3310 w:some_var = 'some' |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3311 assert_equal('some', get(w:, 'some_var')) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3312 assert_equal('some', get(w:, 'some_var', 'xxx')) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3313 assert_equal('xxx', get(w:, 'no_var', 'xxx')) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3314 unlet w:some_var |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3315 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3316 t:some_var = 'some' |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3317 assert_equal('some', get(t:, 'some_var')) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3318 assert_equal('some', get(t:, 'some_var', 'xxx')) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3319 assert_equal('xxx', get(t:, 'no_var', 'xxx')) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3320 unlet t:some_var |
25549
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3321 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3322 v9.CheckDefAndScriptSuccess(lines) |
25549
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3323 enddef |
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3324 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3325 def Test_expr9_namespace_loop_def() |
25549
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3326 var lines =<< trim END |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3327 # check using g: in a for loop more than DO_NOT_FREE_CNT times |
25549
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3328 var exists = 0 |
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3329 var exists_not = 0 |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3330 for i in range(100000) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3331 if has_key(g:, 'does-not-exist') |
25549
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3332 exists += 1 |
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3333 else |
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3334 exists_not += 1 |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3335 endif |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3336 endfor |
25549
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3337 assert_equal(0, exists) |
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3338 assert_equal(100000, exists_not) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3339 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3340 v9.CheckDefSuccess(lines) |
25549
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3341 enddef |
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3342 |
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3343 " NOTE: this is known to be slow. To skip use: |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3344 " :let $TEST_SKIP_PAT = 'Test_expr9_namespace_loop_script' |
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3345 def Test_expr9_namespace_loop_script() |
25549
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3346 var lines =<< trim END |
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3347 vim9script |
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3348 # check using g: in a for loop more than DO_NOT_FREE_CNT times |
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3349 var exists = 0 |
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3350 var exists_not = 0 |
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3351 for i in range(100000) |
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3352 if has_key(g:, 'does-not-exist') |
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3353 exists += 1 |
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3354 else |
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3355 exists_not += 1 |
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3356 endif |
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3357 endfor |
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3358 assert_equal(0, exists) |
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3359 assert_equal(100000, exists_not) |
dc25589bfec0
patch 8.2.3311: Vim9: check for DO_NOT_FREE_CNT is very slow
Bram Moolenaar <Bram@vim.org>
parents:
25545
diff
changeset
|
3360 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3361 v9.CheckScriptSuccess(lines) |
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
|
3362 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
|
3363 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3364 def Test_expr9_parens() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21313
diff
changeset
|
3365 # (expr) |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
3366 var lines =<< trim END |
23614
455ad460ff4f
patch 8.2.2349: Vim9: cannot handle line break after parenthesis at line end
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
3367 assert_equal(4, (6 * 4) / 6) |
455ad460ff4f
patch 8.2.2349: Vim9: cannot handle line break after parenthesis at line end
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
3368 assert_equal(0, 6 * ( 4 / 6 )) |
455ad460ff4f
patch 8.2.2349: Vim9: cannot handle line break after parenthesis at line end
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
3369 |
455ad460ff4f
patch 8.2.2349: Vim9: cannot handle line break after parenthesis at line end
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
3370 assert_equal(6, +6) |
455ad460ff4f
patch 8.2.2349: Vim9: cannot handle line break after parenthesis at line end
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
3371 assert_equal(-6, -6) |
455ad460ff4f
patch 8.2.2349: Vim9: cannot handle line break after parenthesis at line end
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
3372 assert_equal(false, !-3) |
455ad460ff4f
patch 8.2.2349: Vim9: cannot handle line break after parenthesis at line end
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
3373 assert_equal(true, !+0) |
455ad460ff4f
patch 8.2.2349: Vim9: cannot handle line break after parenthesis at line end
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
3374 |
455ad460ff4f
patch 8.2.2349: Vim9: cannot handle line break after parenthesis at line end
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
3375 assert_equal(7, 5 + ( |
455ad460ff4f
patch 8.2.2349: Vim9: cannot handle line break after parenthesis at line end
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
3376 2)) |
455ad460ff4f
patch 8.2.2349: Vim9: cannot handle line break after parenthesis at line end
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
3377 assert_equal(7, 5 + ( |
455ad460ff4f
patch 8.2.2349: Vim9: cannot handle line break after parenthesis at line end
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
3378 2 |
455ad460ff4f
patch 8.2.2349: Vim9: cannot handle line break after parenthesis at line end
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
3379 )) |
455ad460ff4f
patch 8.2.2349: Vim9: cannot handle line break after parenthesis at line end
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
3380 assert_equal(7, 5 + ( # comment |
455ad460ff4f
patch 8.2.2349: Vim9: cannot handle line break after parenthesis at line end
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
3381 2)) |
455ad460ff4f
patch 8.2.2349: Vim9: cannot handle line break after parenthesis at line end
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
3382 assert_equal(7, 5 + ( # comment |
455ad460ff4f
patch 8.2.2349: Vim9: cannot handle line break after parenthesis at line end
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
3383 # comment |
455ad460ff4f
patch 8.2.2349: Vim9: cannot handle line break after parenthesis at line end
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
3384 2)) |
455ad460ff4f
patch 8.2.2349: Vim9: cannot handle line break after parenthesis at line end
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
3385 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
3386 var s = ( |
21044
dc2ca403a217
patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents:
21040
diff
changeset
|
3387 'one' |
dc2ca403a217
patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents:
21040
diff
changeset
|
3388 .. |
dc2ca403a217
patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents:
21040
diff
changeset
|
3389 'two' |
dc2ca403a217
patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents:
21040
diff
changeset
|
3390 ) |
dc2ca403a217
patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents:
21040
diff
changeset
|
3391 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
|
3392 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3393 v9.CheckDefAndScriptSuccess(lines) |
28846
0541b9c09e21
patch 8.2.4946: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28833
diff
changeset
|
3394 |
0541b9c09e21
patch 8.2.4946: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28833
diff
changeset
|
3395 v9.CheckDefAndScriptFailure(['echo ('], ['E1097: Line incomplete', 'E15: Invalid expression: "("']) |
0541b9c09e21
patch 8.2.4946: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28833
diff
changeset
|
3396 v9.CheckDefAndScriptFailure(['echo (123]'], "E110: Missing ')'", 1) |
28852
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3397 |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3398 # this uses up the ppconst stack |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3399 lines =<< eval trim END |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3400 vim9script |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3401 def F() |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3402 g:result = 1 + {repeat('(1 + ', 51)}1{repeat(')', 51)} |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3403 enddef |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3404 F() |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3405 END |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3406 v9.CheckScriptSuccess(lines) |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3407 assert_equal(g:result, 53) |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3408 unlet g:result |
21044
dc2ca403a217
patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents:
21040
diff
changeset
|
3409 enddef |
dc2ca403a217
patch 8.2.1073: Vim9: no line break allowed in () expression
Bram Moolenaar <Bram@vim.org>
parents:
21040
diff
changeset
|
3410 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3411 def Test_expr9_negate_add() |
23525
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3412 var lines =<< trim END |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3413 assert_equal(-99, -99) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3414 assert_equal(-99, - 99) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3415 assert_equal(99, +99) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3416 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3417 var nr = 88 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3418 assert_equal(-88, -nr) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3419 assert_equal(-88, - nr) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3420 assert_equal(88, + nr) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3421 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3422 v9.CheckDefAndScriptSuccess(lines) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3423 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3424 lines =<< trim END |
23525
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3425 var n = 12 |
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3426 echo ++n |
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3427 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3428 v9.CheckDefAndScriptFailure(lines, 'E15:') |
23525
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3429 lines =<< trim END |
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3430 var n = 12 |
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3431 echo --n |
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3432 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3433 v9.CheckDefAndScriptFailure(lines, 'E15:') |
23525
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3434 lines =<< trim END |
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3435 var n = 12 |
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3436 echo +-n |
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3437 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3438 v9.CheckDefAndScriptFailure(lines, 'E15:') |
23525
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3439 lines =<< trim END |
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3440 var n = 12 |
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3441 echo -+n |
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3442 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3443 v9.CheckDefAndScriptFailure(lines, 'E15:') |
23525
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3444 lines =<< trim END |
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3445 var n = 12 |
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3446 echo - -n |
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3447 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3448 v9.CheckDefAndScriptFailure(lines, 'E15:') |
23525
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3449 lines =<< trim END |
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3450 var n = 12 |
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3451 echo + +n |
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3452 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3453 v9.CheckDefAndScriptFailure(lines, 'E15:') |
19848
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
3454 enddef |
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
3455 |
24645
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24602
diff
changeset
|
3456 def LegacyReturn(): string |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24602
diff
changeset
|
3457 legacy return #{key: 'ok'}.key |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24602
diff
changeset
|
3458 enddef |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24602
diff
changeset
|
3459 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3460 def Test_expr9_legacy_script() |
24388
72f3e40f046c
patch 8.2.2734: Vim9: cannot use legacy script-local var from :def function
Bram Moolenaar <Bram@vim.org>
parents:
24361
diff
changeset
|
3461 var lines =<< trim END |
72f3e40f046c
patch 8.2.2734: Vim9: cannot use legacy script-local var from :def function
Bram Moolenaar <Bram@vim.org>
parents:
24361
diff
changeset
|
3462 let s:legacy = 'legacy' |
72f3e40f046c
patch 8.2.2734: Vim9: cannot use legacy script-local var from :def function
Bram Moolenaar <Bram@vim.org>
parents:
24361
diff
changeset
|
3463 def GetLocal(): string |
72f3e40f046c
patch 8.2.2734: Vim9: cannot use legacy script-local var from :def function
Bram Moolenaar <Bram@vim.org>
parents:
24361
diff
changeset
|
3464 return legacy |
72f3e40f046c
patch 8.2.2734: Vim9: cannot use legacy script-local var from :def function
Bram Moolenaar <Bram@vim.org>
parents:
24361
diff
changeset
|
3465 enddef |
72f3e40f046c
patch 8.2.2734: Vim9: cannot use legacy script-local var from :def function
Bram Moolenaar <Bram@vim.org>
parents:
24361
diff
changeset
|
3466 def GetLocalPrefix(): string |
72f3e40f046c
patch 8.2.2734: Vim9: cannot use legacy script-local var from :def function
Bram Moolenaar <Bram@vim.org>
parents:
24361
diff
changeset
|
3467 return s:legacy |
72f3e40f046c
patch 8.2.2734: Vim9: cannot use legacy script-local var from :def function
Bram Moolenaar <Bram@vim.org>
parents:
24361
diff
changeset
|
3468 enddef |
72f3e40f046c
patch 8.2.2734: Vim9: cannot use legacy script-local var from :def function
Bram Moolenaar <Bram@vim.org>
parents:
24361
diff
changeset
|
3469 call assert_equal('legacy', GetLocal()) |
72f3e40f046c
patch 8.2.2734: Vim9: cannot use legacy script-local var from :def function
Bram Moolenaar <Bram@vim.org>
parents:
24361
diff
changeset
|
3470 call assert_equal('legacy', GetLocalPrefix()) |
72f3e40f046c
patch 8.2.2734: Vim9: cannot use legacy script-local var from :def function
Bram Moolenaar <Bram@vim.org>
parents:
24361
diff
changeset
|
3471 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3472 v9.CheckScriptSuccess(lines) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3473 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3474 assert_equal('ok', g:LegacyReturn()) |
24645
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24602
diff
changeset
|
3475 |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24602
diff
changeset
|
3476 lines =<< trim END |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24602
diff
changeset
|
3477 vim9script |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24602
diff
changeset
|
3478 def GetNumber(): number |
28621
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28343
diff
changeset
|
3479 legacy return notexists |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28343
diff
changeset
|
3480 enddef |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28343
diff
changeset
|
3481 echo GetNumber() |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28343
diff
changeset
|
3482 END |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28343
diff
changeset
|
3483 v9.CheckScriptFailure(lines, 'E121: Undefined variable: notexists') |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28343
diff
changeset
|
3484 |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28343
diff
changeset
|
3485 lines =<< trim END |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28343
diff
changeset
|
3486 vim9script |
333be301dfe8
patch 8.2.4834: Vim9: some lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28343
diff
changeset
|
3487 def GetNumber(): number |
24645
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24602
diff
changeset
|
3488 legacy return range(3)->map('v:val + 1') |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24602
diff
changeset
|
3489 enddef |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24602
diff
changeset
|
3490 echo GetNumber() |
668df21d8bc6
patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement
Bram Moolenaar <Bram@vim.org>
parents:
24602
diff
changeset
|
3491 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3492 v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected number but got list<number>') |
24388
72f3e40f046c
patch 8.2.2734: Vim9: cannot use legacy script-local var from :def function
Bram Moolenaar <Bram@vim.org>
parents:
24361
diff
changeset
|
3493 enddef |
72f3e40f046c
patch 8.2.2734: Vim9: cannot use legacy script-local var from :def function
Bram Moolenaar <Bram@vim.org>
parents:
24361
diff
changeset
|
3494 |
20029
8fb1cf4c44d5
patch 8.2.0570: Vim9: no error when omitting type from argument
Bram Moolenaar <Bram@vim.org>
parents:
20013
diff
changeset
|
3495 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
|
3496 return arg |
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
3497 enddef |
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
3498 |
21650
79a8d723a3d2
patch 8.2.1375: Vim9: method name with digit not accepted
Bram Moolenaar <Bram@vim.org>
parents:
21644
diff
changeset
|
3499 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
|
3500 return arg |
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
3501 enddef |
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
3502 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3503 def Test_expr9_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
|
3504 var lines =<< trim END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3505 assert_equal('yes', 'yes'->g:Echo()) |
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
|
3506 assert_equal(true, !range(5)->empty()) |
23525
54ec7c8b7459
patch 8.2.2305: Vim9: "++var" and "--var" are silently accepted
Bram Moolenaar <Bram@vim.org>
parents:
23519
diff
changeset
|
3507 assert_equal([0, 1, 2], 3->range()) |
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
|
3508 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3509 v9.CheckDefAndScriptSuccess(lines) |
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
|
3510 |
21455
8cc1555f2445
patch 8.2.1278: Vim9: line break after "->" only allowed in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21425
diff
changeset
|
3511 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
|
3512 ->s:Echo4Arg()) |
19848
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
3513 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3514 v9.CheckDefAndScriptFailure(["var x = 'yes'->g:Echo"], 'E107:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3515 v9.CheckDefAndScriptFailure([ |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3516 "var x = substitute ('x', 'x', 'x', 'x')" |
26650
a07323eb647f
patch 8.2.3854: Vim9: inconsistent arguments for test functions
Bram Moolenaar <Bram@vim.org>
parents:
26612
diff
changeset
|
3517 ], ['E1001:', 'E121:'], 1) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3518 v9.CheckDefAndScriptFailure(["var Ref = function('len' [1, 2])"], ['E1123:', 'E116:'], 1) |
28846
0541b9c09e21
patch 8.2.4946: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28833
diff
changeset
|
3519 v9.CheckDefAndScriptFailure(["echo match(['foo'] , 'foo')"], 'E1068:', 1) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3520 enddef |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3521 |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
3522 def g:ExistingGlobal(): string |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3523 return 'existing' |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3524 enddef |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3525 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3526 def Test_expr9_call_global() |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
3527 assert_equal('existing', g:ExistingGlobal()) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3528 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3529 def g:DefinedLater(): string |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3530 return 'later' |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3531 enddef |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3532 assert_equal('later', g:DefinedLater()) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3533 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3534 var lines =<< trim END |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3535 echo ExistingGlobal() |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3536 END |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3537 v9.CheckDefAndScriptFailure(lines, 'E117: Unknown function: ExistingGlobal') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3538 enddef |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3539 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3540 def Test_expr9_autoload_var() |
28156
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28113
diff
changeset
|
3541 var auto_lines =<< trim END |
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28113
diff
changeset
|
3542 let autofile#var = 'found' |
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28113
diff
changeset
|
3543 END |
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28113
diff
changeset
|
3544 mkdir('Xruntime/autoload', 'p') |
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28113
diff
changeset
|
3545 writefile(auto_lines, 'Xruntime/autoload/autofile.vim') |
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28113
diff
changeset
|
3546 var save_rtp = &rtp |
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28113
diff
changeset
|
3547 &rtp = getcwd() .. '/Xruntime,' .. &rtp |
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28113
diff
changeset
|
3548 |
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28113
diff
changeset
|
3549 var lines =<< trim END |
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28113
diff
changeset
|
3550 assert_equal('found', autofile#var) |
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28113
diff
changeset
|
3551 END |
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28113
diff
changeset
|
3552 v9.CheckDefAndScriptSuccess(lines) |
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28113
diff
changeset
|
3553 |
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28113
diff
changeset
|
3554 lines =<< trim END |
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28113
diff
changeset
|
3555 echo autofile#other |
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28113
diff
changeset
|
3556 END |
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28113
diff
changeset
|
3557 v9.CheckDefExecAndScriptFailure(lines, 'E121: Undefined variable: autofile#other') |
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28113
diff
changeset
|
3558 |
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28113
diff
changeset
|
3559 &rtp = save_rtp |
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28113
diff
changeset
|
3560 delete('Xruntime', 'rf') |
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28113
diff
changeset
|
3561 enddef |
088d8dc22045
patch 8.2.4602: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28113
diff
changeset
|
3562 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3563 def Test_expr9_call_autoload() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
3564 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
|
3565 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
|
3566 return 'found' |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21739
diff
changeset
|
3567 enddef |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21739
diff
changeset
|
3568 END |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21739
diff
changeset
|
3569 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
|
3570 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
|
3571 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
|
3572 &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
|
3573 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
|
3574 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
|
3575 |
9ef7ae8ab51c
patch 8.2.1426: Vim9: cannot call autoload function in :def function
Bram Moolenaar <Bram@vim.org>
parents:
21739
diff
changeset
|
3576 &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
|
3577 delete('Xruntime', 'rf') |
19848
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
3578 enddef |
36d629aa3d6e
patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
19842
diff
changeset
|
3579 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3580 def Test_expr9_method_call() |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3581 var lines =<< trim END |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3582 new |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3583 setline(1, ['first', 'last']) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3584 'second'->append(1) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3585 "third"->append(2) |
28897
37e05627acb1
patch 8.2.4971: Vim9: interpolated string seen as range
Bram Moolenaar <Bram@vim.org>
parents:
28852
diff
changeset
|
3586 $"fourth"->append(3) |
37e05627acb1
patch 8.2.4971: Vim9: interpolated string seen as range
Bram Moolenaar <Bram@vim.org>
parents:
28852
diff
changeset
|
3587 $'fifth'->append(4) |
37e05627acb1
patch 8.2.4971: Vim9: interpolated string seen as range
Bram Moolenaar <Bram@vim.org>
parents:
28852
diff
changeset
|
3588 assert_equal(['first', 'second', 'third', 'fourth', 'fifth', 'last'], getline(1, '$')) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3589 bwipe! |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3590 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3591 var bufnr = bufnr() |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3592 var loclist = [{bufnr: bufnr, lnum: 42, col: 17, text: 'wrong'}] |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3593 loclist->setloclist(0) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3594 assert_equal([{bufnr: bufnr, |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3595 lnum: 42, |
24964
f4aa891a5ab8
patch 8.2.3019: location list only has the start position.
Bram Moolenaar <Bram@vim.org>
parents:
24958
diff
changeset
|
3596 end_lnum: 0, |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3597 col: 17, |
24964
f4aa891a5ab8
patch 8.2.3019: location list only has the start position.
Bram Moolenaar <Bram@vim.org>
parents:
24958
diff
changeset
|
3598 end_col: 0, |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3599 text: 'wrong', |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3600 pattern: '', |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3601 valid: 1, |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3602 vcol: 0, |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3603 nr: 0, |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3604 type: '', |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3605 module: ''} |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3606 ], getloclist(0)) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3607 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3608 var result: bool = get({n: 0}, 'n', 0) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3609 assert_equal(false, result) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3610 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3611 assert_equal('+string+', 'string'->((s) => '+' .. s .. '+')()) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3612 assert_equal('-text-', 'text'->((s, c) => c .. s .. c)('-')) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3613 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3614 var Join = (l) => join(l, 'x') |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3615 assert_equal('axb', ['a', 'b']->(Join)()) |
24852
3c8bd1d392d1
patch 8.2.2964: Vim9: hang when using space after ->
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
3616 |
3c8bd1d392d1
patch 8.2.2964: Vim9: hang when using space after ->
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
3617 var sorted = [3, 1, 2] |
3c8bd1d392d1
patch 8.2.2964: Vim9: hang when using space after ->
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
3618 -> sort() |
3c8bd1d392d1
patch 8.2.2964: Vim9: hang when using space after ->
Bram Moolenaar <Bram@vim.org>
parents:
24796
diff
changeset
|
3619 assert_equal([1, 2, 3], sorted) |
27173
04af0c68dba8
patch 8.2.4115: cannot use a method with a complex expression
Bram Moolenaar <Bram@vim.org>
parents:
27171
diff
changeset
|
3620 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3621 v9.CheckDefAndScriptSuccess(lines) |
27173
04af0c68dba8
patch 8.2.4115: cannot use a method with a complex expression
Bram Moolenaar <Bram@vim.org>
parents:
27171
diff
changeset
|
3622 |
04af0c68dba8
patch 8.2.4115: cannot use a method with a complex expression
Bram Moolenaar <Bram@vim.org>
parents:
27171
diff
changeset
|
3623 lines =<< trim END |
27171
374c7d5a096a
patch 8.2.4114: Vim9: type checking for a funcref does not work for method
Bram Moolenaar <Bram@vim.org>
parents:
27053
diff
changeset
|
3624 def SetNumber(n: number) |
374c7d5a096a
patch 8.2.4114: Vim9: type checking for a funcref does not work for method
Bram Moolenaar <Bram@vim.org>
parents:
27053
diff
changeset
|
3625 g:number = n |
374c7d5a096a
patch 8.2.4114: Vim9: type checking for a funcref does not work for method
Bram Moolenaar <Bram@vim.org>
parents:
27053
diff
changeset
|
3626 enddef |
374c7d5a096a
patch 8.2.4114: Vim9: type checking for a funcref does not work for method
Bram Moolenaar <Bram@vim.org>
parents:
27053
diff
changeset
|
3627 const Setit = SetNumber |
374c7d5a096a
patch 8.2.4114: Vim9: type checking for a funcref does not work for method
Bram Moolenaar <Bram@vim.org>
parents:
27053
diff
changeset
|
3628 len('text')->Setit() |
374c7d5a096a
patch 8.2.4114: Vim9: type checking for a funcref does not work for method
Bram Moolenaar <Bram@vim.org>
parents:
27053
diff
changeset
|
3629 assert_equal(4, g:number) |
27173
04af0c68dba8
patch 8.2.4115: cannot use a method with a complex expression
Bram Moolenaar <Bram@vim.org>
parents:
27171
diff
changeset
|
3630 |
04af0c68dba8
patch 8.2.4115: cannot use a method with a complex expression
Bram Moolenaar <Bram@vim.org>
parents:
27171
diff
changeset
|
3631 const SetFuncref = funcref(SetNumber) |
04af0c68dba8
patch 8.2.4115: cannot use a method with a complex expression
Bram Moolenaar <Bram@vim.org>
parents:
27171
diff
changeset
|
3632 len('longer')->SetFuncref() |
04af0c68dba8
patch 8.2.4115: cannot use a method with a complex expression
Bram Moolenaar <Bram@vim.org>
parents:
27171
diff
changeset
|
3633 assert_equal(6, g:number) |
04af0c68dba8
patch 8.2.4115: cannot use a method with a complex expression
Bram Moolenaar <Bram@vim.org>
parents:
27171
diff
changeset
|
3634 |
04af0c68dba8
patch 8.2.4115: cannot use a method with a complex expression
Bram Moolenaar <Bram@vim.org>
parents:
27171
diff
changeset
|
3635 const SetList = [SetNumber, SetFuncref] |
04af0c68dba8
patch 8.2.4115: cannot use a method with a complex expression
Bram Moolenaar <Bram@vim.org>
parents:
27171
diff
changeset
|
3636 len('xx')->SetList[0]() |
04af0c68dba8
patch 8.2.4115: cannot use a method with a complex expression
Bram Moolenaar <Bram@vim.org>
parents:
27171
diff
changeset
|
3637 assert_equal(2, g:number) |
04af0c68dba8
patch 8.2.4115: cannot use a method with a complex expression
Bram Moolenaar <Bram@vim.org>
parents:
27171
diff
changeset
|
3638 len('xxx')->SetList[1]() |
04af0c68dba8
patch 8.2.4115: cannot use a method with a complex expression
Bram Moolenaar <Bram@vim.org>
parents:
27171
diff
changeset
|
3639 assert_equal(3, g:number) |
04af0c68dba8
patch 8.2.4115: cannot use a method with a complex expression
Bram Moolenaar <Bram@vim.org>
parents:
27171
diff
changeset
|
3640 |
04af0c68dba8
patch 8.2.4115: cannot use a method with a complex expression
Bram Moolenaar <Bram@vim.org>
parents:
27171
diff
changeset
|
3641 const SetDict = {key: SetNumber} |
04af0c68dba8
patch 8.2.4115: cannot use a method with a complex expression
Bram Moolenaar <Bram@vim.org>
parents:
27171
diff
changeset
|
3642 len('xxxx')->SetDict['key']() |
04af0c68dba8
patch 8.2.4115: cannot use a method with a complex expression
Bram Moolenaar <Bram@vim.org>
parents:
27171
diff
changeset
|
3643 assert_equal(4, g:number) |
04af0c68dba8
patch 8.2.4115: cannot use a method with a complex expression
Bram Moolenaar <Bram@vim.org>
parents:
27171
diff
changeset
|
3644 len('xxxxx')->SetDict.key() |
04af0c68dba8
patch 8.2.4115: cannot use a method with a complex expression
Bram Moolenaar <Bram@vim.org>
parents:
27171
diff
changeset
|
3645 assert_equal(5, g:number) |
04af0c68dba8
patch 8.2.4115: cannot use a method with a complex expression
Bram Moolenaar <Bram@vim.org>
parents:
27171
diff
changeset
|
3646 |
27171
374c7d5a096a
patch 8.2.4114: Vim9: type checking for a funcref does not work for method
Bram Moolenaar <Bram@vim.org>
parents:
27053
diff
changeset
|
3647 unlet g:number |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3648 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3649 v9.CheckDefAndScriptSuccess(lines) |
24936
345619f35112
patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents:
24852
diff
changeset
|
3650 |
345619f35112
patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents:
24852
diff
changeset
|
3651 lines =<< trim END |
345619f35112
patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents:
24852
diff
changeset
|
3652 def RetVoid() |
345619f35112
patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents:
24852
diff
changeset
|
3653 enddef |
345619f35112
patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents:
24852
diff
changeset
|
3654 RetVoid()->byteidx(3) |
345619f35112
patch 8.2.3005: Vim9: using a void value does not give a proper error message
Bram Moolenaar <Bram@vim.org>
parents:
24852
diff
changeset
|
3655 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3656 v9.CheckDefExecFailure(lines, 'E1013:') |
28852
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3657 |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3658 lines =<< trim END |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3659 const SetList = [function('len')] |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3660 echo 'xx'->SetList[x]() |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3661 END |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3662 v9.CheckDefFailure(lines, 'E1001: Variable not found: x') |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3663 |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3664 lines =<< trim END |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3665 const SetList = [function('len')] |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3666 echo 'xx'->SetList[0]x() |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3667 END |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3668 v9.CheckDefFailure(lines, 'E15: Invalid expression: "->SetList[0]x()"') |
23352
37118deff718
patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents:
23338
diff
changeset
|
3669 enddef |
37118deff718
patch 8.2.2219: Vim9: method call with expression not supported
Bram Moolenaar <Bram@vim.org>
parents:
23338
diff
changeset
|
3670 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3671 def Test_expr9_method_call_linebreak() |
27053
58cfcd3ed15b
patch 8.2.4055: Vim9: line break in expression causes v:errmsg to be fillec
Bram Moolenaar <Bram@vim.org>
parents:
27041
diff
changeset
|
3672 # this was giving an error when skipping over the expression |
58cfcd3ed15b
patch 8.2.4055: Vim9: line break in expression causes v:errmsg to be fillec
Bram Moolenaar <Bram@vim.org>
parents:
27041
diff
changeset
|
3673 var lines =<< trim END |
58cfcd3ed15b
patch 8.2.4055: Vim9: line break in expression causes v:errmsg to be fillec
Bram Moolenaar <Bram@vim.org>
parents:
27041
diff
changeset
|
3674 vim9script |
58cfcd3ed15b
patch 8.2.4055: Vim9: line break in expression causes v:errmsg to be fillec
Bram Moolenaar <Bram@vim.org>
parents:
27041
diff
changeset
|
3675 def Test() |
58cfcd3ed15b
patch 8.2.4055: Vim9: line break in expression causes v:errmsg to be fillec
Bram Moolenaar <Bram@vim.org>
parents:
27041
diff
changeset
|
3676 var a: dict<any> = {b: {}} |
58cfcd3ed15b
patch 8.2.4055: Vim9: line break in expression causes v:errmsg to be fillec
Bram Moolenaar <Bram@vim.org>
parents:
27041
diff
changeset
|
3677 a.b->extend({f1: 1, |
58cfcd3ed15b
patch 8.2.4055: Vim9: line break in expression causes v:errmsg to be fillec
Bram Moolenaar <Bram@vim.org>
parents:
27041
diff
changeset
|
3678 f2: 2}) |
58cfcd3ed15b
patch 8.2.4055: Vim9: line break in expression causes v:errmsg to be fillec
Bram Moolenaar <Bram@vim.org>
parents:
27041
diff
changeset
|
3679 echo a |
58cfcd3ed15b
patch 8.2.4055: Vim9: line break in expression causes v:errmsg to be fillec
Bram Moolenaar <Bram@vim.org>
parents:
27041
diff
changeset
|
3680 enddef |
58cfcd3ed15b
patch 8.2.4055: Vim9: line break in expression causes v:errmsg to be fillec
Bram Moolenaar <Bram@vim.org>
parents:
27041
diff
changeset
|
3681 defcompile |
58cfcd3ed15b
patch 8.2.4055: Vim9: line break in expression causes v:errmsg to be fillec
Bram Moolenaar <Bram@vim.org>
parents:
27041
diff
changeset
|
3682 assert_equal('', v:errmsg) |
58cfcd3ed15b
patch 8.2.4055: Vim9: line break in expression causes v:errmsg to be fillec
Bram Moolenaar <Bram@vim.org>
parents:
27041
diff
changeset
|
3683 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3684 v9.CheckScriptSuccess(lines) |
27053
58cfcd3ed15b
patch 8.2.4055: Vim9: line break in expression causes v:errmsg to be fillec
Bram Moolenaar <Bram@vim.org>
parents:
27041
diff
changeset
|
3685 enddef |
58cfcd3ed15b
patch 8.2.4055: Vim9: line break in expression causes v:errmsg to be fillec
Bram Moolenaar <Bram@vim.org>
parents:
27041
diff
changeset
|
3686 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3687 def Test_expr9_method_call_import() |
27191
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3688 var lines =<< trim END |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3689 vim9script |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3690 export def Square(items: list<number>): list<number> |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3691 return map(items, (_, i) => i * i) |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3692 enddef |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3693 END |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3694 call writefile(lines, 'Xsquare.vim') |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3695 |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3696 lines =<< trim END |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3697 vim9script |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3698 import './Xsquare.vim' |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3699 |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3700 def Test(): list<number> |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3701 return range(5) |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3702 ->Xsquare.Square() |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3703 ->map((_, i) => i * 10) |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3704 enddef |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3705 |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3706 assert_equal([0, 10, 40, 90, 160], Test()) |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3707 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3708 v9.CheckScriptSuccess(lines) |
27191
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3709 |
27199
d4f254d02d7c
patch 8.2.4128: crash when method cannot be found
Bram Moolenaar <Bram@vim.org>
parents:
27191
diff
changeset
|
3710 lines =<< trim END |
d4f254d02d7c
patch 8.2.4128: crash when method cannot be found
Bram Moolenaar <Bram@vim.org>
parents:
27191
diff
changeset
|
3711 vim9script |
d4f254d02d7c
patch 8.2.4128: crash when method cannot be found
Bram Moolenaar <Bram@vim.org>
parents:
27191
diff
changeset
|
3712 import './Xsquare.vim' |
d4f254d02d7c
patch 8.2.4128: crash when method cannot be found
Bram Moolenaar <Bram@vim.org>
parents:
27191
diff
changeset
|
3713 |
d4f254d02d7c
patch 8.2.4128: crash when method cannot be found
Bram Moolenaar <Bram@vim.org>
parents:
27191
diff
changeset
|
3714 echo range(5)->Xsquare.NoSuchFunc() |
d4f254d02d7c
patch 8.2.4128: crash when method cannot be found
Bram Moolenaar <Bram@vim.org>
parents:
27191
diff
changeset
|
3715 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3716 v9.CheckScriptFailure(lines, 'E1048: Item not found in script: NoSuchFunc') |
27199
d4f254d02d7c
patch 8.2.4128: crash when method cannot be found
Bram Moolenaar <Bram@vim.org>
parents:
27191
diff
changeset
|
3717 |
27191
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3718 delete('Xsquare.vim') |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3719 enddef |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3720 |
63f8dbcf6a74
patch 8.2.4124: Vim9: method in compiled function may not see script item
Bram Moolenaar <Bram@vim.org>
parents:
27175
diff
changeset
|
3721 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3722 def Test_expr9_not() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
3723 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
|
3724 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
|
3725 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
|
3726 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
|
3727 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
|
3728 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
|
3729 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
|
3730 |
22606
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
3731 assert_equal(true, ! false) |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
3732 assert_equal(true, !! true) |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
3733 assert_equal(true, ! ! true) |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
3734 assert_equal(true, !!! false) |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
3735 assert_equal(true, ! ! ! false) |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
3736 |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
3737 g:true = true |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
3738 g:false = false |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
3739 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
|
3740 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
|
3741 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
|
3742 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
|
3743 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
|
3744 unlet g:true |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
3745 unlet g:false |
336ac63fb987
patch 8.2.1851: Vim9: "!" followed by space incorrectly used
Bram Moolenaar <Bram@vim.org>
parents:
22580
diff
changeset
|
3746 |
21733
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
3747 assert_equal(true, !test_null_partial()) |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23418
diff
changeset
|
3748 assert_equal(false, !() => 'yes') |
21733
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
3749 |
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
3750 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
|
3751 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
|
3752 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
|
3753 |
21733
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
3754 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
|
3755 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
|
3756 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
|
3757 endif |
19483
0d3dcb4476ba
patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
19469
diff
changeset
|
3758 |
21733
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
3759 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
|
3760 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
|
3761 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
|
3762 |
21733
1bb5adfe5966
patch 8.2.1416: Vim9: boolean evaluation does not work as intended
Bram Moolenaar <Bram@vim.org>
parents:
21725
diff
changeset
|
3763 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
|
3764 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
|
3765 |
caf0286cf02b
patch 8.2.1419: Vim9: not operator applied too early
Bram Moolenaar <Bram@vim.org>
parents:
21737
diff
changeset
|
3766 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
|
3767 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
|
3768 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3769 v9.CheckDefAndScriptSuccess(lines) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3770 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3771 |
25634
27cb2e79ccde
patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25549
diff
changeset
|
3772 let g:anumber = 42 |
27cb2e79ccde
patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25549
diff
changeset
|
3773 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3774 def Test_expr9_negate() |
25634
27cb2e79ccde
patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25549
diff
changeset
|
3775 var lines =<< trim END |
27cb2e79ccde
patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25549
diff
changeset
|
3776 var nr = 1 |
27cb2e79ccde
patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25549
diff
changeset
|
3777 assert_equal(-1, -nr) |
27cb2e79ccde
patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25549
diff
changeset
|
3778 assert_equal(-42, -g:anumber) |
27cb2e79ccde
patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25549
diff
changeset
|
3779 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3780 v9.CheckDefAndScriptSuccess(lines) |
25634
27cb2e79ccde
patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25549
diff
changeset
|
3781 enddef |
27cb2e79ccde
patch 8.2.3353: Vim9: type of argument for negate not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25549
diff
changeset
|
3782 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3783 func Test_expr9_fails() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3784 call v9.CheckDefFailure(["var x = (12"], "E1097:", 3) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3785 call v9.CheckScriptFailure(['vim9script', "var x = (12"], 'E110:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3786 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3787 call v9.CheckDefAndScriptFailure(["var x = -'xx'"], "E1030:", 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3788 call v9.CheckDefAndScriptFailure(["var x = +'xx'"], "E1030:", 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3789 call v9.CheckDefAndScriptFailure(["var x = -0z12"], "E974:", 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3790 call v9.CheckDefExecAndScriptFailure(["var x = -[8]"], ["E1012:", 'E745:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3791 call v9.CheckDefExecAndScriptFailure(["var x = -{a: 1}"], ["E1012:", 'E728:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3792 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3793 call v9.CheckDefAndScriptFailure(["var x = @"], "E1002:", 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3794 call v9.CheckDefAndScriptFailure(["var x = @<"], "E354:", 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3795 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3796 call v9.CheckDefFailure(["var x = [1, 2"], "E697:", 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3797 call v9.CheckScriptFailure(['vim9script', "var x = [1, 2"], 'E696:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3798 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3799 call v9.CheckDefAndScriptFailure(["var x = [notfound]"], ["E1001:", 'E121:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3800 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3801 call v9.CheckDefAndScriptFailure(["var X = () => 123)"], 'E488:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3802 call v9.CheckDefAndScriptFailure(["var x = 123->((x) => x + 5)"], "E107:", 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3803 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3804 call v9.CheckDefAndScriptFailure(["var x = ¬exist"], 'E113:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3805 call v9.CheckDefAndScriptFailure(["&grepprg = [343]"], ['E1012:', 'E730:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3806 |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27539
diff
changeset
|
3807 call v9.CheckDefExecAndScriptFailure(["echo s:doesnt_exist"], ['E121:', 'E1268:'], 1) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3808 call v9.CheckDefExecAndScriptFailure(["echo g:doesnt_exist"], 'E121:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3809 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3810 call v9.CheckDefAndScriptFailure(["echo a:somevar"], ['E1075:', 'E121:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3811 call v9.CheckDefAndScriptFailure(["echo l:somevar"], ['E1075:', 'E121:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3812 call v9.CheckDefAndScriptFailure(["echo x:somevar"], ['E1075:', 'E121:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3813 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3814 call v9.CheckDefExecAndScriptFailure(["var x = +g:astring"], ['E1012:', 'E1030:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3815 call v9.CheckDefExecAndScriptFailure(["var x = +g:ablob"], ['E1012:', 'E974:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3816 call v9.CheckDefExecAndScriptFailure(["var x = +g:alist"], ['E1012:', 'E745:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3817 call v9.CheckDefExecAndScriptFailure(["var x = +g:adict"], ['E1012:', 'E728:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3818 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3819 call v9.CheckDefAndScriptFailure(["var x = ''", "var y = x.memb"], ['E1229: Expected dictionary for using key "memb", but got string', 'E488:'], 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3820 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3821 call v9.CheckDefAndScriptFailure(["'yes'->", "Echo()"], ['E488: Trailing characters: ->', 'E260: Missing name after ->'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3822 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3823 call v9.CheckDefExecFailure(["[1, 2->len()"], 'E697:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3824 call v9.CheckScriptFailure(['vim9script', "[1, 2->len()"], 'E696:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3825 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3826 call v9.CheckDefFailure(["{a: 1->len()"], 'E723:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3827 call v9.CheckScriptFailure(['vim9script', "{a: 1->len()"], 'E722:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3828 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3829 call v9.CheckDefExecFailure(["{['a']: 1->len()"], 'E723:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3830 call v9.CheckScriptFailure(['vim9script', "{['a']: 1->len()"], 'E722:', 2) |
28852
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3831 |
ffd57385eef8
patch 8.2.4949: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28846
diff
changeset
|
3832 call v9.CheckDefFailure(['echo #{}'], 'E1170:') |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3833 endfunc |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3834 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3835 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
|
3836 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3837 func CallMe(arg) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3838 return a:arg |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3839 endfunc |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3840 |
19437
5d34ae66118e
patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents:
19423
diff
changeset
|
3841 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
|
3842 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
|
3843 endfunc |
5d34ae66118e
patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents:
19423
diff
changeset
|
3844 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3845 def Test_expr9_trailing() |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3846 var lines =<< trim END |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3847 # user function call |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3848 assert_equal(123, g:CallMe(123)) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3849 assert_equal(123, g:CallMe( 123)) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3850 assert_equal(123, g:CallMe(123 )) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3851 assert_equal('yesno', g:CallMe2('yes', 'no')) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3852 assert_equal('yesno', g:CallMe2( 'yes', 'no' )) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3853 assert_equal('nothing', g:CallMe('nothing')) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3854 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3855 # partial call |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3856 var Part = function('g:CallMe') |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3857 assert_equal('yes', Part('yes')) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3858 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3859 # funcref call, using list index |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3860 var l = [] |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3861 g:Funcrefs[0](l, 2) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3862 assert_equal([2], l) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3863 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3864 # method call |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3865 l = [2, 5, 6] |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3866 l->map((k, v) => k + v) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3867 assert_equal([2, 6, 8], l) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3868 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3869 # lambda method call |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3870 l = [2, 5] |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3871 l->((ll) => add(ll, 8))() |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3872 assert_equal([2, 5, 8], l) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3873 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3874 # dict member |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3875 var d = {key: 123} |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3876 assert_equal(123, d.key) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3877 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3878 v9.CheckDefAndScriptSuccess(lines) |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3879 enddef |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3880 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3881 def Test_expr9_string_subscript() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
3882 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
|
3883 var text = 'abcdef' |
23551
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23525
diff
changeset
|
3884 assert_equal('f', text[-1]) |
21823
b1f3d8a44ab6
patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
3885 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
|
3886 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
|
3887 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
|
3888 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
|
3889 |
23551
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23525
diff
changeset
|
3890 text = 'ábçdë' |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23525
diff
changeset
|
3891 assert_equal('ë', text[-1]) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23525
diff
changeset
|
3892 assert_equal('d', text[-2]) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23525
diff
changeset
|
3893 assert_equal('ç', text[-3]) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23525
diff
changeset
|
3894 assert_equal('b', text[-4]) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23525
diff
changeset
|
3895 assert_equal('á', text[-5]) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23525
diff
changeset
|
3896 assert_equal('', text[-6]) |
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23525
diff
changeset
|
3897 |
21823
b1f3d8a44ab6
patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
3898 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
|
3899 assert_equal('', text[-999]) |
23551
1bb7fa4f9b35
patch 8.2.2318: Vim9: string and list index work differently
Bram Moolenaar <Bram@vim.org>
parents:
23525
diff
changeset
|
3900 assert_equal('f', text[-1]) |
21823
b1f3d8a44ab6
patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
3901 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
|
3902 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
|
3903 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
|
3904 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
|
3905 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
|
3906 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
|
3907 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
|
3908 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
|
3909 |
23414
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
3910 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
|
3911 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
|
3912 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
|
3913 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
|
3914 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
|
3915 : -1]) |
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
3916 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
|
3917 -1]) |
ccad66ac6c3e
patch 8.2.1462: Vim9: string slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21823
diff
changeset
|
3918 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
|
3919 ]) |
23414
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
3920 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
|
3921 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
|
3922 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
|
3923 assert_equal('ëf', text[4 : -1]) |
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
3924 assert_equal('f', text[5 : -1]) |
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
3925 assert_equal('', text[6 : -1]) |
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
3926 assert_equal('', text[999 : -1]) |
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
3927 |
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
3928 assert_equal('ábçd', text[: 3]) |
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
3929 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
|
3930 assert_equal('ábçdëf', text[:]) |
24602
033b43570140
patch 8.2.2840: Vim9: member operation not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24553
diff
changeset
|
3931 |
033b43570140
patch 8.2.2840: Vim9: member operation not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24553
diff
changeset
|
3932 assert_equal('a', g:astring[0]) |
033b43570140
patch 8.2.2840: Vim9: member operation not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24553
diff
changeset
|
3933 assert_equal('sd', g:astring[1 : 2]) |
033b43570140
patch 8.2.2840: Vim9: member operation not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24553
diff
changeset
|
3934 assert_equal('asdf', g:astring[:]) |
21823
b1f3d8a44ab6
patch 8.2.1461: Vim9: string indexes are counted in bytes
Bram Moolenaar <Bram@vim.org>
parents:
21821
diff
changeset
|
3935 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3936 v9.CheckDefAndScriptSuccess(lines) |
23106
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
3937 |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
3938 lines =<< trim END |
23414
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
3939 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
|
3940 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3941 v9.CheckDefFailure(lines, 'E1097:', 3) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3942 v9.CheckScriptFailure(['vim9script'] + lines, 'E15:', 2) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3943 |
23106
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
3944 lines =<< trim END |
23414
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
3945 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
|
3946 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3947 v9.CheckDefAndScriptFailure(lines, ['E1001:', 'E121:'], 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3948 |
23106
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
3949 lines =<< trim END |
23414
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
3950 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
|
3951 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3952 v9.CheckDefFailure(lines, 'E1097:', 3) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3953 v9.CheckScriptFailure(['vim9script'] + lines, 'E111:', 2) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3954 |
23106
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
3955 lines =<< trim END |
23414
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
3956 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
|
3957 echo d |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
3958 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3959 v9.CheckDefAndScriptFailure(lines, 'E111:', 2) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3960 |
23106
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
3961 lines =<< trim END |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
3962 var d = 'asdf'['1'] |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
3963 echo d |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
3964 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3965 v9.CheckDefAndScriptFailure(lines, ['E1012: Type mismatch; expected number but got string', 'E1030: Using a String as a Number: "1"'], 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3966 |
23106
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
3967 lines =<< trim END |
23414
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
3968 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
|
3969 echo d |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
3970 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3971 v9.CheckDefAndScriptFailure(lines, ['E1012: Type mismatch; expected number but got string', 'E1030: Using a String as a Number: "1"'], 1) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3972 |
23106
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
3973 lines =<< trim END |
23414
9bd3873b13e2
patch 8.2.2250: Vim9: sublist is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23368
diff
changeset
|
3974 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
|
3975 echo d |
b0c88aa0175b
patch 8.2.2099: Vim9: some checks are not tested
Bram Moolenaar <Bram@vim.org>
parents:
23088
diff
changeset
|
3976 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
3977 v9.CheckDefAndScriptFailure(lines, ['E1012: Type mismatch; expected number but got string', 'E1030: Using a String as a Number: "2"'], 1) |
21393
320581a133d9
patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents:
21387
diff
changeset
|
3978 enddef |
320581a133d9
patch 8.2.1247: Vim9: cannot index a character in a string
Bram Moolenaar <Bram@vim.org>
parents:
21387
diff
changeset
|
3979 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
3980 def Test_expr9_list_subscript() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
3981 var lines =<< trim END |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3982 var list = [0, 1, 2, 3, 4] |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3983 assert_equal(0, list[0]) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3984 assert_equal(4, list[4]) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3985 assert_equal(4, list[-1]) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3986 assert_equal(0, list[-5]) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3987 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3988 assert_equal([0, 1, 2, 3, 4], list[0 : 4]) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3989 assert_equal([0, 1, 2, 3, 4], list[:]) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3990 assert_equal([1, 2, 3, 4], list[1 :]) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3991 assert_equal([2, 3, 4], list[2 : -1]) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3992 assert_equal([4], list[4 : -1]) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3993 assert_equal([], list[5 : -1]) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3994 assert_equal([], list[999 : -1]) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3995 assert_equal([1, 2, 3, 4], list[g:theone : g:thefour]) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3996 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3997 assert_equal([0, 1, 2, 3], list[0 : 3]) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3998 assert_equal([0], list[0 : 0]) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
3999 assert_equal([0, 1, 2, 3, 4], list[0 : -1]) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4000 assert_equal([0, 1, 2], list[0 : -3]) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4001 assert_equal([0], list[0 : -5]) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4002 assert_equal([], list[0 : -6]) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4003 assert_equal([], list[0 : -99]) |
24602
033b43570140
patch 8.2.2840: Vim9: member operation not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24553
diff
changeset
|
4004 |
033b43570140
patch 8.2.2840: Vim9: member operation not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24553
diff
changeset
|
4005 assert_equal(2, g:alist[0]) |
033b43570140
patch 8.2.2840: Vim9: member operation not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24553
diff
changeset
|
4006 assert_equal([2, 3, 4], g:alist[:]) |
21828
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
4007 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4008 v9.CheckDefAndScriptSuccess(lines) |
21831
d8422de73113
patch 8.2.1465: Vim9: subscript not handled properly
Bram Moolenaar <Bram@vim.org>
parents:
21828
diff
changeset
|
4009 |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
4010 lines = ['var l = [0, 1, 2]', 'echo l[g:astring : g:theone]'] |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4011 v9.CheckDefExecAndScriptFailure(lines, ['E1012:', 'E1030:'], 2) |
23561
647ff61c0bcd
patch 8.2.2323: Vim9: error when inferring type from empty dict/list
Bram Moolenaar <Bram@vim.org>
parents:
23555
diff
changeset
|
4012 |
647ff61c0bcd
patch 8.2.2323: Vim9: error when inferring type from empty dict/list
Bram Moolenaar <Bram@vim.org>
parents:
23555
diff
changeset
|
4013 lines =<< trim END |
647ff61c0bcd
patch 8.2.2323: Vim9: error when inferring type from empty dict/list
Bram Moolenaar <Bram@vim.org>
parents:
23555
diff
changeset
|
4014 var ld = [] |
647ff61c0bcd
patch 8.2.2323: Vim9: error when inferring type from empty dict/list
Bram Moolenaar <Bram@vim.org>
parents:
23555
diff
changeset
|
4015 def Func() |
647ff61c0bcd
patch 8.2.2323: Vim9: error when inferring type from empty dict/list
Bram Moolenaar <Bram@vim.org>
parents:
23555
diff
changeset
|
4016 eval ld[0].key |
647ff61c0bcd
patch 8.2.2323: Vim9: error when inferring type from empty dict/list
Bram Moolenaar <Bram@vim.org>
parents:
23555
diff
changeset
|
4017 enddef |
647ff61c0bcd
patch 8.2.2323: Vim9: error when inferring type from empty dict/list
Bram Moolenaar <Bram@vim.org>
parents:
23555
diff
changeset
|
4018 defcompile |
647ff61c0bcd
patch 8.2.2323: Vim9: error when inferring type from empty dict/list
Bram Moolenaar <Bram@vim.org>
parents:
23555
diff
changeset
|
4019 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4020 v9.CheckDefAndScriptSuccess(lines) |
21828
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
4021 enddef |
af5db9b6d210
patch 8.2.1463: Vim9: list slice not supported yet
Bram Moolenaar <Bram@vim.org>
parents:
21826
diff
changeset
|
4022 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
4023 def Test_expr9_dict_subscript() |
22421
2765ae0ce02e
patch 8.2.1759: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22419
diff
changeset
|
4024 var lines =<< trim END |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
4025 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
|
4026 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
|
4027 assert_true(res) |
23561
647ff61c0bcd
patch 8.2.2323: Vim9: error when inferring type from empty dict/list
Bram Moolenaar <Bram@vim.org>
parents:
23555
diff
changeset
|
4028 |
24602
033b43570140
patch 8.2.2840: Vim9: member operation not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24553
diff
changeset
|
4029 assert_equal(2, g:adict['aaa']) |
033b43570140
patch 8.2.2840: Vim9: member operation not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24553
diff
changeset
|
4030 assert_equal(8, g:adict.bbb) |
033b43570140
patch 8.2.2840: Vim9: member operation not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24553
diff
changeset
|
4031 |
23561
647ff61c0bcd
patch 8.2.2323: Vim9: error when inferring type from empty dict/list
Bram Moolenaar <Bram@vim.org>
parents:
23555
diff
changeset
|
4032 var dd = {} |
647ff61c0bcd
patch 8.2.2323: Vim9: error when inferring type from empty dict/list
Bram Moolenaar <Bram@vim.org>
parents:
23555
diff
changeset
|
4033 def Func1() |
647ff61c0bcd
patch 8.2.2323: Vim9: error when inferring type from empty dict/list
Bram Moolenaar <Bram@vim.org>
parents:
23555
diff
changeset
|
4034 eval dd.key1.key2 |
647ff61c0bcd
patch 8.2.2323: Vim9: error when inferring type from empty dict/list
Bram Moolenaar <Bram@vim.org>
parents:
23555
diff
changeset
|
4035 enddef |
647ff61c0bcd
patch 8.2.2323: Vim9: error when inferring type from empty dict/list
Bram Moolenaar <Bram@vim.org>
parents:
23555
diff
changeset
|
4036 def Func2() |
647ff61c0bcd
patch 8.2.2323: Vim9: error when inferring type from empty dict/list
Bram Moolenaar <Bram@vim.org>
parents:
23555
diff
changeset
|
4037 eval dd['key1'].key2 |
647ff61c0bcd
patch 8.2.2323: Vim9: error when inferring type from empty dict/list
Bram Moolenaar <Bram@vim.org>
parents:
23555
diff
changeset
|
4038 enddef |
647ff61c0bcd
patch 8.2.2323: Vim9: error when inferring type from empty dict/list
Bram Moolenaar <Bram@vim.org>
parents:
23555
diff
changeset
|
4039 defcompile |
22244
9f6b8fdea159
patch 8.2.1671: Vim9: stray error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
22238
diff
changeset
|
4040 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4041 v9.CheckDefAndScriptSuccess(lines) |
22244
9f6b8fdea159
patch 8.2.1671: Vim9: stray error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
22238
diff
changeset
|
4042 enddef |
9f6b8fdea159
patch 8.2.1671: Vim9: stray error for missing white space
Bram Moolenaar <Bram@vim.org>
parents:
22238
diff
changeset
|
4043 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
4044 def Test_expr9_blob_subscript() |
24602
033b43570140
patch 8.2.2840: Vim9: member operation not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24553
diff
changeset
|
4045 var lines =<< trim END |
033b43570140
patch 8.2.2840: Vim9: member operation not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24553
diff
changeset
|
4046 var b = 0z112233 |
033b43570140
patch 8.2.2840: Vim9: member operation not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24553
diff
changeset
|
4047 assert_equal(0x11, b[0]) |
033b43570140
patch 8.2.2840: Vim9: member operation not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24553
diff
changeset
|
4048 assert_equal(0z112233, b[:]) |
033b43570140
patch 8.2.2840: Vim9: member operation not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24553
diff
changeset
|
4049 |
033b43570140
patch 8.2.2840: Vim9: member operation not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24553
diff
changeset
|
4050 assert_equal(0x01, g:ablob[0]) |
033b43570140
patch 8.2.2840: Vim9: member operation not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24553
diff
changeset
|
4051 assert_equal(0z01ab, g:ablob[:]) |
033b43570140
patch 8.2.2840: Vim9: member operation not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24553
diff
changeset
|
4052 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4053 v9.CheckDefAndScriptSuccess(lines) |
24602
033b43570140
patch 8.2.2840: Vim9: member operation not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24553
diff
changeset
|
4054 enddef |
033b43570140
patch 8.2.2840: Vim9: member operation not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24553
diff
changeset
|
4055 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
4056 def Test_expr9_funcref_subscript() |
28846
0541b9c09e21
patch 8.2.4946: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28833
diff
changeset
|
4057 var lines =<< trim END |
0541b9c09e21
patch 8.2.4946: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28833
diff
changeset
|
4058 var l = function('len')("abc") |
0541b9c09e21
patch 8.2.4946: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28833
diff
changeset
|
4059 assert_equal(3, l) |
0541b9c09e21
patch 8.2.4946: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28833
diff
changeset
|
4060 END |
0541b9c09e21
patch 8.2.4946: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28833
diff
changeset
|
4061 v9.CheckDefAndScriptSuccess(lines) |
0541b9c09e21
patch 8.2.4946: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28833
diff
changeset
|
4062 |
0541b9c09e21
patch 8.2.4946: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28833
diff
changeset
|
4063 v9.CheckDefAndScriptFailure(["var l = function('len')(xxx)"], ['E1001: Variable not found: xxx', 'E121: Undefined variable: xxx'], 1) |
0541b9c09e21
patch 8.2.4946: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28833
diff
changeset
|
4064 enddef |
0541b9c09e21
patch 8.2.4946: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
28833
diff
changeset
|
4065 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
4066 def Test_expr9_subscript_linebreak() |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4067 var lines =<< trim END |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4068 var range = range( |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4069 3) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4070 var l = range |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4071 ->mapnew('string(v:key)') |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4072 assert_equal(['0', '1', '2'], l) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4073 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4074 l = range |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4075 ->mapnew('string(v:key)') |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4076 assert_equal(['0', '1', '2'], l) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4077 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4078 l = range # comment |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4079 ->mapnew('string(v:key)') |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4080 assert_equal(['0', '1', '2'], l) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4081 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4082 l = range |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4083 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4084 ->mapnew('string(v:key)') |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4085 assert_equal(['0', '1', '2'], l) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4086 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4087 l = range |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4088 # comment |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4089 ->mapnew('string(v:key)') |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4090 assert_equal(['0', '1', '2'], l) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4091 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4092 assert_equal('1', l[ |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4093 1]) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4094 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4095 var d = {one: 33} |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4096 assert_equal(33, d |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4097 .one) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4098 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4099 v9.CheckDefAndScriptSuccess(lines) |
24339
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4100 |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4101 lines =<< trim END |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4102 var d = {one: 33} |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4103 assert_equal(33, d. |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4104 one) |
236e9ebdb30e
patch 8.2.2710: Vim9: not all tests cover script and :def function
Bram Moolenaar <Bram@vim.org>
parents:
24331
diff
changeset
|
4105 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4106 v9.CheckDefAndScriptFailure(lines, ['E1127:', 'E116:'], 2) |
20949
62912ad41aff
patch 8.2.1026: Vim9: cannot break the line after "->"
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
4107 enddef |
62912ad41aff
patch 8.2.1026: Vim9: cannot break the line after "->"
Bram Moolenaar <Bram@vim.org>
parents:
20919
diff
changeset
|
4108 |
28962
abdea69d21b6
patch 8.2.5003: cannot do bitwise shifts
Bram Moolenaar <Bram@vim.org>
parents:
28899
diff
changeset
|
4109 func Test_expr9_trailing_fails() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4110 call v9.CheckDefAndScriptFailure(['var l = [2]', 'l->((ll) => add(ll, 8))'], 'E107:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4111 call v9.CheckDefAndScriptFailure(['var l = [2]', 'l->((ll) => add(ll, 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
|
4112 endfunc |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4113 |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4114 func Test_expr_fails() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4115 call v9.CheckDefAndScriptFailure(["var x = '1'is2"], 'E488:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4116 call v9.CheckDefAndScriptFailure(["var x = '1'isnot2"], 'E488:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4117 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4118 call v9.CheckDefAndScriptFailure(["CallMe ('yes')"], ['E476:', 'E492:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4119 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4120 call v9.CheckDefAndScriptFailure(["CallMe2('yes','no')"], 'E1069:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4121 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4122 call v9.CheckDefAndScriptFailure(["v:nosuch += 3"], ['E1001:', 'E121:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4123 call v9.CheckDefAndScriptFailure(["var v:statusmsg = ''"], 'E1016: Cannot declare a v: variable:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4124 call v9.CheckDefAndScriptFailure(["var asdf = v:nosuch"], ['E1001:', 'E121:'], 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4125 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4126 call v9.CheckDefFailure(["echo len('asdf'"], 'E110:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4127 call v9.CheckScriptFailure(['vim9script', "echo len('asdf'"], 'E116:', 2) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4128 |
28263
c446812efd60
patch 8.2.4657: errors for functions are sometimes hard to read
Bram Moolenaar <Bram@vim.org>
parents:
28231
diff
changeset
|
4129 call v9.CheckDefAndScriptFailure(["echo Func01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789()"], ['E1011:', 'E117:'], 1) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27199
diff
changeset
|
4130 call v9.CheckDefAndScriptFailure(["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
|
4131 endfunc |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21763
diff
changeset
|
4132 |
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21763
diff
changeset
|
4133 " vim: shiftwidth=2 sts=2 expandtab |