Mercurial > vim
annotate src/testdir/test_vim9_assign.vim @ 28560:060fc3b69697 v8.2.4804
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Commit: https://github.com/vim/vim/commit/1fc6ea9bf3548b578676331f5eac1f7e0611c268
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Thu Apr 21 23:30:15 2022 +0100
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Problem: Expression in heredoc doesn't work for compiled function.
Solution: Implement compiling the heredoc expressions. (Yegappan Lakshmanan,
closes #10232)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 22 Apr 2022 00:45:04 +0200 |
parents | 769599ee9f06 |
children | 723c7d940cba |
rev | line source |
---|---|
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 " Test Vim9 assignments |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
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:
27406
diff
changeset
|
4 import './vim9.vim' as v9 |
26954
11ee2667a09a
patch 8.2.4006: Vim9: crash when declaring variable on the command line
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
5 source term_util.vim |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 let s:appendToMe = 'xxx' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 let s:addToMe = 111 |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
9 let s:newVar = '' |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 let g:existing = 'yes' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 let g:inc_counter = 1 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 let $SOME_ENV_VAR = 'some' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 let g:alist = [7] |
23982
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
14 let g:adict = #{a: 1} |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 let g:astring = 'text' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 def Test_assignment_bool() |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
18 var bool1: bool = true |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 assert_equal(v:true, bool1) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
20 var bool2: bool = false |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 assert_equal(v:false, bool2) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
23 var bool3: bool = 0 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 assert_equal(false, bool3) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
25 var bool4: bool = 1 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 assert_equal(true, bool4) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22458
diff
changeset
|
28 var bool5: bool = 1 && true |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 assert_equal(true, bool5) |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22458
diff
changeset
|
30 var bool6: bool = 0 && 1 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 assert_equal(false, bool6) |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22458
diff
changeset
|
32 var bool7: bool = 0 || 1 && true |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 assert_equal(true, bool7) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
35 var lines =<< trim END |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 vim9script |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 def GetFlag(): bool |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
38 var flag: bool = 1 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 return flag |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 enddef |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
41 var flag: bool = GetFlag() |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 assert_equal(true, flag) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 flag = 0 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 assert_equal(false, flag) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 flag = 1 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 assert_equal(true, flag) |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22458
diff
changeset
|
47 flag = 1 || true |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 assert_equal(true, flag) |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22458
diff
changeset
|
49 flag = 1 && false |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 assert_equal(false, flag) |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23338
diff
changeset
|
51 |
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23338
diff
changeset
|
52 var cp: bool = &cp |
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23338
diff
changeset
|
53 var fen: bool = &l:fen |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
55 v9.CheckScriptSuccess(lines) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
56 v9.CheckDefAndScriptFailure(['var x: bool = 2'], 'E1012:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
57 v9.CheckDefAndScriptFailure(['var x: bool = -1'], 'E1012:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
58 v9.CheckDefAndScriptFailure(['var x: bool = [1]'], 'E1012:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
59 v9.CheckDefAndScriptFailure(['var x: bool = {}'], 'E1012:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
60 v9.CheckDefAndScriptFailure(['var x: bool = "x"'], 'E1012:') |
23707
6e8a4a30d94d
patch 8.2.2395: Vim9: error for wrong type may report wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
23679
diff
changeset
|
61 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
62 v9.CheckDefAndScriptFailure(['var x: bool = "x"', '', 'eval 0'], 'E1012:', 1) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
65 def Test_syntax() |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
66 var name = 234 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
67 var other: list<string> = ['asdf'] |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
70 def Test_assignment() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
71 v9.CheckDefFailure(['var x:string'], 'E1069:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
72 v9.CheckDefFailure(['var x:string = "x"'], 'E1069:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
73 v9.CheckDefFailure(['var a:string = "x"'], 'E1069:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
74 v9.CheckDefFailure(['var lambda = () => "lambda"'], 'E704:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
75 v9.CheckScriptFailure(['var x = "x"'], 'E1124:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 |
24154
6e8f49a4a193
patch 8.2.2618: Vim9: cannot use a normal list name to store function refs
Bram Moolenaar <Bram@vim.org>
parents:
24047
diff
changeset
|
77 # lower case name is OK for a list |
6e8f49a4a193
patch 8.2.2618: Vim9: cannot use a normal list name to store function refs
Bram Moolenaar <Bram@vim.org>
parents:
24047
diff
changeset
|
78 var lambdaLines =<< trim END |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
79 var lambdaList: list<func> = [g:Test_syntax] |
24154
6e8f49a4a193
patch 8.2.2618: Vim9: cannot use a normal list name to store function refs
Bram Moolenaar <Bram@vim.org>
parents:
24047
diff
changeset
|
80 lambdaList[0] = () => "lambda" |
6e8f49a4a193
patch 8.2.2618: Vim9: cannot use a normal list name to store function refs
Bram Moolenaar <Bram@vim.org>
parents:
24047
diff
changeset
|
81 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
82 v9.CheckDefAndScriptSuccess(lambdaLines) |
24154
6e8f49a4a193
patch 8.2.2618: Vim9: cannot use a normal list name to store function refs
Bram Moolenaar <Bram@vim.org>
parents:
24047
diff
changeset
|
83 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
84 var nr: number = 1234 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
85 v9.CheckDefFailure(['var nr: number = "asdf"'], 'E1012:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
86 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
87 var a: number = 6 #comment |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
88 assert_equal(6, a) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
89 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
90 if has('channel') |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
91 var chan1: channel |
22618
c2d8b596dd0f
patch 8.2.1857: Vim9: using job_status() on an unused var gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22610
diff
changeset
|
92 assert_equal('fail', ch_status(chan1)) |
c2d8b596dd0f
patch 8.2.1857: Vim9: using job_status() on an unused var gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22610
diff
changeset
|
93 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
94 var job1: job |
22618
c2d8b596dd0f
patch 8.2.1857: Vim9: using job_status() on an unused var gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22610
diff
changeset
|
95 assert_equal('fail', job_status(job1)) |
c2d8b596dd0f
patch 8.2.1857: Vim9: using job_status() on an unused var gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22610
diff
changeset
|
96 |
22582
a3df1fb28d44
patch 8.2.1839: Vim9: memory leaks reported in assign test
Bram Moolenaar <Bram@vim.org>
parents:
22545
diff
changeset
|
97 # calling job_start() is in test_vim9_fails.vim, it causes leak reports |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
98 endif |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
99 if has('float') |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
100 var float1: float = 3.4 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
101 endif |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
102 var Funky1: func |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
103 var Funky2: func = function('len') |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
104 var Party2: func = funcref('g:Test_syntax') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
105 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
106 g:newvar = 'new' #comment |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
107 assert_equal('new', g:newvar) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
108 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
109 assert_equal('yes', g:existing) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
110 g:existing = 'no' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
111 assert_equal('no', g:existing) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
112 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
113 v:char = 'abc' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
114 assert_equal('abc', v:char) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
115 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
116 $ENVVAR = 'foobar' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
117 assert_equal('foobar', $ENVVAR) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
118 $ENVVAR = '' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
119 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
120 var lines =<< trim END |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
121 vim9script |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
122 $ENVVAR = 'barfoo' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
123 assert_equal('barfoo', $ENVVAR) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
124 $ENVVAR = '' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
125 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
126 v9.CheckScriptSuccess(lines) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
127 |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
128 appendToMe ..= 'yyy' |
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
129 assert_equal('xxxyyy', appendToMe) |
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
130 addToMe += 222 |
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
131 assert_equal(333, addToMe) |
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
132 newVar = 'new' |
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
133 assert_equal('new', newVar) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
134 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
135 set ts=7 |
23422
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23338
diff
changeset
|
136 var ts: number = &ts |
bb0c53f4ef8b
patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents:
23338
diff
changeset
|
137 assert_equal(7, ts) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
138 &ts += 1 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
139 assert_equal(8, &ts) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
140 &ts -= 3 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
141 assert_equal(5, &ts) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
142 &ts *= 2 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
143 assert_equal(10, &ts) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
144 &ts /= 3 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
145 assert_equal(3, &ts) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
146 set ts=10 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
147 &ts %= 4 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
148 assert_equal(2, &ts) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
149 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
150 if has('float') |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
151 var f100: float = 100.0 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
152 f100 /= 5 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
153 assert_equal(20.0, f100) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
154 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
155 var f200: float = 200.0 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
156 f200 /= 5.0 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
157 assert_equal(40.0, f200) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
158 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
159 v9.CheckDefFailure(['var nr: number = 200', 'nr /= 5.0'], 'E1012:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
160 endif |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
161 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
162 lines =<< trim END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
163 &ts = 6 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
164 &ts += 3 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
165 assert_equal(9, &ts) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
166 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
167 &l:ts = 6 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
168 assert_equal(6, &ts) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
169 &l:ts += 2 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
170 assert_equal(8, &ts) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
171 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
172 &g:ts = 6 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
173 assert_equal(6, &g:ts) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
174 &g:ts += 2 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
175 assert_equal(8, &g:ts) |
23509
18f3dc6974af
patch 8.2.2297: Vim9: cannot set 'number' to a boolean value
Bram Moolenaar <Bram@vim.org>
parents:
23495
diff
changeset
|
176 |
18f3dc6974af
patch 8.2.2297: Vim9: cannot set 'number' to a boolean value
Bram Moolenaar <Bram@vim.org>
parents:
23495
diff
changeset
|
177 &number = true |
18f3dc6974af
patch 8.2.2297: Vim9: cannot set 'number' to a boolean value
Bram Moolenaar <Bram@vim.org>
parents:
23495
diff
changeset
|
178 assert_equal(true, &number) |
18f3dc6974af
patch 8.2.2297: Vim9: cannot set 'number' to a boolean value
Bram Moolenaar <Bram@vim.org>
parents:
23495
diff
changeset
|
179 &number = 0 |
18f3dc6974af
patch 8.2.2297: Vim9: cannot set 'number' to a boolean value
Bram Moolenaar <Bram@vim.org>
parents:
23495
diff
changeset
|
180 assert_equal(false, &number) |
18f3dc6974af
patch 8.2.2297: Vim9: cannot set 'number' to a boolean value
Bram Moolenaar <Bram@vim.org>
parents:
23495
diff
changeset
|
181 &number = 1 |
18f3dc6974af
patch 8.2.2297: Vim9: cannot set 'number' to a boolean value
Bram Moolenaar <Bram@vim.org>
parents:
23495
diff
changeset
|
182 assert_equal(true, &number) |
18f3dc6974af
patch 8.2.2297: Vim9: cannot set 'number' to a boolean value
Bram Moolenaar <Bram@vim.org>
parents:
23495
diff
changeset
|
183 &number = false |
18f3dc6974af
patch 8.2.2297: Vim9: cannot set 'number' to a boolean value
Bram Moolenaar <Bram@vim.org>
parents:
23495
diff
changeset
|
184 assert_equal(false, &number) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
185 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
186 v9.CheckDefAndScriptSuccess(lines) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
187 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
188 v9.CheckDefFailure(['¬ex += 3'], 'E113:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
189 v9.CheckDefFailure(['&ts ..= "xxx"'], 'E1019:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
190 v9.CheckDefFailure(['&ts = [7]'], 'E1012:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
191 v9.CheckDefExecFailure(['&ts = g:alist'], 'E1012: Type mismatch; expected number but got list<number>') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
192 v9.CheckDefFailure(['&ts = "xx"'], 'E1012:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
193 v9.CheckDefExecFailure(['&ts = g:astring'], 'E1012: Type mismatch; expected number but got string') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
194 v9.CheckDefFailure(['&path += 3'], 'E1012:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
195 v9.CheckDefExecFailure(['&bs = "asdf"'], 'E474:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
196 # test freeing ISN_STOREOPT |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
197 v9.CheckDefFailure(['&ts = 3', 'var asdf'], 'E1022:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
198 &ts = 8 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
199 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
200 lines =<< trim END |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
201 var save_TI = &t_TI |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
202 &t_TI = '' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
203 assert_equal('', &t_TI) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
204 &t_TI = 'xxx' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
205 assert_equal('xxx', &t_TI) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
206 &t_TI = save_TI |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
207 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
208 v9.CheckDefAndScriptSuccess(lines) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
209 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
210 v9.CheckDefFailure(['&t_TI = 123'], 'E1012:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
211 v9.CheckScriptFailure(['vim9script', '&t_TI = 123'], 'E928:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
212 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
213 v9.CheckDefFailure(['var s:var = 123'], 'E1101:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
214 v9.CheckDefFailure(['var s:var: number'], 'E1101:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
215 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
216 lines =<< trim END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
217 vim9script |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
218 def SomeFunc() |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
219 s:var = 123 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
220 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
221 defcompile |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
222 END |
27843
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
223 v9.CheckScriptFailure(lines, 'E1268:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
224 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
225 g:inc_counter += 1 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
226 assert_equal(2, g:inc_counter) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
227 |
25483
0160aff01c32
patch 8.2.3278: Vim9: error when adding 1 to float
Bram Moolenaar <Bram@vim.org>
parents:
25459
diff
changeset
|
228 if has('float') |
0160aff01c32
patch 8.2.3278: Vim9: error when adding 1 to float
Bram Moolenaar <Bram@vim.org>
parents:
25459
diff
changeset
|
229 var f: float |
0160aff01c32
patch 8.2.3278: Vim9: error when adding 1 to float
Bram Moolenaar <Bram@vim.org>
parents:
25459
diff
changeset
|
230 f += 1 |
0160aff01c32
patch 8.2.3278: Vim9: error when adding 1 to float
Bram Moolenaar <Bram@vim.org>
parents:
25459
diff
changeset
|
231 assert_equal(1.0, f) |
0160aff01c32
patch 8.2.3278: Vim9: error when adding 1 to float
Bram Moolenaar <Bram@vim.org>
parents:
25459
diff
changeset
|
232 endif |
0160aff01c32
patch 8.2.3278: Vim9: error when adding 1 to float
Bram Moolenaar <Bram@vim.org>
parents:
25459
diff
changeset
|
233 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
234 $SOME_ENV_VAR ..= 'more' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
235 assert_equal('somemore', $SOME_ENV_VAR) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
236 v9.CheckDefFailure(['$SOME_ENV_VAR += "more"'], 'E1051:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
237 v9.CheckDefFailure(['$SOME_ENV_VAR += 123'], 'E1012:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
238 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
239 v:errmsg = 'none' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
240 v:errmsg ..= 'again' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
241 assert_equal('noneagain', v:errmsg) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
242 v9.CheckDefFailure(['v:errmsg += "more"'], 'E1051:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
243 v9.CheckDefFailure(['v:errmsg += 123'], 'E1012:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
244 |
22582
a3df1fb28d44
patch 8.2.1839: Vim9: memory leaks reported in assign test
Bram Moolenaar <Bram@vim.org>
parents:
22545
diff
changeset
|
245 var text =<< trim END |
a3df1fb28d44
patch 8.2.1839: Vim9: memory leaks reported in assign test
Bram Moolenaar <Bram@vim.org>
parents:
22545
diff
changeset
|
246 some text |
a3df1fb28d44
patch 8.2.1839: Vim9: memory leaks reported in assign test
Bram Moolenaar <Bram@vim.org>
parents:
22545
diff
changeset
|
247 END |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
248 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
249 |
25519
f7db86111acd
patch 8.2.3296: Vim9: cannot add a number to a float
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
250 def Test_float_and_number() |
f7db86111acd
patch 8.2.3296: Vim9: cannot add a number to a float
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
251 if !has('float') |
f7db86111acd
patch 8.2.3296: Vim9: cannot add a number to a float
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
252 MissingFeature float |
f7db86111acd
patch 8.2.3296: Vim9: cannot add a number to a float
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
253 else |
f7db86111acd
patch 8.2.3296: Vim9: cannot add a number to a float
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
254 var lines =<< trim END |
f7db86111acd
patch 8.2.3296: Vim9: cannot add a number to a float
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
255 var f: float |
f7db86111acd
patch 8.2.3296: Vim9: cannot add a number to a float
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
256 f += 2 |
f7db86111acd
patch 8.2.3296: Vim9: cannot add a number to a float
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
257 f -= 1 |
f7db86111acd
patch 8.2.3296: Vim9: cannot add a number to a float
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
258 assert_equal(1.0, f) |
f7db86111acd
patch 8.2.3296: Vim9: cannot add a number to a float
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
259 ++f |
f7db86111acd
patch 8.2.3296: Vim9: cannot add a number to a float
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
260 --f |
f7db86111acd
patch 8.2.3296: Vim9: cannot add a number to a float
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
261 assert_equal(1.0, f) |
f7db86111acd
patch 8.2.3296: Vim9: cannot add a number to a float
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
262 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
263 v9.CheckDefAndScriptSuccess(lines) |
25519
f7db86111acd
patch 8.2.3296: Vim9: cannot add a number to a float
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
264 endif |
f7db86111acd
patch 8.2.3296: Vim9: cannot add a number to a float
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
265 enddef |
f7db86111acd
patch 8.2.3296: Vim9: cannot add a number to a float
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
266 |
25453
21b70bab366c
patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Bram Moolenaar <Bram@vim.org>
parents:
25405
diff
changeset
|
267 let g:someNumber = 43 |
21b70bab366c
patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Bram Moolenaar <Bram@vim.org>
parents:
25405
diff
changeset
|
268 |
21b70bab366c
patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Bram Moolenaar <Bram@vim.org>
parents:
25405
diff
changeset
|
269 def Test_assign_concat() |
21b70bab366c
patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Bram Moolenaar <Bram@vim.org>
parents:
25405
diff
changeset
|
270 var lines =<< trim END |
21b70bab366c
patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Bram Moolenaar <Bram@vim.org>
parents:
25405
diff
changeset
|
271 var s = '-' |
21b70bab366c
patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Bram Moolenaar <Bram@vim.org>
parents:
25405
diff
changeset
|
272 s ..= 99 |
21b70bab366c
patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Bram Moolenaar <Bram@vim.org>
parents:
25405
diff
changeset
|
273 s ..= true |
21b70bab366c
patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Bram Moolenaar <Bram@vim.org>
parents:
25405
diff
changeset
|
274 s ..= '-' |
21b70bab366c
patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Bram Moolenaar <Bram@vim.org>
parents:
25405
diff
changeset
|
275 s ..= v:null |
21b70bab366c
patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Bram Moolenaar <Bram@vim.org>
parents:
25405
diff
changeset
|
276 s ..= g:someNumber |
21b70bab366c
patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Bram Moolenaar <Bram@vim.org>
parents:
25405
diff
changeset
|
277 assert_equal('-99true-null43', s) |
21b70bab366c
patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Bram Moolenaar <Bram@vim.org>
parents:
25405
diff
changeset
|
278 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
279 v9.CheckDefAndScriptSuccess(lines) |
25453
21b70bab366c
patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Bram Moolenaar <Bram@vim.org>
parents:
25405
diff
changeset
|
280 |
21b70bab366c
patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Bram Moolenaar <Bram@vim.org>
parents:
25405
diff
changeset
|
281 lines =<< trim END |
21b70bab366c
patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Bram Moolenaar <Bram@vim.org>
parents:
25405
diff
changeset
|
282 var s = '-' |
21b70bab366c
patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Bram Moolenaar <Bram@vim.org>
parents:
25405
diff
changeset
|
283 s ..= [1, 2] |
21b70bab366c
patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Bram Moolenaar <Bram@vim.org>
parents:
25405
diff
changeset
|
284 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
285 v9.CheckDefAndScriptFailure(lines, ['E1105: Cannot convert list to string', 'E734: Wrong variable type for .='], 2) |
25453
21b70bab366c
patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Bram Moolenaar <Bram@vim.org>
parents:
25405
diff
changeset
|
286 lines =<< trim END |
21b70bab366c
patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Bram Moolenaar <Bram@vim.org>
parents:
25405
diff
changeset
|
287 var s = '-' |
21b70bab366c
patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Bram Moolenaar <Bram@vim.org>
parents:
25405
diff
changeset
|
288 s ..= {a: 2} |
21b70bab366c
patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Bram Moolenaar <Bram@vim.org>
parents:
25405
diff
changeset
|
289 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
290 v9.CheckDefAndScriptFailure(lines, ['E1105: Cannot convert dict to string', 'E734: Wrong variable type for .='], 2) |
28273
fff70771d4bb
patch 8.2.4662: no error for using out of range list index
Bram Moolenaar <Bram@vim.org>
parents:
28152
diff
changeset
|
291 |
fff70771d4bb
patch 8.2.4662: no error for using out of range list index
Bram Moolenaar <Bram@vim.org>
parents:
28152
diff
changeset
|
292 lines =<< trim END |
fff70771d4bb
patch 8.2.4662: no error for using out of range list index
Bram Moolenaar <Bram@vim.org>
parents:
28152
diff
changeset
|
293 var ls: list<string> = [] |
fff70771d4bb
patch 8.2.4662: no error for using out of range list index
Bram Moolenaar <Bram@vim.org>
parents:
28152
diff
changeset
|
294 ls[-1] ..= 'foo' |
fff70771d4bb
patch 8.2.4662: no error for using out of range list index
Bram Moolenaar <Bram@vim.org>
parents:
28152
diff
changeset
|
295 END |
fff70771d4bb
patch 8.2.4662: no error for using out of range list index
Bram Moolenaar <Bram@vim.org>
parents:
28152
diff
changeset
|
296 v9.CheckDefExecAndScriptFailure(lines, 'E684: list index out of range: -1', 2) |
25453
21b70bab366c
patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Bram Moolenaar <Bram@vim.org>
parents:
25405
diff
changeset
|
297 enddef |
21b70bab366c
patch 8.2.3263: Vim9: "..=" does not accept same types as the ".." operator
Bram Moolenaar <Bram@vim.org>
parents:
25405
diff
changeset
|
298 |
25032
123590c942b7
patch 8.2.3053: Vim9: cannot assign to @@ in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25022
diff
changeset
|
299 def Test_assign_register() |
123590c942b7
patch 8.2.3053: Vim9: cannot assign to @@ in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25022
diff
changeset
|
300 var lines =<< trim END |
123590c942b7
patch 8.2.3053: Vim9: cannot assign to @@ in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25022
diff
changeset
|
301 @c = 'areg' |
123590c942b7
patch 8.2.3053: Vim9: cannot assign to @@ in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25022
diff
changeset
|
302 @c ..= 'add' |
123590c942b7
patch 8.2.3053: Vim9: cannot assign to @@ in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25022
diff
changeset
|
303 assert_equal('aregadd', @c) |
123590c942b7
patch 8.2.3053: Vim9: cannot assign to @@ in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25022
diff
changeset
|
304 |
123590c942b7
patch 8.2.3053: Vim9: cannot assign to @@ in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25022
diff
changeset
|
305 @@ = 'some text' |
123590c942b7
patch 8.2.3053: Vim9: cannot assign to @@ in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25022
diff
changeset
|
306 assert_equal('some text', getreg('"')) |
123590c942b7
patch 8.2.3053: Vim9: cannot assign to @@ in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25022
diff
changeset
|
307 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
308 v9.CheckDefAndScriptSuccess(lines) |
25032
123590c942b7
patch 8.2.3053: Vim9: cannot assign to @@ in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25022
diff
changeset
|
309 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
310 v9.CheckDefFailure(['@a += "more"'], 'E1051:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
311 v9.CheckDefFailure(['@a += 123'], 'E1012:') |
25032
123590c942b7
patch 8.2.3053: Vim9: cannot assign to @@ in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25022
diff
changeset
|
312 enddef |
123590c942b7
patch 8.2.3053: Vim9: cannot assign to @@ in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25022
diff
changeset
|
313 |
24717
bf8feac8a89a
patch 8.2.2897: Vim9: can use reserved words at the script level
Bram Moolenaar <Bram@vim.org>
parents:
24555
diff
changeset
|
314 def Test_reserved_name() |
28002
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
315 var more_names = ['null_job', 'null_channel'] |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
316 if !has('job') |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
317 more_names = [] |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
318 endif |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
319 |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
320 for name in ['true', |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
321 'false', |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
322 'null', |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
323 'null_blob', |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
324 'null_dict', |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
325 'null_function', |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
326 'null_list', |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
327 'null_partial', |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
328 'null_string', |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
329 ] + more_names |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
330 v9.CheckDefExecAndScriptFailure(['var ' .. name .. ' = 0'], 'E1034:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
331 v9.CheckDefExecAndScriptFailure(['var ' .. name .. ': bool'], 'E1034:') |
24717
bf8feac8a89a
patch 8.2.2897: Vim9: can use reserved words at the script level
Bram Moolenaar <Bram@vim.org>
parents:
24555
diff
changeset
|
332 endfor |
bf8feac8a89a
patch 8.2.2897: Vim9: can use reserved words at the script level
Bram Moolenaar <Bram@vim.org>
parents:
24555
diff
changeset
|
333 enddef |
bf8feac8a89a
patch 8.2.2897: Vim9: can use reserved words at the script level
Bram Moolenaar <Bram@vim.org>
parents:
24555
diff
changeset
|
334 |
28002
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
335 def Test_null_values() |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
336 var lines =<< trim END |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
337 var b: blob = null_blob |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
338 var dn: dict<number> = null_dict |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
339 var ds: dict<string> = null_dict |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
340 var ln: list<number> = null_list |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
341 var ls: list<string> = null_list |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
342 var Ff: func(string): string = null_function |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
343 var Fp: func(number): number = null_partial |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
344 var s: string = null_string |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
345 if has('job') |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
346 var j: job = null_job |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
347 var c: channel = null_channel |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
348 endif |
28017
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
349 |
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
350 var d: dict<func> = {a: function('tr'), b: null_function} |
28059
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28017
diff
changeset
|
351 |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28017
diff
changeset
|
352 var bl: list<blob> = [0z12, null_blob] |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28017
diff
changeset
|
353 var dnl: list<dict<number>> = [{a: 1}, null_dict] |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28017
diff
changeset
|
354 var dsl: list<dict<string>> = [{a: 'x'}, null_dict] |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28017
diff
changeset
|
355 var lnl: list<list<number>> = [[1], null_list] |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28017
diff
changeset
|
356 var lsl: list<list<string>> = [['x'], null_list] |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28017
diff
changeset
|
357 def Len(v: string): number |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28017
diff
changeset
|
358 return len(v) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28017
diff
changeset
|
359 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28017
diff
changeset
|
360 var Ffl: list<func(string): number> = [Len, null_function] |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28017
diff
changeset
|
361 var Fpl: list<func(string): number> = [Len, null_partial] |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28017
diff
changeset
|
362 var sl: list<string> = ['x', null_string] |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28017
diff
changeset
|
363 if has('job') |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28017
diff
changeset
|
364 var jl: list<job> = [null_job] |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28017
diff
changeset
|
365 var cl: list<channel> = [null_channel] |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28017
diff
changeset
|
366 endif |
28002
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
367 END |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
368 v9.CheckDefAndScriptSuccess(lines) |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
369 enddef |
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27968
diff
changeset
|
370 |
28017
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
371 def Test_keep_type_after_assigning_null() |
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
372 var lines =<< trim END |
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
373 var b: blob |
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
374 b = null_blob |
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
375 b = 'text' |
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
376 END |
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
377 v9.CheckDefExecAndScriptFailure(lines, 'E1012: Type mismatch; expected blob but got string') |
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
378 |
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
379 lines =<< trim END |
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
380 var l: list<number> |
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
381 l = null_list |
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
382 l = ['text'] |
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
383 END |
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
384 v9.CheckDefExecAndScriptFailure(lines, 'E1012: Type mismatch; expected list<number> but got list<string>') |
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
385 |
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
386 lines =<< trim END |
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
387 var d: dict<string> |
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
388 d = null_dict |
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
389 d = {a: 1, b: 2} |
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
390 END |
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
391 v9.CheckDefExecAndScriptFailure(lines, 'E1012: Type mismatch; expected dict<string> but got dict<number>') |
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
392 enddef |
21cc8371e45e
patch 8.2.4533: Vim9: no test that after assigning null type is still checked
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
393 |
24462
7c4f50c02e18
patch 8.2.2771: Vim9: assignment not recognized if declaration was skipped
Bram Moolenaar <Bram@vim.org>
parents:
24426
diff
changeset
|
394 def Test_skipped_assignment() |
7c4f50c02e18
patch 8.2.2771: Vim9: assignment not recognized if declaration was skipped
Bram Moolenaar <Bram@vim.org>
parents:
24426
diff
changeset
|
395 var lines =<< trim END |
7c4f50c02e18
patch 8.2.2771: Vim9: assignment not recognized if declaration was skipped
Bram Moolenaar <Bram@vim.org>
parents:
24426
diff
changeset
|
396 for x in [] |
7c4f50c02e18
patch 8.2.2771: Vim9: assignment not recognized if declaration was skipped
Bram Moolenaar <Bram@vim.org>
parents:
24426
diff
changeset
|
397 var i: number = 1 |
7c4f50c02e18
patch 8.2.2771: Vim9: assignment not recognized if declaration was skipped
Bram Moolenaar <Bram@vim.org>
parents:
24426
diff
changeset
|
398 while false |
7c4f50c02e18
patch 8.2.2771: Vim9: assignment not recognized if declaration was skipped
Bram Moolenaar <Bram@vim.org>
parents:
24426
diff
changeset
|
399 i += 1 |
7c4f50c02e18
patch 8.2.2771: Vim9: assignment not recognized if declaration was skipped
Bram Moolenaar <Bram@vim.org>
parents:
24426
diff
changeset
|
400 endwhile |
7c4f50c02e18
patch 8.2.2771: Vim9: assignment not recognized if declaration was skipped
Bram Moolenaar <Bram@vim.org>
parents:
24426
diff
changeset
|
401 endfor |
7c4f50c02e18
patch 8.2.2771: Vim9: assignment not recognized if declaration was skipped
Bram Moolenaar <Bram@vim.org>
parents:
24426
diff
changeset
|
402 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
403 v9.CheckDefAndScriptSuccess(lines) |
24462
7c4f50c02e18
patch 8.2.2771: Vim9: assignment not recognized if declaration was skipped
Bram Moolenaar <Bram@vim.org>
parents:
24426
diff
changeset
|
404 enddef |
7c4f50c02e18
patch 8.2.2771: Vim9: assignment not recognized if declaration was skipped
Bram Moolenaar <Bram@vim.org>
parents:
24426
diff
changeset
|
405 |
26302
7351926fbe9e
patch 8.2.3682: Vim9: assigning to a script variable drops the type
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
406 def Test_assign_keep_type() |
7351926fbe9e
patch 8.2.3682: Vim9: assigning to a script variable drops the type
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
407 var lines =<< trim END |
7351926fbe9e
patch 8.2.3682: Vim9: assigning to a script variable drops the type
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
408 vim9script |
7351926fbe9e
patch 8.2.3682: Vim9: assigning to a script variable drops the type
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
409 var l: list<number> = [123] |
7351926fbe9e
patch 8.2.3682: Vim9: assigning to a script variable drops the type
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
410 l = [123] |
7351926fbe9e
patch 8.2.3682: Vim9: assigning to a script variable drops the type
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
411 l->add('string') |
7351926fbe9e
patch 8.2.3682: Vim9: assigning to a script variable drops the type
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
412 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
413 v9.CheckScriptFailure(lines, 'E1012:', 4) |
26302
7351926fbe9e
patch 8.2.3682: Vim9: assigning to a script variable drops the type
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
414 enddef |
7351926fbe9e
patch 8.2.3682: Vim9: assigning to a script variable drops the type
Bram Moolenaar <Bram@vim.org>
parents:
25776
diff
changeset
|
415 |
23122
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
416 def Test_assign_unpack() |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
417 var lines =<< trim END |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
418 var v1: number |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
419 var v2: number |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
420 [v1, v2] = [1, 2] |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
421 assert_equal(1, v1) |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
422 assert_equal(2, v2) |
24426
78343859f42d
patch 8.2.2753: Vim9: cannot ignore an item in assignment unpack
Bram Moolenaar <Bram@vim.org>
parents:
24377
diff
changeset
|
423 |
78343859f42d
patch 8.2.2753: Vim9: cannot ignore an item in assignment unpack
Bram Moolenaar <Bram@vim.org>
parents:
24377
diff
changeset
|
424 [v1, _, v2, _] = [1, 99, 2, 77] |
78343859f42d
patch 8.2.2753: Vim9: cannot ignore an item in assignment unpack
Bram Moolenaar <Bram@vim.org>
parents:
24377
diff
changeset
|
425 assert_equal(1, v1) |
78343859f42d
patch 8.2.2753: Vim9: cannot ignore an item in assignment unpack
Bram Moolenaar <Bram@vim.org>
parents:
24377
diff
changeset
|
426 assert_equal(2, v2) |
78343859f42d
patch 8.2.2753: Vim9: cannot ignore an item in assignment unpack
Bram Moolenaar <Bram@vim.org>
parents:
24377
diff
changeset
|
427 |
78343859f42d
patch 8.2.2753: Vim9: cannot ignore an item in assignment unpack
Bram Moolenaar <Bram@vim.org>
parents:
24377
diff
changeset
|
428 [v1, v2; _] = [1, 2, 3, 4, 5] |
78343859f42d
patch 8.2.2753: Vim9: cannot ignore an item in assignment unpack
Bram Moolenaar <Bram@vim.org>
parents:
24377
diff
changeset
|
429 assert_equal(1, v1) |
78343859f42d
patch 8.2.2753: Vim9: cannot ignore an item in assignment unpack
Bram Moolenaar <Bram@vim.org>
parents:
24377
diff
changeset
|
430 assert_equal(2, v2) |
24984
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
431 |
27716
4097434c7c67
patch 8.2.4384: Vim9: error message not tested, some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
27669
diff
changeset
|
432 var _x: number |
4097434c7c67
patch 8.2.4384: Vim9: error message not tested, some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
27669
diff
changeset
|
433 [_x, v2] = [6, 7] |
4097434c7c67
patch 8.2.4384: Vim9: error message not tested, some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
27669
diff
changeset
|
434 assert_equal(6, _x) |
4097434c7c67
patch 8.2.4384: Vim9: error message not tested, some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
27669
diff
changeset
|
435 assert_equal(7, v2) |
4097434c7c67
patch 8.2.4384: Vim9: error message not tested, some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
27669
diff
changeset
|
436 |
25034
8d660d1cca8d
patch 8.2.3054: Vim9: unpack assignment using "_" after semicolon fails
Bram Moolenaar <Bram@vim.org>
parents:
25032
diff
changeset
|
437 var reslist = [] |
8d660d1cca8d
patch 8.2.3054: Vim9: unpack assignment using "_" after semicolon fails
Bram Moolenaar <Bram@vim.org>
parents:
25032
diff
changeset
|
438 for text in ['aaa {bbb} ccc', 'ddd {eee} fff'] |
8d660d1cca8d
patch 8.2.3054: Vim9: unpack assignment using "_" after semicolon fails
Bram Moolenaar <Bram@vim.org>
parents:
25032
diff
changeset
|
439 var before: string |
8d660d1cca8d
patch 8.2.3054: Vim9: unpack assignment using "_" after semicolon fails
Bram Moolenaar <Bram@vim.org>
parents:
25032
diff
changeset
|
440 var middle: string |
8d660d1cca8d
patch 8.2.3054: Vim9: unpack assignment using "_" after semicolon fails
Bram Moolenaar <Bram@vim.org>
parents:
25032
diff
changeset
|
441 var after: string |
8d660d1cca8d
patch 8.2.3054: Vim9: unpack assignment using "_" after semicolon fails
Bram Moolenaar <Bram@vim.org>
parents:
25032
diff
changeset
|
442 [_, before, middle, after; _] = text->matchlist('\(.\{-\}\){\(.\{-\}\)}\(.*\)') |
8d660d1cca8d
patch 8.2.3054: Vim9: unpack assignment using "_" after semicolon fails
Bram Moolenaar <Bram@vim.org>
parents:
25032
diff
changeset
|
443 reslist->add(before)->add(middle)->add(after) |
8d660d1cca8d
patch 8.2.3054: Vim9: unpack assignment using "_" after semicolon fails
Bram Moolenaar <Bram@vim.org>
parents:
25032
diff
changeset
|
444 endfor |
8d660d1cca8d
patch 8.2.3054: Vim9: unpack assignment using "_" after semicolon fails
Bram Moolenaar <Bram@vim.org>
parents:
25032
diff
changeset
|
445 assert_equal(['aaa ', 'bbb', ' ccc', 'ddd ', 'eee', ' fff'], reslist) |
8d660d1cca8d
patch 8.2.3054: Vim9: unpack assignment using "_" after semicolon fails
Bram Moolenaar <Bram@vim.org>
parents:
25032
diff
changeset
|
446 |
24984
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
447 var a = 1 |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
448 var b = 3 |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
449 [a, b] += [2, 4] |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
450 assert_equal(3, a) |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
451 assert_equal(7, b) |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
452 |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
453 [a, b] -= [1, 2] |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
454 assert_equal(2, a) |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
455 assert_equal(5, b) |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
456 |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
457 [a, b] *= [3, 2] |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
458 assert_equal(6, a) |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
459 assert_equal(10, b) |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
460 |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
461 [a, b] /= [2, 4] |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
462 assert_equal(3, a) |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
463 assert_equal(2, b) |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
464 |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
465 [a, b] = [17, 15] |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
466 [a, b] %= [5, 3] |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
467 assert_equal(2, a) |
71b1e2ef0069
patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
24956
diff
changeset
|
468 assert_equal(0, b) |
23122
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
469 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
470 v9.CheckDefAndScriptSuccess(lines) |
23122
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
471 |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
472 lines =<< trim END |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
473 var v1: number |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
474 var v2: number |
26372
f5727e2603f0
patch 8.2.3717: Vim9: error for constant list size is only given at runtime
Bram Moolenaar <Bram@vim.org>
parents:
26346
diff
changeset
|
475 [v1, v2] = [1, 2, 3] |
f5727e2603f0
patch 8.2.3717: Vim9: error for constant list size is only given at runtime
Bram Moolenaar <Bram@vim.org>
parents:
26346
diff
changeset
|
476 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
477 v9.CheckDefFailure(lines, 'E1093: Expected 2 items but got 3', 3) |
26372
f5727e2603f0
patch 8.2.3717: Vim9: error for constant list size is only given at runtime
Bram Moolenaar <Bram@vim.org>
parents:
26346
diff
changeset
|
478 |
f5727e2603f0
patch 8.2.3717: Vim9: error for constant list size is only given at runtime
Bram Moolenaar <Bram@vim.org>
parents:
26346
diff
changeset
|
479 lines =<< trim END |
f5727e2603f0
patch 8.2.3717: Vim9: error for constant list size is only given at runtime
Bram Moolenaar <Bram@vim.org>
parents:
26346
diff
changeset
|
480 var v1: number |
f5727e2603f0
patch 8.2.3717: Vim9: error for constant list size is only given at runtime
Bram Moolenaar <Bram@vim.org>
parents:
26346
diff
changeset
|
481 var v2: number |
f5727e2603f0
patch 8.2.3717: Vim9: error for constant list size is only given at runtime
Bram Moolenaar <Bram@vim.org>
parents:
26346
diff
changeset
|
482 [v1, v2] = [1] |
f5727e2603f0
patch 8.2.3717: Vim9: error for constant list size is only given at runtime
Bram Moolenaar <Bram@vim.org>
parents:
26346
diff
changeset
|
483 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
484 v9.CheckDefFailure(lines, 'E1093: Expected 2 items but got 1', 3) |
26372
f5727e2603f0
patch 8.2.3717: Vim9: error for constant list size is only given at runtime
Bram Moolenaar <Bram@vim.org>
parents:
26346
diff
changeset
|
485 |
f5727e2603f0
patch 8.2.3717: Vim9: error for constant list size is only given at runtime
Bram Moolenaar <Bram@vim.org>
parents:
26346
diff
changeset
|
486 lines =<< trim END |
f5727e2603f0
patch 8.2.3717: Vim9: error for constant list size is only given at runtime
Bram Moolenaar <Bram@vim.org>
parents:
26346
diff
changeset
|
487 var v1: number |
f5727e2603f0
patch 8.2.3717: Vim9: error for constant list size is only given at runtime
Bram Moolenaar <Bram@vim.org>
parents:
26346
diff
changeset
|
488 var v2: number |
f5727e2603f0
patch 8.2.3717: Vim9: error for constant list size is only given at runtime
Bram Moolenaar <Bram@vim.org>
parents:
26346
diff
changeset
|
489 [v1, v2; _] = [1] |
f5727e2603f0
patch 8.2.3717: Vim9: error for constant list size is only given at runtime
Bram Moolenaar <Bram@vim.org>
parents:
26346
diff
changeset
|
490 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
491 v9.CheckDefFailure(lines, 'E1093: Expected 2 items but got 1', 3) |
26372
f5727e2603f0
patch 8.2.3717: Vim9: error for constant list size is only given at runtime
Bram Moolenaar <Bram@vim.org>
parents:
26346
diff
changeset
|
492 |
f5727e2603f0
patch 8.2.3717: Vim9: error for constant list size is only given at runtime
Bram Moolenaar <Bram@vim.org>
parents:
26346
diff
changeset
|
493 lines =<< trim END |
f5727e2603f0
patch 8.2.3717: Vim9: error for constant list size is only given at runtime
Bram Moolenaar <Bram@vim.org>
parents:
26346
diff
changeset
|
494 var v1: number |
f5727e2603f0
patch 8.2.3717: Vim9: error for constant list size is only given at runtime
Bram Moolenaar <Bram@vim.org>
parents:
26346
diff
changeset
|
495 var v2: number |
23122
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
496 [v1, v2] = |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
497 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
498 v9.CheckDefFailure(lines, 'E1097:', 5) |
23122
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
499 |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
500 lines =<< trim END |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
501 var v1: number |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
502 var v2: number |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
503 [v1, v2] = xxx |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
504 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
505 v9.CheckDefFailure(lines, 'E1001:', 3) |
23122
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
506 |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
507 lines =<< trim END |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
508 var v1: number |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
509 var v2: number |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
510 [v1, v2] = popup_clear() |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
511 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
512 v9.CheckDefFailure(lines, 'E1031:', 3) |
23122
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
513 |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
514 lines =<< trim END |
23450
a8e7acf71fa4
patch 8.2.2268: Vim9: list unpack seen as declaration
Bram Moolenaar <Bram@vim.org>
parents:
23448
diff
changeset
|
515 [v1, v2] = [1, 2] |
a8e7acf71fa4
patch 8.2.2268: Vim9: list unpack seen as declaration
Bram Moolenaar <Bram@vim.org>
parents:
23448
diff
changeset
|
516 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
517 v9.CheckDefFailure(lines, 'E1089', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
518 v9.CheckScriptFailure(['vim9script'] + lines, 'E1089', 2) |
23450
a8e7acf71fa4
patch 8.2.2268: Vim9: list unpack seen as declaration
Bram Moolenaar <Bram@vim.org>
parents:
23448
diff
changeset
|
519 |
a8e7acf71fa4
patch 8.2.2268: Vim9: list unpack seen as declaration
Bram Moolenaar <Bram@vim.org>
parents:
23448
diff
changeset
|
520 lines =<< trim END |
23122
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
521 var v1: number |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
522 var v2: number |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
523 [v1, v2] = '' |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
524 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
525 v9.CheckDefFailure(lines, 'E1012: Type mismatch; expected list<any> but got string', 3) |
23917
4b417b776b95
patch 8.2.2501: not always clear where an error is reported
Bram Moolenaar <Bram@vim.org>
parents:
23707
diff
changeset
|
526 |
4b417b776b95
patch 8.2.2501: not always clear where an error is reported
Bram Moolenaar <Bram@vim.org>
parents:
23707
diff
changeset
|
527 lines =<< trim END |
4b417b776b95
patch 8.2.2501: not always clear where an error is reported
Bram Moolenaar <Bram@vim.org>
parents:
23707
diff
changeset
|
528 g:values = [false, 0] |
4b417b776b95
patch 8.2.2501: not always clear where an error is reported
Bram Moolenaar <Bram@vim.org>
parents:
23707
diff
changeset
|
529 var x: bool |
4b417b776b95
patch 8.2.2501: not always clear where an error is reported
Bram Moolenaar <Bram@vim.org>
parents:
23707
diff
changeset
|
530 var y: string |
4b417b776b95
patch 8.2.2501: not always clear where an error is reported
Bram Moolenaar <Bram@vim.org>
parents:
23707
diff
changeset
|
531 [x, y] = g:values |
4b417b776b95
patch 8.2.2501: not always clear where an error is reported
Bram Moolenaar <Bram@vim.org>
parents:
23707
diff
changeset
|
532 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
533 v9.CheckDefExecAndScriptFailure(lines, 'E1163: Variable 2: type mismatch, expected string but got number') |
25547
ec4df0b982da
patch 8.2.3310: Vim9: unpack assignment does not mention source of type error
Bram Moolenaar <Bram@vim.org>
parents:
25519
diff
changeset
|
534 |
ec4df0b982da
patch 8.2.3310: Vim9: unpack assignment does not mention source of type error
Bram Moolenaar <Bram@vim.org>
parents:
25519
diff
changeset
|
535 lines =<< trim END |
ec4df0b982da
patch 8.2.3310: Vim9: unpack assignment does not mention source of type error
Bram Moolenaar <Bram@vim.org>
parents:
25519
diff
changeset
|
536 var x: number |
ec4df0b982da
patch 8.2.3310: Vim9: unpack assignment does not mention source of type error
Bram Moolenaar <Bram@vim.org>
parents:
25519
diff
changeset
|
537 var y: number |
ec4df0b982da
patch 8.2.3310: Vim9: unpack assignment does not mention source of type error
Bram Moolenaar <Bram@vim.org>
parents:
25519
diff
changeset
|
538 var z: string |
ec4df0b982da
patch 8.2.3310: Vim9: unpack assignment does not mention source of type error
Bram Moolenaar <Bram@vim.org>
parents:
25519
diff
changeset
|
539 [x, y, z] = [1, 2, 3] |
ec4df0b982da
patch 8.2.3310: Vim9: unpack assignment does not mention source of type error
Bram Moolenaar <Bram@vim.org>
parents:
25519
diff
changeset
|
540 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
541 v9.CheckDefAndScriptFailure(lines, 'E1163: Variable 3: type mismatch, expected string but got number') |
25547
ec4df0b982da
patch 8.2.3310: Vim9: unpack assignment does not mention source of type error
Bram Moolenaar <Bram@vim.org>
parents:
25519
diff
changeset
|
542 |
ec4df0b982da
patch 8.2.3310: Vim9: unpack assignment does not mention source of type error
Bram Moolenaar <Bram@vim.org>
parents:
25519
diff
changeset
|
543 lines =<< trim END |
ec4df0b982da
patch 8.2.3310: Vim9: unpack assignment does not mention source of type error
Bram Moolenaar <Bram@vim.org>
parents:
25519
diff
changeset
|
544 var x: number |
ec4df0b982da
patch 8.2.3310: Vim9: unpack assignment does not mention source of type error
Bram Moolenaar <Bram@vim.org>
parents:
25519
diff
changeset
|
545 var y: string |
ec4df0b982da
patch 8.2.3310: Vim9: unpack assignment does not mention source of type error
Bram Moolenaar <Bram@vim.org>
parents:
25519
diff
changeset
|
546 var z: string |
ec4df0b982da
patch 8.2.3310: Vim9: unpack assignment does not mention source of type error
Bram Moolenaar <Bram@vim.org>
parents:
25519
diff
changeset
|
547 [x, y, z] = [1, '2', 3] |
ec4df0b982da
patch 8.2.3310: Vim9: unpack assignment does not mention source of type error
Bram Moolenaar <Bram@vim.org>
parents:
25519
diff
changeset
|
548 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
549 v9.CheckDefExecAndScriptFailure(lines, 'E1163: Variable 3: type mismatch, expected string but got number') |
23122
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
550 enddef |
60a0221beab0
patch 8.2.2107: Vim9: some errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
551 |
23070
6a70803f4cbe
patch 8.2.2081: Vim9: cannot handle a linebreak after "=" in assignment
Bram Moolenaar <Bram@vim.org>
parents:
23052
diff
changeset
|
552 def Test_assign_linebreak() |
6a70803f4cbe
patch 8.2.2081: Vim9: cannot handle a linebreak after "=" in assignment
Bram Moolenaar <Bram@vim.org>
parents:
23052
diff
changeset
|
553 var nr: number |
6a70803f4cbe
patch 8.2.2081: Vim9: cannot handle a linebreak after "=" in assignment
Bram Moolenaar <Bram@vim.org>
parents:
23052
diff
changeset
|
554 nr = |
6a70803f4cbe
patch 8.2.2081: Vim9: cannot handle a linebreak after "=" in assignment
Bram Moolenaar <Bram@vim.org>
parents:
23052
diff
changeset
|
555 123 |
6a70803f4cbe
patch 8.2.2081: Vim9: cannot handle a linebreak after "=" in assignment
Bram Moolenaar <Bram@vim.org>
parents:
23052
diff
changeset
|
556 assert_equal(123, nr) |
6a70803f4cbe
patch 8.2.2081: Vim9: cannot handle a linebreak after "=" in assignment
Bram Moolenaar <Bram@vim.org>
parents:
23052
diff
changeset
|
557 |
6a70803f4cbe
patch 8.2.2081: Vim9: cannot handle a linebreak after "=" in assignment
Bram Moolenaar <Bram@vim.org>
parents:
23052
diff
changeset
|
558 var n2: number |
6a70803f4cbe
patch 8.2.2081: Vim9: cannot handle a linebreak after "=" in assignment
Bram Moolenaar <Bram@vim.org>
parents:
23052
diff
changeset
|
559 [nr, n2] = |
6a70803f4cbe
patch 8.2.2081: Vim9: cannot handle a linebreak after "=" in assignment
Bram Moolenaar <Bram@vim.org>
parents:
23052
diff
changeset
|
560 [12, 34] |
6a70803f4cbe
patch 8.2.2081: Vim9: cannot handle a linebreak after "=" in assignment
Bram Moolenaar <Bram@vim.org>
parents:
23052
diff
changeset
|
561 assert_equal(12, nr) |
6a70803f4cbe
patch 8.2.2081: Vim9: cannot handle a linebreak after "=" in assignment
Bram Moolenaar <Bram@vim.org>
parents:
23052
diff
changeset
|
562 assert_equal(34, n2) |
6a70803f4cbe
patch 8.2.2081: Vim9: cannot handle a linebreak after "=" in assignment
Bram Moolenaar <Bram@vim.org>
parents:
23052
diff
changeset
|
563 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
564 v9.CheckDefFailure(["var x = #"], 'E1097:', 3) |
24329
cd9f77409393
patch 8.2.2705: Vim9: misleading reported line number for wrong type
Bram Moolenaar <Bram@vim.org>
parents:
24325
diff
changeset
|
565 |
cd9f77409393
patch 8.2.2705: Vim9: misleading reported line number for wrong type
Bram Moolenaar <Bram@vim.org>
parents:
24325
diff
changeset
|
566 var lines =<< trim END |
cd9f77409393
patch 8.2.2705: Vim9: misleading reported line number for wrong type
Bram Moolenaar <Bram@vim.org>
parents:
24325
diff
changeset
|
567 var x: list<string> = ['a'] |
cd9f77409393
patch 8.2.2705: Vim9: misleading reported line number for wrong type
Bram Moolenaar <Bram@vim.org>
parents:
24325
diff
changeset
|
568 var y: list<number> = x |
cd9f77409393
patch 8.2.2705: Vim9: misleading reported line number for wrong type
Bram Moolenaar <Bram@vim.org>
parents:
24325
diff
changeset
|
569 ->copy() |
cd9f77409393
patch 8.2.2705: Vim9: misleading reported line number for wrong type
Bram Moolenaar <Bram@vim.org>
parents:
24325
diff
changeset
|
570 ->copy() |
cd9f77409393
patch 8.2.2705: Vim9: misleading reported line number for wrong type
Bram Moolenaar <Bram@vim.org>
parents:
24325
diff
changeset
|
571 END |
27517
f00a7a2bee21
patch 8.2.4286: Vim9: strict type checking after copy() and deepcopy()
Bram Moolenaar <Bram@vim.org>
parents:
27464
diff
changeset
|
572 v9.CheckDefExecFailure(lines, 'E1012:', 4) |
25139
7fa520b85244
patch 8.2.3106: Vim9: confusing line number reported for error
Bram Moolenaar <Bram@vim.org>
parents:
25137
diff
changeset
|
573 |
7fa520b85244
patch 8.2.3106: Vim9: confusing line number reported for error
Bram Moolenaar <Bram@vim.org>
parents:
25137
diff
changeset
|
574 lines =<< trim END |
7fa520b85244
patch 8.2.3106: Vim9: confusing line number reported for error
Bram Moolenaar <Bram@vim.org>
parents:
25137
diff
changeset
|
575 var x: any |
7fa520b85244
patch 8.2.3106: Vim9: confusing line number reported for error
Bram Moolenaar <Bram@vim.org>
parents:
25137
diff
changeset
|
576 x.key = 1 |
7fa520b85244
patch 8.2.3106: Vim9: confusing line number reported for error
Bram Moolenaar <Bram@vim.org>
parents:
25137
diff
changeset
|
577 + 2 |
7fa520b85244
patch 8.2.3106: Vim9: confusing line number reported for error
Bram Moolenaar <Bram@vim.org>
parents:
25137
diff
changeset
|
578 + 3 |
7fa520b85244
patch 8.2.3106: Vim9: confusing line number reported for error
Bram Moolenaar <Bram@vim.org>
parents:
25137
diff
changeset
|
579 + 4 |
7fa520b85244
patch 8.2.3106: Vim9: confusing line number reported for error
Bram Moolenaar <Bram@vim.org>
parents:
25137
diff
changeset
|
580 + 5 |
7fa520b85244
patch 8.2.3106: Vim9: confusing line number reported for error
Bram Moolenaar <Bram@vim.org>
parents:
25137
diff
changeset
|
581 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
582 v9.CheckDefExecAndScriptFailure(lines, ['E1148:', 'E1203:'], 2) |
23070
6a70803f4cbe
patch 8.2.2081: Vim9: cannot handle a linebreak after "=" in assignment
Bram Moolenaar <Bram@vim.org>
parents:
23052
diff
changeset
|
583 enddef |
6a70803f4cbe
patch 8.2.2081: Vim9: cannot handle a linebreak after "=" in assignment
Bram Moolenaar <Bram@vim.org>
parents:
23052
diff
changeset
|
584 |
23033
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
585 def Test_assign_index() |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
586 # list of list |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
587 var l1: list<number> |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
588 l1[0] = 123 |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
589 assert_equal([123], l1) |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
590 |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
591 var l2: list<list<number>> |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
592 l2[0] = [] |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
593 l2[0][0] = 123 |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
594 assert_equal([[123]], l2) |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
595 |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
596 var l3: list<list<list<number>>> |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
597 l3[0] = [] |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
598 l3[0][0] = [] |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
599 l3[0][0][0] = 123 |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
600 assert_equal([[[123]]], l3) |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
601 |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
602 var lines =<< trim END |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
603 var l3: list<list<number>> |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
604 l3[0] = [] |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
605 l3[0][0] = [] |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
606 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
607 v9.CheckDefFailure(lines, 'E1012: Type mismatch; expected number but got list<unknown>', 3) |
23033
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
608 |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
609 # dict of dict |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
610 var d1: dict<number> |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
611 d1.one = 1 |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
612 assert_equal({one: 1}, d1) |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
613 |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
614 var d2: dict<dict<number>> |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
615 d2.one = {} |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
616 d2.one.two = 123 |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
617 assert_equal({one: {two: 123}}, d2) |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
618 |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
619 var d3: dict<dict<dict<number>>> |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
620 d3.one = {} |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
621 d3.one.two = {} |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
622 d3.one.two.three = 123 |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
623 assert_equal({one: {two: {three: 123}}}, d3) |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
624 |
27762
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
625 # blob |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
626 var bl: blob = 0z11223344 |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
627 bl[0] = 0x77 |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
628 assert_equal(0z77223344, bl) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
629 bl[-2] = 0x66 |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
630 assert_equal(0z77226644, bl) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
631 |
27918
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
632 lines =<< trim END |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
633 g:val = '22' |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
634 var bl = 0z11 |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
635 bl[1] = g:val |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
636 END |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
637 v9.CheckDefExecAndScriptFailure(lines, 'E1030: Using a String as a Number: "22"') |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
638 |
25459
9adaa0c056c7
patch 8.2.3266: Vim9: assignment with two indexes may check next line
Bram Moolenaar <Bram@vim.org>
parents:
25453
diff
changeset
|
639 # should not read the next line when generating "a.b" |
9adaa0c056c7
patch 8.2.3266: Vim9: assignment with two indexes may check next line
Bram Moolenaar <Bram@vim.org>
parents:
25453
diff
changeset
|
640 var a = {} |
9adaa0c056c7
patch 8.2.3266: Vim9: assignment with two indexes may check next line
Bram Moolenaar <Bram@vim.org>
parents:
25453
diff
changeset
|
641 a.b = {} |
9adaa0c056c7
patch 8.2.3266: Vim9: assignment with two indexes may check next line
Bram Moolenaar <Bram@vim.org>
parents:
25453
diff
changeset
|
642 a.b.c = {} |
9adaa0c056c7
patch 8.2.3266: Vim9: assignment with two indexes may check next line
Bram Moolenaar <Bram@vim.org>
parents:
25453
diff
changeset
|
643 ->copy() |
9adaa0c056c7
patch 8.2.3266: Vim9: assignment with two indexes may check next line
Bram Moolenaar <Bram@vim.org>
parents:
25453
diff
changeset
|
644 |
23033
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
645 lines =<< trim END |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
646 var d3: dict<dict<number>> |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
647 d3.one = {} |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
648 d3.one.two = {} |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
649 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
650 v9.CheckDefFailure(lines, 'E1012: Type mismatch; expected number but got dict<unknown>', 3) |
23033
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
651 |
23187
013aa8e2be8c
patch 8.2.2139: Vim9: unreachable code in assignment
Bram Moolenaar <Bram@vim.org>
parents:
23185
diff
changeset
|
652 lines =<< trim END |
013aa8e2be8c
patch 8.2.2139: Vim9: unreachable code in assignment
Bram Moolenaar <Bram@vim.org>
parents:
23185
diff
changeset
|
653 var lines: list<string> |
013aa8e2be8c
patch 8.2.2139: Vim9: unreachable code in assignment
Bram Moolenaar <Bram@vim.org>
parents:
23185
diff
changeset
|
654 lines['a'] = 'asdf' |
013aa8e2be8c
patch 8.2.2139: Vim9: unreachable code in assignment
Bram Moolenaar <Bram@vim.org>
parents:
23185
diff
changeset
|
655 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
656 v9.CheckDefFailure(lines, 'E1012:', 2) |
23187
013aa8e2be8c
patch 8.2.2139: Vim9: unreachable code in assignment
Bram Moolenaar <Bram@vim.org>
parents:
23185
diff
changeset
|
657 |
013aa8e2be8c
patch 8.2.2139: Vim9: unreachable code in assignment
Bram Moolenaar <Bram@vim.org>
parents:
23185
diff
changeset
|
658 lines =<< trim END |
013aa8e2be8c
patch 8.2.2139: Vim9: unreachable code in assignment
Bram Moolenaar <Bram@vim.org>
parents:
23185
diff
changeset
|
659 var lines: string |
013aa8e2be8c
patch 8.2.2139: Vim9: unreachable code in assignment
Bram Moolenaar <Bram@vim.org>
parents:
23185
diff
changeset
|
660 lines[9] = 'asdf' |
013aa8e2be8c
patch 8.2.2139: Vim9: unreachable code in assignment
Bram Moolenaar <Bram@vim.org>
parents:
23185
diff
changeset
|
661 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
662 v9.CheckDefFailure(lines, 'E1141:', 2) |
23187
013aa8e2be8c
patch 8.2.2139: Vim9: unreachable code in assignment
Bram Moolenaar <Bram@vim.org>
parents:
23185
diff
changeset
|
663 |
23033
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
664 # list of dict |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
665 var ld: list<dict<number>> |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
666 ld[0] = {} |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
667 ld[0].one = 123 |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
668 assert_equal([{one: 123}], ld) |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
669 |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
670 lines =<< trim END |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
671 var ld: list<dict<number>> |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
672 ld[0] = [] |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
673 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
674 v9.CheckDefFailure(lines, 'E1012: Type mismatch; expected dict<number> but got list<unknown>', 2) |
23033
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
675 |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
676 # dict of list |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
677 var dl: dict<list<number>> |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
678 dl.one = [] |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
679 dl.one[0] = 123 |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
680 assert_equal({one: [123]}, dl) |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
681 |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
682 lines =<< trim END |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
683 var dl: dict<list<number>> |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
684 dl.one = {} |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
685 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
686 v9.CheckDefFailure(lines, 'E1012: Type mismatch; expected list<number> but got dict<unknown>', 2) |
27762
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
687 |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
688 lines =<< trim END |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
689 g:l = [1, 2] |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
690 g:l['x'] = 3 |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
691 END |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
692 v9.CheckDefExecAndScriptFailure(lines, ['E39:', 'E1030:'], 2) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
693 |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
694 lines =<< trim END |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
695 var bl: blob = test_null_blob() |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
696 bl[1] = 8 |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
697 END |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
698 v9.CheckDefExecAndScriptFailure(lines, ['E1184:', 'E979:'], 2) |
27764
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
699 |
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
700 lines =<< trim END |
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
701 g:bl = 'not a blob' |
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
702 g:bl[1 : 2] = 8 |
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
703 END |
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
704 v9.CheckDefExecAndScriptFailure(lines, ['E897:', 'E689:'], 2) |
23033
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
705 enddef |
b98003d73150
patch 8.2.2063: Vim9: only one level of indexing supported
Bram Moolenaar <Bram@vim.org>
parents:
22906
diff
changeset
|
706 |
27148
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
707 def Test_init_in_for_loop() |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
708 var lines =<< trim END |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
709 var l: list<number> = [] |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
710 for i in [3, 4] |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
711 var n: number |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
712 add(l, n) |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
713 n = 123 |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
714 endfor |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
715 assert_equal([0, 0], l) |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
716 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
717 v9.CheckDefAndScriptSuccess(lines) |
27148
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
718 |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
719 lines =<< trim END |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
720 var l: list<number> = [] |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
721 for i in [3, 4] |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
722 var n: number = 0 |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
723 add(l, n) |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
724 n = 123 |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
725 endfor |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
726 assert_equal([0, 0], l) |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
727 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
728 v9.CheckDefAndScriptSuccess(lines) |
27148
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
729 |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
730 lines =<< trim END |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
731 var l: list<number> = [] |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
732 for i in [3, 4] |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
733 var n: number = 3 |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
734 add(l, n) |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
735 n = 123 |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
736 endfor |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
737 assert_equal([3, 3], l) |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
738 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
739 v9.CheckDefAndScriptSuccess(lines) |
27148
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
740 enddef |
6ed31017c303
patch 8.2.4103: Vim9: variable declared in for loop not initialzed
Bram Moolenaar <Bram@vim.org>
parents:
26980
diff
changeset
|
741 |
22365
a4866826cebc
patch 8.2.1731: Vim9: cannot use += to append to empty NULL list
Bram Moolenaar <Bram@vim.org>
parents:
22363
diff
changeset
|
742 def Test_extend_list() |
28491
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
743 # using uninitialized list assigns empty list |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
744 var lines =<< trim END |
25776
f31cf0388eab
patch 8.2.3423: Vim9: list += list creates a new list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25668
diff
changeset
|
745 var l1: list<number> |
f31cf0388eab
patch 8.2.3423: Vim9: list += list creates a new list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25668
diff
changeset
|
746 var l2 = l1 |
f31cf0388eab
patch 8.2.3423: Vim9: list += list creates a new list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25668
diff
changeset
|
747 assert_true(l1 is l2) |
f31cf0388eab
patch 8.2.3423: Vim9: list += list creates a new list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25668
diff
changeset
|
748 l1 += [123] |
f31cf0388eab
patch 8.2.3423: Vim9: list += list creates a new list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25668
diff
changeset
|
749 assert_equal([123], l1) |
f31cf0388eab
patch 8.2.3423: Vim9: list += list creates a new list in :def function
Bram Moolenaar <Bram@vim.org>
parents:
25668
diff
changeset
|
750 assert_true(l1 is l2) |
22802
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
751 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
752 v9.CheckDefAndScriptSuccess(lines) |
22365
a4866826cebc
patch 8.2.1731: Vim9: cannot use += to append to empty NULL list
Bram Moolenaar <Bram@vim.org>
parents:
22363
diff
changeset
|
753 |
22802
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
754 lines =<< trim END |
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
755 var list: list<string> |
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
756 extend(list, ['x']) |
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
757 assert_equal(['x'], list) |
22365
a4866826cebc
patch 8.2.1731: Vim9: cannot use += to append to empty NULL list
Bram Moolenaar <Bram@vim.org>
parents:
22363
diff
changeset
|
758 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
759 v9.CheckDefAndScriptSuccess(lines) |
22545
47596deedfb5
patch 8.2.1821: Vim9: concatenating to a NULL list doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
760 |
28491
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
761 # appending to uninitialized list from a function works |
22545
47596deedfb5
patch 8.2.1821: Vim9: concatenating to a NULL list doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
762 lines =<< trim END |
47596deedfb5
patch 8.2.1821: Vim9: concatenating to a NULL list doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
763 vim9script |
47596deedfb5
patch 8.2.1821: Vim9: concatenating to a NULL list doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
764 var list: list<string> |
47596deedfb5
patch 8.2.1821: Vim9: concatenating to a NULL list doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
765 def Func() |
47596deedfb5
patch 8.2.1821: Vim9: concatenating to a NULL list doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
766 list += ['a', 'b'] |
47596deedfb5
patch 8.2.1821: Vim9: concatenating to a NULL list doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
767 enddef |
47596deedfb5
patch 8.2.1821: Vim9: concatenating to a NULL list doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
768 Func() |
47596deedfb5
patch 8.2.1821: Vim9: concatenating to a NULL list doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
769 assert_equal(['a', 'b'], list) |
47596deedfb5
patch 8.2.1821: Vim9: concatenating to a NULL list doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
770 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
771 v9.CheckScriptSuccess(lines) |
23227
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23223
diff
changeset
|
772 lines =<< trim END |
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23223
diff
changeset
|
773 vim9script |
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23223
diff
changeset
|
774 var list: list<string> |
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23223
diff
changeset
|
775 def Func() |
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23223
diff
changeset
|
776 extend(list, ['x', 'b']) |
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23223
diff
changeset
|
777 enddef |
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23223
diff
changeset
|
778 Func() |
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23223
diff
changeset
|
779 assert_equal(['x', 'b'], list) |
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23223
diff
changeset
|
780 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
781 v9.CheckScriptSuccess(lines) |
22802
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
782 |
28345
fabe722b24e9
patch 8.2.4698: Vim9: script variable has no flag that it was set
Bram Moolenaar <Bram@vim.org>
parents:
28273
diff
changeset
|
783 # initialized to null, with type, does not default to empty list |
22802
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
784 lines =<< trim END |
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
785 vim9script |
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
786 var l: list<string> = test_null_list() |
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
787 extend(l, ['x']) |
28345
fabe722b24e9
patch 8.2.4698: Vim9: script variable has no flag that it was set
Bram Moolenaar <Bram@vim.org>
parents:
28273
diff
changeset
|
788 END |
fabe722b24e9
patch 8.2.4698: Vim9: script variable has no flag that it was set
Bram Moolenaar <Bram@vim.org>
parents:
28273
diff
changeset
|
789 v9.CheckScriptFailure(lines, 'E1134:', 3) |
fabe722b24e9
patch 8.2.4698: Vim9: script variable has no flag that it was set
Bram Moolenaar <Bram@vim.org>
parents:
28273
diff
changeset
|
790 |
fabe722b24e9
patch 8.2.4698: Vim9: script variable has no flag that it was set
Bram Moolenaar <Bram@vim.org>
parents:
28273
diff
changeset
|
791 # initialized to null, without type, does not default to empty list |
fabe722b24e9
patch 8.2.4698: Vim9: script variable has no flag that it was set
Bram Moolenaar <Bram@vim.org>
parents:
28273
diff
changeset
|
792 lines =<< trim END |
fabe722b24e9
patch 8.2.4698: Vim9: script variable has no flag that it was set
Bram Moolenaar <Bram@vim.org>
parents:
28273
diff
changeset
|
793 vim9script |
fabe722b24e9
patch 8.2.4698: Vim9: script variable has no flag that it was set
Bram Moolenaar <Bram@vim.org>
parents:
28273
diff
changeset
|
794 var l = null_list |
fabe722b24e9
patch 8.2.4698: Vim9: script variable has no flag that it was set
Bram Moolenaar <Bram@vim.org>
parents:
28273
diff
changeset
|
795 extend(l, ['x']) |
22802
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
796 END |
28345
fabe722b24e9
patch 8.2.4698: Vim9: script variable has no flag that it was set
Bram Moolenaar <Bram@vim.org>
parents:
28273
diff
changeset
|
797 v9.CheckScriptFailure(lines, 'E1134:', 3) |
fabe722b24e9
patch 8.2.4698: Vim9: script variable has no flag that it was set
Bram Moolenaar <Bram@vim.org>
parents:
28273
diff
changeset
|
798 |
fabe722b24e9
patch 8.2.4698: Vim9: script variable has no flag that it was set
Bram Moolenaar <Bram@vim.org>
parents:
28273
diff
changeset
|
799 # assigned null, does not default to empty list |
fabe722b24e9
patch 8.2.4698: Vim9: script variable has no flag that it was set
Bram Moolenaar <Bram@vim.org>
parents:
28273
diff
changeset
|
800 lines =<< trim END |
fabe722b24e9
patch 8.2.4698: Vim9: script variable has no flag that it was set
Bram Moolenaar <Bram@vim.org>
parents:
28273
diff
changeset
|
801 vim9script |
fabe722b24e9
patch 8.2.4698: Vim9: script variable has no flag that it was set
Bram Moolenaar <Bram@vim.org>
parents:
28273
diff
changeset
|
802 var l: list<string> |
fabe722b24e9
patch 8.2.4698: Vim9: script variable has no flag that it was set
Bram Moolenaar <Bram@vim.org>
parents:
28273
diff
changeset
|
803 l = null_list |
fabe722b24e9
patch 8.2.4698: Vim9: script variable has no flag that it was set
Bram Moolenaar <Bram@vim.org>
parents:
28273
diff
changeset
|
804 extend(l, ['x']) |
fabe722b24e9
patch 8.2.4698: Vim9: script variable has no flag that it was set
Bram Moolenaar <Bram@vim.org>
parents:
28273
diff
changeset
|
805 END |
fabe722b24e9
patch 8.2.4698: Vim9: script variable has no flag that it was set
Bram Moolenaar <Bram@vim.org>
parents:
28273
diff
changeset
|
806 v9.CheckScriptFailure(lines, 'E1134:', 4) |
22802
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
807 |
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
808 lines =<< trim END |
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
809 vim9script |
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
810 extend(test_null_list(), ['x']) |
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
811 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
812 v9.CheckScriptFailure(lines, 'E1134:', 2) |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
813 |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
814 # using global var has no declared type |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
815 g:myList = [] |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
816 g:myList->extend([1]) |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
817 g:myList->extend(['x']) |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
818 assert_equal([1, 'x'], g:myList) |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
819 unlet g:myList |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
820 |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
821 # using declared list gives an error |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
822 lines =<< trim END |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
823 var l: list<number> |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
824 g:myList = l |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
825 g:myList->extend([1]) |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
826 g:myList->extend(['x']) |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
827 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
828 v9.CheckDefExecAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected list<number> but got list<string>', 4) |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
829 unlet g:myList |
27569
f40647a2b36a
patch 8.2.4311: Vim9: changing script variable type not caught compile time
Bram Moolenaar <Bram@vim.org>
parents:
27539
diff
changeset
|
830 |
f40647a2b36a
patch 8.2.4311: Vim9: changing script variable type not caught compile time
Bram Moolenaar <Bram@vim.org>
parents:
27539
diff
changeset
|
831 lines =<< trim END |
f40647a2b36a
patch 8.2.4311: Vim9: changing script variable type not caught compile time
Bram Moolenaar <Bram@vim.org>
parents:
27539
diff
changeset
|
832 vim9script |
f40647a2b36a
patch 8.2.4311: Vim9: changing script variable type not caught compile time
Bram Moolenaar <Bram@vim.org>
parents:
27539
diff
changeset
|
833 var lds = [1, 2, 3] |
f40647a2b36a
patch 8.2.4311: Vim9: changing script variable type not caught compile time
Bram Moolenaar <Bram@vim.org>
parents:
27539
diff
changeset
|
834 def Func() |
f40647a2b36a
patch 8.2.4311: Vim9: changing script variable type not caught compile time
Bram Moolenaar <Bram@vim.org>
parents:
27539
diff
changeset
|
835 echo lds->extend(['x']) |
f40647a2b36a
patch 8.2.4311: Vim9: changing script variable type not caught compile time
Bram Moolenaar <Bram@vim.org>
parents:
27539
diff
changeset
|
836 enddef |
f40647a2b36a
patch 8.2.4311: Vim9: changing script variable type not caught compile time
Bram Moolenaar <Bram@vim.org>
parents:
27539
diff
changeset
|
837 defcompile |
f40647a2b36a
patch 8.2.4311: Vim9: changing script variable type not caught compile time
Bram Moolenaar <Bram@vim.org>
parents:
27539
diff
changeset
|
838 END |
f40647a2b36a
patch 8.2.4311: Vim9: changing script variable type not caught compile time
Bram Moolenaar <Bram@vim.org>
parents:
27539
diff
changeset
|
839 v9.CheckScriptFailure(lines, 'E1013:') |
22802
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
840 enddef |
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
841 |
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
842 def Test_extend_dict() |
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
843 var lines =<< trim END |
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
844 vim9script |
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
845 var d: dict<number> |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
846 extend(d, {a: 1}) |
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
847 assert_equal({a: 1}, d) |
22802
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
848 |
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
849 var d2: dict<number> |
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
850 d2['one'] = 1 |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
851 assert_equal({one: 1}, d2) |
22802
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
852 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
853 v9.CheckScriptSuccess(lines) |
22802
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
854 |
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
855 lines =<< trim END |
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
856 vim9script |
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
857 var d: dict<string> = test_null_dict() |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
858 extend(d, {a: 'x'}) |
22802
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
859 END |
28345
fabe722b24e9
patch 8.2.4698: Vim9: script variable has no flag that it was set
Bram Moolenaar <Bram@vim.org>
parents:
28273
diff
changeset
|
860 v9.CheckScriptFailure(lines, 'E1133:', 3) |
22802
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
861 |
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
862 lines =<< trim END |
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
863 vim9script |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
864 extend(test_null_dict(), {a: 'x'}) |
22802
3e0f909ca1f2
patch 8.2.1949: Vim9: using extend() on null dict is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
22631
diff
changeset
|
865 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
866 v9.CheckScriptFailure(lines, 'E1133:', 2) |
22365
a4866826cebc
patch 8.2.1731: Vim9: cannot use += to append to empty NULL list
Bram Moolenaar <Bram@vim.org>
parents:
22363
diff
changeset
|
867 enddef |
a4866826cebc
patch 8.2.1731: Vim9: cannot use += to append to empty NULL list
Bram Moolenaar <Bram@vim.org>
parents:
22363
diff
changeset
|
868 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
869 def Test_single_letter_vars() |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
870 # single letter variables |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
871 var a: number = 123 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
872 a = 123 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
873 assert_equal(123, a) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
874 var b: number |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
875 b = 123 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
876 assert_equal(123, b) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
877 var g: number |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
878 g = 123 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
879 assert_equal(123, g) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
880 var s: number |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
881 s = 123 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
882 assert_equal(123, s) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
883 var t: number |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
884 t = 123 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
885 assert_equal(123, t) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
886 var v: number |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
887 v = 123 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
888 assert_equal(123, v) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
889 var w: number |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
890 w = 123 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
891 assert_equal(123, w) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
892 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
893 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
894 def Test_vim9_single_char_vars() |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
895 var lines =<< trim END |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
896 vim9script |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
897 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
898 # single character variable declarations work |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
899 var a: string |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
900 var b: number |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
901 var l: list<any> |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
902 var s: string |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
903 var t: number |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
904 var v: number |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
905 var w: number |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
906 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
907 # script-local variables can be used without s: prefix |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
908 a = 'script-a' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
909 b = 111 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
910 l = [1, 2, 3] |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
911 s = 'script-s' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
912 t = 222 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
913 v = 333 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
914 w = 444 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
915 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
916 assert_equal('script-a', a) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
917 assert_equal(111, b) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
918 assert_equal([1, 2, 3], l) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
919 assert_equal('script-s', s) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
920 assert_equal(222, t) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
921 assert_equal(333, v) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
922 assert_equal(444, w) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
923 END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
924 writefile(lines, 'Xsinglechar') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
925 source Xsinglechar |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
926 delete('Xsinglechar') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
927 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
928 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
929 def Test_assignment_list() |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
930 var list1: list<bool> = [false, true, false] |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
931 var list2: list<number> = [1, 2, 3] |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
932 var list3: list<string> = ['sdf', 'asdf'] |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
933 var list4: list<any> = ['yes', true, 1234] |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
934 var list5: list<blob> = [0z01, 0z02] |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
935 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
936 var listS: list<string> = [] |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
937 var listN: list<number> = [] |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
938 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
939 assert_equal([1, 2, 3], list2) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
940 list2[-1] = 99 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
941 assert_equal([1, 2, 99], list2) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
942 list2[-2] = 88 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
943 assert_equal([1, 88, 99], list2) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
944 list2[-3] = 77 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
945 assert_equal([77, 88, 99], list2) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
946 list2 += [100] |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
947 assert_equal([77, 88, 99, 100], list2) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
948 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
949 list3 += ['end'] |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
950 assert_equal(['sdf', 'asdf', 'end'], list3) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
951 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
952 v9.CheckDefExecFailure(['var ll = [1, 2, 3]', 'll[-4] = 6'], 'E684:') |
27766
2a394907825d
patch 8.2.4409: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27764
diff
changeset
|
953 v9.CheckDefExecFailure(['var ll = [1, 2, 3]', 'unlet ll[8 : 9]'], 'E684:') |
2a394907825d
patch 8.2.4409: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27764
diff
changeset
|
954 v9.CheckDefExecFailure(['var ll = [1, 2, 3]', 'unlet ll[1 : -9]'], 'E684:') |
2a394907825d
patch 8.2.4409: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27764
diff
changeset
|
955 v9.CheckDefExecFailure(['var ll = [1, 2, 3]', 'unlet ll[2 : 1]'], 'E684:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
956 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
957 # type becomes list<any> |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
958 var somelist = rand() > 0 ? [1, 2, 3] : ['a', 'b', 'c'] |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23245
diff
changeset
|
959 |
26925
4e77f9961650
patch 8.2.3991: Vim9: error when extending dict<any>
Bram Moolenaar <Bram@vim.org>
parents:
26851
diff
changeset
|
960 # type is list<any> even though initializer is list<number> |
4e77f9961650
patch 8.2.3991: Vim9: error when extending dict<any>
Bram Moolenaar <Bram@vim.org>
parents:
26851
diff
changeset
|
961 var anyList: list<any> = [0] |
4e77f9961650
patch 8.2.3991: Vim9: error when extending dict<any>
Bram Moolenaar <Bram@vim.org>
parents:
26851
diff
changeset
|
962 assert_equal([0, 'x'], extend(anyList, ['x'])) |
4e77f9961650
patch 8.2.3991: Vim9: error when extending dict<any>
Bram Moolenaar <Bram@vim.org>
parents:
26851
diff
changeset
|
963 |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23245
diff
changeset
|
964 var lines =<< trim END |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23245
diff
changeset
|
965 var d = {dd: test_null_list()} |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23245
diff
changeset
|
966 d.dd[0] = 0 |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23245
diff
changeset
|
967 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
968 v9.CheckDefExecFailure(lines, 'E1147:', 2) |
25126
b825efff9790
patch 8.2.3100: Vim9: no error when using type with unknown number of args
Bram Moolenaar <Bram@vim.org>
parents:
25054
diff
changeset
|
969 |
b825efff9790
patch 8.2.3100: Vim9: no error when using type with unknown number of args
Bram Moolenaar <Bram@vim.org>
parents:
25054
diff
changeset
|
970 lines =<< trim END |
b825efff9790
patch 8.2.3100: Vim9: no error when using type with unknown number of args
Bram Moolenaar <Bram@vim.org>
parents:
25054
diff
changeset
|
971 def OneArg(x: bool) |
b825efff9790
patch 8.2.3100: Vim9: no error when using type with unknown number of args
Bram Moolenaar <Bram@vim.org>
parents:
25054
diff
changeset
|
972 enddef |
b825efff9790
patch 8.2.3100: Vim9: no error when using type with unknown number of args
Bram Moolenaar <Bram@vim.org>
parents:
25054
diff
changeset
|
973 def TwoArgs(x: bool, y: bool) |
b825efff9790
patch 8.2.3100: Vim9: no error when using type with unknown number of args
Bram Moolenaar <Bram@vim.org>
parents:
25054
diff
changeset
|
974 enddef |
b825efff9790
patch 8.2.3100: Vim9: no error when using type with unknown number of args
Bram Moolenaar <Bram@vim.org>
parents:
25054
diff
changeset
|
975 var fl: list<func(bool, bool, bool)> = [OneArg, TwoArgs] |
b825efff9790
patch 8.2.3100: Vim9: no error when using type with unknown number of args
Bram Moolenaar <Bram@vim.org>
parents:
25054
diff
changeset
|
976 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
977 v9.CheckDefExecAndScriptFailure(lines, 'E1012:', 5) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
978 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
979 |
26346
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
980 def Test_list_declaration() |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
981 var [v1, v2] = [1, 2] |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
982 v1 += 3 |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
983 assert_equal(4, v1) |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
984 v2 *= 3 |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
985 assert_equal(6, v2) |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
986 |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
987 var lines =<< trim END |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
988 var [v1, v2] = [1] |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
989 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
990 v9.CheckDefExecAndScriptFailure(lines, ['E1093: Expected 2 items but got 1', 'E688:']) |
26346
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
991 lines =<< trim END |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
992 var testlist = [1] |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
993 var [v1, v2] = testlist |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
994 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
995 v9.CheckDefExecAndScriptFailure(lines, ['E1093: Expected 2 items but got 1', 'E688:']) |
26346
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
996 lines =<< trim END |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
997 var [v1, v2] = [1, 2, 3] |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
998 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
999 v9.CheckDefExecAndScriptFailure(lines, ['E1093: Expected 2 items but got 3', 'E687:']) |
26346
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1000 lines =<< trim END |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1001 var testlist = [1, 2, 3] |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1002 var [v1, v2] = testlist |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1003 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1004 v9.CheckDefExecAndScriptFailure(lines, ['E1093: Expected 2 items but got 3', 'E687:']) |
26346
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1005 |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1006 var [vnr, vstr] = [123, 'text'] |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1007 vnr += 3 |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1008 assert_equal(126, vnr) |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1009 vstr ..= 'end' |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1010 assert_equal('textend', vstr) |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1011 |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1012 var [vnr2: number, vstr2: string] = [123, 'text'] |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1013 vnr2 += 3 |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1014 assert_equal(126, vnr2) |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1015 vstr2 ..= 'end' |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1016 assert_equal('textend', vstr2) |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1017 |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1018 var [vnr3: number; vlist: list<string>] = [123, 'foo', 'bar'] |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1019 vnr3 += 5 |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1020 assert_equal(128, vnr3) |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1021 assert_equal(['foo', 'bar'], vlist) |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1022 |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1023 lines =<< trim END |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1024 var [vnr2: number, vstr2: number] = [123, 'text'] |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1025 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1026 v9.CheckDefExecAndScriptFailure(lines, ['E1163: Variable 2: type mismatch, expected number but got string', 'E1012: Type mismatch; expected number but got string']) |
26346
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1027 lines =<< trim END |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1028 var testlist = [234, 'text'] |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1029 var [vnr2: number, vstr2: number] = testlist |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1030 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1031 v9.CheckDefExecAndScriptFailure(lines, ['E1163: Variable 2: type mismatch, expected number but got string', 'E1012: Type mismatch; expected number but got string']) |
26346
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1032 enddef |
8be6413a8e27
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26330
diff
changeset
|
1033 |
25137
34f18d4081af
patch 8.2.3105: Vim9: type of partial is wrong when it has arguments
Bram Moolenaar <Bram@vim.org>
parents:
25135
diff
changeset
|
1034 def PartFuncBool(b: bool): string |
25135
5731bcaaabcb
patch 8.2.3104: Vim9: unspecified function type causes type error
Bram Moolenaar <Bram@vim.org>
parents:
25126
diff
changeset
|
1035 return 'done' |
5731bcaaabcb
patch 8.2.3104: Vim9: unspecified function type causes type error
Bram Moolenaar <Bram@vim.org>
parents:
25126
diff
changeset
|
1036 enddef |
5731bcaaabcb
patch 8.2.3104: Vim9: unspecified function type causes type error
Bram Moolenaar <Bram@vim.org>
parents:
25126
diff
changeset
|
1037 |
5731bcaaabcb
patch 8.2.3104: Vim9: unspecified function type causes type error
Bram Moolenaar <Bram@vim.org>
parents:
25126
diff
changeset
|
1038 def Test_assignment_partial() |
25137
34f18d4081af
patch 8.2.3105: Vim9: type of partial is wrong when it has arguments
Bram Moolenaar <Bram@vim.org>
parents:
25135
diff
changeset
|
1039 var lines =<< trim END |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
1040 var Partial: func(): string = function(g:PartFuncBool, [true]) |
25137
34f18d4081af
patch 8.2.3105: Vim9: type of partial is wrong when it has arguments
Bram Moolenaar <Bram@vim.org>
parents:
25135
diff
changeset
|
1041 assert_equal('done', Partial()) |
34f18d4081af
patch 8.2.3105: Vim9: type of partial is wrong when it has arguments
Bram Moolenaar <Bram@vim.org>
parents:
25135
diff
changeset
|
1042 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1043 v9.CheckDefAndScriptSuccess(lines) |
25141
99f6087a5fd2
patch 8.2.3107: Vim9: error for arguments while type didn't specify arguments
Bram Moolenaar <Bram@vim.org>
parents:
25139
diff
changeset
|
1044 |
99f6087a5fd2
patch 8.2.3107: Vim9: error for arguments while type didn't specify arguments
Bram Moolenaar <Bram@vim.org>
parents:
25139
diff
changeset
|
1045 lines =<< trim END |
99f6087a5fd2
patch 8.2.3107: Vim9: error for arguments while type didn't specify arguments
Bram Moolenaar <Bram@vim.org>
parents:
25139
diff
changeset
|
1046 vim9script |
99f6087a5fd2
patch 8.2.3107: Vim9: error for arguments while type didn't specify arguments
Bram Moolenaar <Bram@vim.org>
parents:
25139
diff
changeset
|
1047 def Func(b: bool) |
99f6087a5fd2
patch 8.2.3107: Vim9: error for arguments while type didn't specify arguments
Bram Moolenaar <Bram@vim.org>
parents:
25139
diff
changeset
|
1048 enddef |
99f6087a5fd2
patch 8.2.3107: Vim9: error for arguments while type didn't specify arguments
Bram Moolenaar <Bram@vim.org>
parents:
25139
diff
changeset
|
1049 var Ref: func = function(Func, [true]) |
99f6087a5fd2
patch 8.2.3107: Vim9: error for arguments while type didn't specify arguments
Bram Moolenaar <Bram@vim.org>
parents:
25139
diff
changeset
|
1050 assert_equal('func()', typename(Ref)) |
99f6087a5fd2
patch 8.2.3107: Vim9: error for arguments while type didn't specify arguments
Bram Moolenaar <Bram@vim.org>
parents:
25139
diff
changeset
|
1051 Ref() |
99f6087a5fd2
patch 8.2.3107: Vim9: error for arguments while type didn't specify arguments
Bram Moolenaar <Bram@vim.org>
parents:
25139
diff
changeset
|
1052 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1053 v9.CheckScriptSuccess(lines) |
26833
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1054 |
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1055 lines =<< trim END |
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1056 vim9script |
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1057 |
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1058 var nres: any |
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1059 var sres: any |
26851
15913ba6363e
patch 8.2.3954: Vim9: no error for shadowing if script var is declared later
Bram Moolenaar <Bram@vim.org>
parents:
26833
diff
changeset
|
1060 def Func(nr: number, s = '') |
15913ba6363e
patch 8.2.3954: Vim9: no error for shadowing if script var is declared later
Bram Moolenaar <Bram@vim.org>
parents:
26833
diff
changeset
|
1061 nres = nr |
26833
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1062 sres = s |
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1063 enddef |
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1064 |
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1065 var n: number |
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1066 var Ref = function(Func, [n]) |
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1067 Ref('x') |
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1068 assert_equal(0, nres) |
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1069 assert_equal('x', sres) |
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1070 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1071 v9.CheckScriptSuccess(lines) |
26833
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1072 |
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1073 lines =<< trim END |
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1074 vim9script |
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1075 |
26851
15913ba6363e
patch 8.2.3954: Vim9: no error for shadowing if script var is declared later
Bram Moolenaar <Bram@vim.org>
parents:
26833
diff
changeset
|
1076 def Func(nr: number, s = '') |
26833
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1077 enddef |
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1078 |
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1079 var n: number |
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1080 var Ref = function(Func, [n]) |
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1081 Ref(0) |
434eaef2ac62
patch 8.2.3945: Vim9: partial variable argument types are wrong
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
1082 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1083 v9.CheckScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected string but got number') |
25135
5731bcaaabcb
patch 8.2.3104: Vim9: unspecified function type causes type error
Bram Moolenaar <Bram@vim.org>
parents:
25126
diff
changeset
|
1084 enddef |
5731bcaaabcb
patch 8.2.3104: Vim9: unspecified function type causes type error
Bram Moolenaar <Bram@vim.org>
parents:
25126
diff
changeset
|
1085 |
23662
c761fcb89dfe
patch 8.2.2373: Vim9: list assignment only accepts a number index
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
1086 def Test_assignment_list_any_index() |
c761fcb89dfe
patch 8.2.2373: Vim9: list assignment only accepts a number index
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
1087 var l: list<number> = [1, 2] |
c761fcb89dfe
patch 8.2.2373: Vim9: list assignment only accepts a number index
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
1088 for [x, y, _] |
c761fcb89dfe
patch 8.2.2373: Vim9: list assignment only accepts a number index
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
1089 in [[0, 1, ''], [1, 3, '']] |
c761fcb89dfe
patch 8.2.2373: Vim9: list assignment only accepts a number index
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
1090 l[x] = l[x] + y |
c761fcb89dfe
patch 8.2.2373: Vim9: list assignment only accepts a number index
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
1091 endfor |
c761fcb89dfe
patch 8.2.2373: Vim9: list assignment only accepts a number index
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
1092 assert_equal([2, 5], l) |
c761fcb89dfe
patch 8.2.2373: Vim9: list assignment only accepts a number index
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
1093 enddef |
c761fcb89dfe
patch 8.2.2373: Vim9: list assignment only accepts a number index
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
1094 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1095 def Test_assignment_list_vim9script() |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1096 var lines =<< trim END |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1097 vim9script |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1098 var v1: number |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1099 var v2: number |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1100 var v3: number |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1101 [v1, v2, v3] = [1, 2, 3] |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1102 assert_equal([1, 2, 3], [v1, v2, v3]) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1103 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1104 v9.CheckScriptSuccess(lines) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1105 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1106 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1107 def Test_assignment_dict() |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
1108 var dict1: dict<bool> = {one: false, two: true} |
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
1109 var dict2: dict<number> = {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
|
1110 var dict3: dict<string> = {key: 'value'} |
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
1111 var dict4: dict<any> = {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
|
1112 var dict5: dict<blob> = {one: 0z01, two: 0z02} |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1113 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1114 # overwrite |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1115 dict3['key'] = 'another' |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
1116 assert_equal(dict3, {key: 'another'}) |
22906
5ff7125e81fc
patch 8.2.2000: Vim9: dict.key assignment not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
22802
diff
changeset
|
1117 dict3.key = 'yet another' |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
1118 assert_equal(dict3, {key: 'yet another'}) |
22906
5ff7125e81fc
patch 8.2.2000: Vim9: dict.key assignment not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
22802
diff
changeset
|
1119 |
23245
ac934fbacc0e
patch 8.2.2168: Vim9: error for assigning to dict of dict
Bram Moolenaar <Bram@vim.org>
parents:
23243
diff
changeset
|
1120 # member "any" can also be a dict and assigned to |
ac934fbacc0e
patch 8.2.2168: Vim9: error for assigning to dict of dict
Bram Moolenaar <Bram@vim.org>
parents:
23243
diff
changeset
|
1121 var anydict: dict<any> = {nest: {}, nr: 0} |
ac934fbacc0e
patch 8.2.2168: Vim9: error for assigning to dict of dict
Bram Moolenaar <Bram@vim.org>
parents:
23243
diff
changeset
|
1122 anydict.nest['this'] = 123 |
ac934fbacc0e
patch 8.2.2168: Vim9: error for assigning to dict of dict
Bram Moolenaar <Bram@vim.org>
parents:
23243
diff
changeset
|
1123 anydict.nest.that = 456 |
ac934fbacc0e
patch 8.2.2168: Vim9: error for assigning to dict of dict
Bram Moolenaar <Bram@vim.org>
parents:
23243
diff
changeset
|
1124 assert_equal({nest: {this: 123, that: 456}, nr: 0}, anydict) |
ac934fbacc0e
patch 8.2.2168: Vim9: error for assigning to dict of dict
Bram Moolenaar <Bram@vim.org>
parents:
23243
diff
changeset
|
1125 |
22906
5ff7125e81fc
patch 8.2.2000: Vim9: dict.key assignment not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
22802
diff
changeset
|
1126 var lines =<< trim END |
23243
0804cb073097
patch 8.2.2167: Vim9: assign test fails
Bram Moolenaar <Bram@vim.org>
parents:
23227
diff
changeset
|
1127 var dd = {} |
0804cb073097
patch 8.2.2167: Vim9: assign test fails
Bram Moolenaar <Bram@vim.org>
parents:
23227
diff
changeset
|
1128 dd.two = 2 |
0804cb073097
patch 8.2.2167: Vim9: assign test fails
Bram Moolenaar <Bram@vim.org>
parents:
23227
diff
changeset
|
1129 assert_equal({two: 2}, dd) |
0804cb073097
patch 8.2.2167: Vim9: assign test fails
Bram Moolenaar <Bram@vim.org>
parents:
23227
diff
changeset
|
1130 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1131 v9.CheckDefAndScriptSuccess(lines) |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23245
diff
changeset
|
1132 |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23245
diff
changeset
|
1133 lines =<< trim END |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23245
diff
changeset
|
1134 var d = {dd: {}} |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23245
diff
changeset
|
1135 d.dd[0] = 2 |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23245
diff
changeset
|
1136 d.dd['x'] = 3 |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23245
diff
changeset
|
1137 d.dd.y = 4 |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23245
diff
changeset
|
1138 assert_equal({dd: {0: 2, x: 3, y: 4}}, d) |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23245
diff
changeset
|
1139 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1140 v9.CheckDefAndScriptSuccess(lines) |
23243
0804cb073097
patch 8.2.2167: Vim9: assign test fails
Bram Moolenaar <Bram@vim.org>
parents:
23227
diff
changeset
|
1141 |
0804cb073097
patch 8.2.2167: Vim9: assign test fails
Bram Moolenaar <Bram@vim.org>
parents:
23227
diff
changeset
|
1142 lines =<< trim END |
28129
dd2ed5345f20
patch 8.2.4589: cannot index the g: dictionary
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
1143 var key = 'foo' |
dd2ed5345f20
patch 8.2.4589: cannot index the g: dictionary
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
1144 g:[key] = 'value' |
dd2ed5345f20
patch 8.2.4589: cannot index the g: dictionary
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
1145 assert_equal('value', g:foo) |
dd2ed5345f20
patch 8.2.4589: cannot index the g: dictionary
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
1146 unlet g:foo |
dd2ed5345f20
patch 8.2.4589: cannot index the g: dictionary
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
1147 END |
dd2ed5345f20
patch 8.2.4589: cannot index the g: dictionary
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
1148 v9.CheckDefAndScriptSuccess(lines) |
dd2ed5345f20
patch 8.2.4589: cannot index the g: dictionary
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
1149 |
dd2ed5345f20
patch 8.2.4589: cannot index the g: dictionary
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
1150 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
|
1151 var dd = {one: 1} |
22906
5ff7125e81fc
patch 8.2.2000: Vim9: dict.key assignment not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
22802
diff
changeset
|
1152 dd.one) = 2 |
5ff7125e81fc
patch 8.2.2000: Vim9: dict.key assignment not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
22802
diff
changeset
|
1153 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1154 v9.CheckDefFailure(lines, 'E488:', 2) |
23243
0804cb073097
patch 8.2.2167: Vim9: assign test fails
Bram Moolenaar <Bram@vim.org>
parents:
23227
diff
changeset
|
1155 |
0804cb073097
patch 8.2.2167: Vim9: assign test fails
Bram Moolenaar <Bram@vim.org>
parents:
23227
diff
changeset
|
1156 lines =<< trim END |
0804cb073097
patch 8.2.2167: Vim9: assign test fails
Bram Moolenaar <Bram@vim.org>
parents:
23227
diff
changeset
|
1157 var dd = {one: 1} |
0804cb073097
patch 8.2.2167: Vim9: assign test fails
Bram Moolenaar <Bram@vim.org>
parents:
23227
diff
changeset
|
1158 var dd.one = 2 |
0804cb073097
patch 8.2.2167: Vim9: assign test fails
Bram Moolenaar <Bram@vim.org>
parents:
23227
diff
changeset
|
1159 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1160 v9.CheckDefAndScriptFailure(lines, 'E1017:', 2) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1161 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1162 # empty key can be used |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1163 var dd = {} |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1164 dd[""] = 6 |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
1165 assert_equal({['']: 6}, dd) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1166 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1167 # type becomes dict<any> |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
1168 var somedict = rand() > 0 ? {a: 1, b: 2} : {a: 'a', b: 'b'} |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1169 |
26925
4e77f9961650
patch 8.2.3991: Vim9: error when extending dict<any>
Bram Moolenaar <Bram@vim.org>
parents:
26851
diff
changeset
|
1170 # type is dict<any> even though initializer is dict<number> |
4e77f9961650
patch 8.2.3991: Vim9: error when extending dict<any>
Bram Moolenaar <Bram@vim.org>
parents:
26851
diff
changeset
|
1171 var anyDict: dict<any> = {a: 0} |
4e77f9961650
patch 8.2.3991: Vim9: error when extending dict<any>
Bram Moolenaar <Bram@vim.org>
parents:
26851
diff
changeset
|
1172 assert_equal({a: 0, b: 'x'}, extend(anyDict, {b: 'x'})) |
4e77f9961650
patch 8.2.3991: Vim9: error when extending dict<any>
Bram Moolenaar <Bram@vim.org>
parents:
26851
diff
changeset
|
1173 |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
1174 # using global var, which has no declared type |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
1175 g:myDict = {} |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
1176 g:myDict->extend({a: 1}) |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
1177 g:myDict->extend({b: 'x'}) |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
1178 assert_equal({a: 1, b: 'x'}, g:myDict) |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
1179 unlet g:myDict |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
1180 |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
1181 # using list with declared type gives an error |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
1182 lines =<< trim END |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
1183 var d: dict<number> |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
1184 g:myDict = d |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
1185 g:myDict->extend({a: 1}) |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
1186 g:myDict->extend({b: 'x'}) |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
1187 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1188 v9.CheckDefExecAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected dict<number> but got dict<string>', 4) |
26935
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
1189 unlet g:myDict |
ccb9be1cdd71
patch 8.2.3996: Vim9: type checking lacks information about declared type
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
1190 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1191 # assignment to script-local dict |
22906
5ff7125e81fc
patch 8.2.2000: Vim9: dict.key assignment not implemented yet
Bram Moolenaar <Bram@vim.org>
parents:
22802
diff
changeset
|
1192 lines =<< trim END |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1193 vim9script |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1194 var test: dict<any> = {} |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1195 def FillDict(): dict<any> |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1196 test['a'] = 43 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1197 return test |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1198 enddef |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
1199 assert_equal({a: 43}, FillDict()) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1200 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1201 v9.CheckScriptSuccess(lines) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1202 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1203 lines =<< trim END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1204 vim9script |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1205 var test: dict<any> |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1206 def FillDict(): dict<any> |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1207 test['a'] = 43 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1208 return test |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1209 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1210 FillDict() |
23227
ccbbbbed371f
patch 8.2.2159: Vim9: when declaring a list it is not allocated yet
Bram Moolenaar <Bram@vim.org>
parents:
23223
diff
changeset
|
1211 assert_equal({a: 43}, test) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1212 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1213 v9.CheckScriptSuccess(lines) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1214 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1215 # assignment to global dict |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1216 lines =<< trim END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1217 vim9script |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1218 g:test = {} |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1219 def FillDict(): dict<any> |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1220 g:test['a'] = 43 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1221 return g:test |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1222 enddef |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
1223 assert_equal({a: 43}, FillDict()) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1224 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1225 v9.CheckScriptSuccess(lines) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1226 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1227 # assignment to buffer dict |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1228 lines =<< trim END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1229 vim9script |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1230 b:test = {} |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1231 def FillDict(): dict<any> |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1232 b:test['a'] = 43 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1233 return b:test |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1234 enddef |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
1235 assert_equal({a: 43}, FillDict()) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1236 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1237 v9.CheckScriptSuccess(lines) |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23245
diff
changeset
|
1238 |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23245
diff
changeset
|
1239 lines =<< trim END |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23245
diff
changeset
|
1240 var d = {dd: test_null_dict()} |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23245
diff
changeset
|
1241 d.dd[0] = 0 |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23245
diff
changeset
|
1242 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1243 v9.CheckDefExecFailure(lines, 'E1103:', 2) |
23266
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23245
diff
changeset
|
1244 |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23245
diff
changeset
|
1245 lines =<< trim END |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23245
diff
changeset
|
1246 var d = {dd: 'string'} |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23245
diff
changeset
|
1247 d.dd[0] = 0 |
00f7cd9b6033
patch 8.2.2179: Vim9: crash when indexing a dict with a number
Bram Moolenaar <Bram@vim.org>
parents:
23245
diff
changeset
|
1248 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1249 v9.CheckDefExecFailure(lines, 'E1148:', 2) |
25036
3b8d3b383fd6
patch 8.2.3055: strange error for assigning to "x.key" on non-dictionary
Bram Moolenaar <Bram@vim.org>
parents:
25034
diff
changeset
|
1250 |
3b8d3b383fd6
patch 8.2.3055: strange error for assigning to "x.key" on non-dictionary
Bram Moolenaar <Bram@vim.org>
parents:
25034
diff
changeset
|
1251 lines =<< trim END |
3b8d3b383fd6
patch 8.2.3055: strange error for assigning to "x.key" on non-dictionary
Bram Moolenaar <Bram@vim.org>
parents:
25034
diff
changeset
|
1252 var n: any |
3b8d3b383fd6
patch 8.2.3055: strange error for assigning to "x.key" on non-dictionary
Bram Moolenaar <Bram@vim.org>
parents:
25034
diff
changeset
|
1253 n.key = 5 |
3b8d3b383fd6
patch 8.2.3055: strange error for assigning to "x.key" on non-dictionary
Bram Moolenaar <Bram@vim.org>
parents:
25034
diff
changeset
|
1254 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1255 v9.CheckDefExecAndScriptFailure(lines, ['E1148:', 'E1203: Dot can only be used on a dictionary: n.key = 5'], 2) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1256 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1257 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1258 def Test_assignment_local() |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1259 # Test in a separated file in order not to the current buffer/window/tab is |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1260 # changed. |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1261 var script_lines: list<string> =<< trim END |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1262 let b:existing = 'yes' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1263 let w:existing = 'yes' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1264 let t:existing = 'yes' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1265 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1266 def Test_assignment_local_internal() |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1267 b:newvar = 'new' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1268 assert_equal('new', b:newvar) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1269 assert_equal('yes', b:existing) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1270 b:existing = 'no' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1271 assert_equal('no', b:existing) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1272 b:existing ..= 'NO' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1273 assert_equal('noNO', b:existing) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1274 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1275 w:newvar = 'new' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1276 assert_equal('new', w:newvar) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1277 assert_equal('yes', w:existing) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1278 w:existing = 'no' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1279 assert_equal('no', w:existing) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1280 w:existing ..= 'NO' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1281 assert_equal('noNO', w:existing) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1282 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1283 t:newvar = 'new' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1284 assert_equal('new', t:newvar) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1285 assert_equal('yes', t:existing) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1286 t:existing = 'no' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1287 assert_equal('no', t:existing) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1288 t:existing ..= 'NO' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1289 assert_equal('noNO', t:existing) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1290 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1291 call Test_assignment_local_internal() |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1292 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1293 v9.CheckScriptSuccess(script_lines) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1294 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1295 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1296 def Test_assignment_default() |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1297 # Test default values. |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1298 var thebool: bool |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1299 assert_equal(v:false, thebool) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1300 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1301 var thenumber: number |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1302 assert_equal(0, thenumber) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1303 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1304 if has('float') |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1305 var thefloat: float |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1306 assert_equal(0.0, thefloat) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1307 endif |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1308 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1309 var thestring: string |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1310 assert_equal('', thestring) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1311 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1312 var theblob: blob |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1313 assert_equal(0z, theblob) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1314 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1315 var Thefunc: func |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1316 assert_equal(test_null_function(), Thefunc) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1317 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1318 var thelist: list<any> |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1319 assert_equal([], thelist) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1320 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1321 var thedict: dict<any> |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1322 assert_equal({}, thedict) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1323 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1324 if has('channel') |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1325 var thejob: job |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1326 assert_equal(test_null_job(), thejob) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1327 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1328 var thechannel: channel |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1329 assert_equal(test_null_channel(), thechannel) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1330 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1331 if has('unix') && executable('cat') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1332 # check with non-null job and channel, types must match |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
1333 thejob = job_start("cat ", {}) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1334 thechannel = job_getchannel(thejob) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1335 job_stop(thejob, 'kill') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1336 endif |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1337 endif |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1338 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1339 var nr = 1234 | nr = 5678 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1340 assert_equal(5678, nr) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1341 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1342 |
27762
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
1343 def Test_script_var_default() |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
1344 var lines =<< trim END |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
1345 vim9script |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
1346 var l: list<number> |
27918
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1347 var li = [1, 2] |
27762
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
1348 var bl: blob |
27918
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1349 var bli = 0z12 |
27762
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
1350 var d: dict<number> |
27918
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1351 var di = {'a': 1, 'b': 2} |
27762
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
1352 def Echo() |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
1353 assert_equal([], l) |
27918
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1354 assert_equal([1, 2], li) |
27762
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
1355 assert_equal(0z, bl) |
27918
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1356 assert_equal(0z12, bli) |
27762
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
1357 assert_equal({}, d) |
27918
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1358 assert_equal({'a': 1, 'b': 2}, di) |
27762
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
1359 enddef |
27764
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
1360 Echo() |
27762
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
1361 END |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
1362 v9.CheckScriptSuccess(lines) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
1363 enddef |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
1364 |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
1365 let s:scriptvar = 'init' |
23450
a8e7acf71fa4
patch 8.2.2268: Vim9: list unpack seen as declaration
Bram Moolenaar <Bram@vim.org>
parents:
23448
diff
changeset
|
1366 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1367 def Test_assignment_var_list() |
23050
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
1368 var lines =<< trim END |
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
1369 var v1: string |
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
1370 var v2: string |
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
1371 var vrem: list<string> |
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
1372 [v1] = ['aaa'] |
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
1373 assert_equal('aaa', v1) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1374 |
23050
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
1375 [v1, v2] = ['one', 'two'] |
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
1376 assert_equal('one', v1) |
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
1377 assert_equal('two', v2) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1378 |
23050
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
1379 [v1, v2; vrem] = ['one', 'two'] |
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
1380 assert_equal('one', v1) |
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
1381 assert_equal('two', v2) |
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
1382 assert_equal([], vrem) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1383 |
23050
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
1384 [v1, v2; vrem] = ['one', 'two', 'three'] |
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
1385 assert_equal('one', v1) |
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
1386 assert_equal('two', v2) |
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
1387 assert_equal(['three'], vrem) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1388 |
23050
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
1389 [&ts, &sw] = [3, 4] |
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
1390 assert_equal(3, &ts) |
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
1391 assert_equal(4, &sw) |
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
1392 set ts=8 sw=4 |
23052
9775df18916b
patch 8.2.2072: Vim9: list assign not well tested
Bram Moolenaar <Bram@vim.org>
parents:
23050
diff
changeset
|
1393 |
9775df18916b
patch 8.2.2072: Vim9: list assign not well tested
Bram Moolenaar <Bram@vim.org>
parents:
23050
diff
changeset
|
1394 [@a, @z] = ['aa', 'zz'] |
9775df18916b
patch 8.2.2072: Vim9: list assign not well tested
Bram Moolenaar <Bram@vim.org>
parents:
23050
diff
changeset
|
1395 assert_equal('aa', @a) |
9775df18916b
patch 8.2.2072: Vim9: list assign not well tested
Bram Moolenaar <Bram@vim.org>
parents:
23050
diff
changeset
|
1396 assert_equal('zz', @z) |
9775df18916b
patch 8.2.2072: Vim9: list assign not well tested
Bram Moolenaar <Bram@vim.org>
parents:
23050
diff
changeset
|
1397 |
9775df18916b
patch 8.2.2072: Vim9: list assign not well tested
Bram Moolenaar <Bram@vim.org>
parents:
23050
diff
changeset
|
1398 [$SOME_VAR, $OTHER_VAR] = ['some', 'other'] |
9775df18916b
patch 8.2.2072: Vim9: list assign not well tested
Bram Moolenaar <Bram@vim.org>
parents:
23050
diff
changeset
|
1399 assert_equal('some', $SOME_VAR) |
9775df18916b
patch 8.2.2072: Vim9: list assign not well tested
Bram Moolenaar <Bram@vim.org>
parents:
23050
diff
changeset
|
1400 assert_equal('other', $OTHER_VAR) |
9775df18916b
patch 8.2.2072: Vim9: list assign not well tested
Bram Moolenaar <Bram@vim.org>
parents:
23050
diff
changeset
|
1401 |
23450
a8e7acf71fa4
patch 8.2.2268: Vim9: list unpack seen as declaration
Bram Moolenaar <Bram@vim.org>
parents:
23448
diff
changeset
|
1402 [g:globalvar, b:bufvar, w:winvar, t:tabvar, v:errmsg] = |
a8e7acf71fa4
patch 8.2.2268: Vim9: list unpack seen as declaration
Bram Moolenaar <Bram@vim.org>
parents:
23448
diff
changeset
|
1403 ['global', 'buf', 'win', 'tab', 'error'] |
23052
9775df18916b
patch 8.2.2072: Vim9: list assign not well tested
Bram Moolenaar <Bram@vim.org>
parents:
23050
diff
changeset
|
1404 assert_equal('global', g:globalvar) |
9775df18916b
patch 8.2.2072: Vim9: list assign not well tested
Bram Moolenaar <Bram@vim.org>
parents:
23050
diff
changeset
|
1405 assert_equal('buf', b:bufvar) |
9775df18916b
patch 8.2.2072: Vim9: list assign not well tested
Bram Moolenaar <Bram@vim.org>
parents:
23050
diff
changeset
|
1406 assert_equal('win', w:winvar) |
9775df18916b
patch 8.2.2072: Vim9: list assign not well tested
Bram Moolenaar <Bram@vim.org>
parents:
23050
diff
changeset
|
1407 assert_equal('tab', t:tabvar) |
9775df18916b
patch 8.2.2072: Vim9: list assign not well tested
Bram Moolenaar <Bram@vim.org>
parents:
23050
diff
changeset
|
1408 assert_equal('error', v:errmsg) |
9775df18916b
patch 8.2.2072: Vim9: list assign not well tested
Bram Moolenaar <Bram@vim.org>
parents:
23050
diff
changeset
|
1409 unlet g:globalvar |
23050
50442f932ff7
patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents:
23039
diff
changeset
|
1410 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1411 v9.CheckDefAndScriptSuccess(lines) |
23450
a8e7acf71fa4
patch 8.2.2268: Vim9: list unpack seen as declaration
Bram Moolenaar <Bram@vim.org>
parents:
23448
diff
changeset
|
1412 |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
1413 [g:globalvar, scriptvar, b:bufvar] = ['global', 'script', 'buf'] |
23450
a8e7acf71fa4
patch 8.2.2268: Vim9: list unpack seen as declaration
Bram Moolenaar <Bram@vim.org>
parents:
23448
diff
changeset
|
1414 assert_equal('global', g:globalvar) |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
1415 assert_equal('script', scriptvar) |
23450
a8e7acf71fa4
patch 8.2.2268: Vim9: list unpack seen as declaration
Bram Moolenaar <Bram@vim.org>
parents:
23448
diff
changeset
|
1416 assert_equal('buf', b:bufvar) |
a8e7acf71fa4
patch 8.2.2268: Vim9: list unpack seen as declaration
Bram Moolenaar <Bram@vim.org>
parents:
23448
diff
changeset
|
1417 |
a8e7acf71fa4
patch 8.2.2268: Vim9: list unpack seen as declaration
Bram Moolenaar <Bram@vim.org>
parents:
23448
diff
changeset
|
1418 lines =<< trim END |
a8e7acf71fa4
patch 8.2.2268: Vim9: list unpack seen as declaration
Bram Moolenaar <Bram@vim.org>
parents:
23448
diff
changeset
|
1419 vim9script |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
1420 var scriptvar = 'init' |
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
1421 [g:globalvar, scriptvar, w:winvar] = ['global', 'script', 'win'] |
23450
a8e7acf71fa4
patch 8.2.2268: Vim9: list unpack seen as declaration
Bram Moolenaar <Bram@vim.org>
parents:
23448
diff
changeset
|
1422 assert_equal('global', g:globalvar) |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
1423 assert_equal('script', scriptvar) |
23450
a8e7acf71fa4
patch 8.2.2268: Vim9: list unpack seen as declaration
Bram Moolenaar <Bram@vim.org>
parents:
23448
diff
changeset
|
1424 assert_equal('win', w:winvar) |
a8e7acf71fa4
patch 8.2.2268: Vim9: list unpack seen as declaration
Bram Moolenaar <Bram@vim.org>
parents:
23448
diff
changeset
|
1425 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1426 v9.CheckScriptSuccess(lines) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1427 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1428 |
27519
7898c7847293
patch 8.2.4287: cannot assign empty list with type to variable with list type
Bram Moolenaar <Bram@vim.org>
parents:
27517
diff
changeset
|
1429 def Test_assignment_empty_list() |
7898c7847293
patch 8.2.4287: cannot assign empty list with type to variable with list type
Bram Moolenaar <Bram@vim.org>
parents:
27517
diff
changeset
|
1430 var lines =<< trim END |
7898c7847293
patch 8.2.4287: cannot assign empty list with type to variable with list type
Bram Moolenaar <Bram@vim.org>
parents:
27517
diff
changeset
|
1431 var l2: list<any> = [] |
7898c7847293
patch 8.2.4287: cannot assign empty list with type to variable with list type
Bram Moolenaar <Bram@vim.org>
parents:
27517
diff
changeset
|
1432 var l: list<string> |
7898c7847293
patch 8.2.4287: cannot assign empty list with type to variable with list type
Bram Moolenaar <Bram@vim.org>
parents:
27517
diff
changeset
|
1433 l = l2 |
7898c7847293
patch 8.2.4287: cannot assign empty list with type to variable with list type
Bram Moolenaar <Bram@vim.org>
parents:
27517
diff
changeset
|
1434 END |
7898c7847293
patch 8.2.4287: cannot assign empty list with type to variable with list type
Bram Moolenaar <Bram@vim.org>
parents:
27517
diff
changeset
|
1435 v9.CheckDefAndScriptSuccess(lines) |
7898c7847293
patch 8.2.4287: cannot assign empty list with type to variable with list type
Bram Moolenaar <Bram@vim.org>
parents:
27517
diff
changeset
|
1436 enddef |
7898c7847293
patch 8.2.4287: cannot assign empty list with type to variable with list type
Bram Moolenaar <Bram@vim.org>
parents:
27517
diff
changeset
|
1437 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1438 def Test_assignment_vim9script() |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1439 var lines =<< trim END |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1440 vim9script |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1441 def Func(): list<number> |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1442 return [1, 2] |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1443 enddef |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
1444 var name1: number |
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
1445 var name2: number |
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
1446 [name1, name2] = |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1447 Func() |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
1448 assert_equal(1, name1) |
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
1449 assert_equal(2, name2) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1450 var ll = |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1451 Func() |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1452 assert_equal([1, 2], ll) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1453 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1454 @/ = 'text' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1455 assert_equal('text', @/) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1456 @0 = 'zero' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1457 assert_equal('zero', @0) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1458 @1 = 'one' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1459 assert_equal('one', @1) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1460 @9 = 'nine' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1461 assert_equal('nine', @9) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1462 @- = 'minus' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1463 assert_equal('minus', @-) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1464 if has('clipboard_working') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1465 @* = 'star' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1466 assert_equal('star', @*) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1467 @+ = 'plus' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1468 assert_equal('plus', @+) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1469 endif |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1470 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1471 var a: number = 123 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1472 assert_equal(123, a) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1473 var s: string = 'yes' |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1474 assert_equal('yes', s) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1475 var b: number = 42 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1476 assert_equal(42, b) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1477 var w: number = 43 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1478 assert_equal(43, w) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1479 var t: number = 44 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1480 assert_equal(44, t) |
22610
08e2363fd0de
patch 8.2.1853: "to_f" is recognized at "topleft" modifier
Bram Moolenaar <Bram@vim.org>
parents:
22582
diff
changeset
|
1481 |
08e2363fd0de
patch 8.2.1853: "to_f" is recognized at "topleft" modifier
Bram Moolenaar <Bram@vim.org>
parents:
22582
diff
changeset
|
1482 var to_var = 0 |
08e2363fd0de
patch 8.2.1853: "to_f" is recognized at "topleft" modifier
Bram Moolenaar <Bram@vim.org>
parents:
22582
diff
changeset
|
1483 to_var = 3 |
08e2363fd0de
patch 8.2.1853: "to_f" is recognized at "topleft" modifier
Bram Moolenaar <Bram@vim.org>
parents:
22582
diff
changeset
|
1484 assert_equal(3, to_var) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1485 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1486 v9.CheckScriptSuccess(lines) |
22431
685909aa5641
patch 8.2.1764: Vim9: no error when assigning to script var with wrong type
Bram Moolenaar <Bram@vim.org>
parents:
22425
diff
changeset
|
1487 |
685909aa5641
patch 8.2.1764: Vim9: no error when assigning to script var with wrong type
Bram Moolenaar <Bram@vim.org>
parents:
22425
diff
changeset
|
1488 lines =<< trim END |
685909aa5641
patch 8.2.1764: Vim9: no error when assigning to script var with wrong type
Bram Moolenaar <Bram@vim.org>
parents:
22425
diff
changeset
|
1489 vim9script |
685909aa5641
patch 8.2.1764: Vim9: no error when assigning to script var with wrong type
Bram Moolenaar <Bram@vim.org>
parents:
22425
diff
changeset
|
1490 var n: number |
685909aa5641
patch 8.2.1764: Vim9: no error when assigning to script var with wrong type
Bram Moolenaar <Bram@vim.org>
parents:
22425
diff
changeset
|
1491 def Func() |
685909aa5641
patch 8.2.1764: Vim9: no error when assigning to script var with wrong type
Bram Moolenaar <Bram@vim.org>
parents:
22425
diff
changeset
|
1492 n = 'string' |
685909aa5641
patch 8.2.1764: Vim9: no error when assigning to script var with wrong type
Bram Moolenaar <Bram@vim.org>
parents:
22425
diff
changeset
|
1493 enddef |
685909aa5641
patch 8.2.1764: Vim9: no error when assigning to script var with wrong type
Bram Moolenaar <Bram@vim.org>
parents:
22425
diff
changeset
|
1494 defcompile |
685909aa5641
patch 8.2.1764: Vim9: no error when assigning to script var with wrong type
Bram Moolenaar <Bram@vim.org>
parents:
22425
diff
changeset
|
1495 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1496 v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected number but got string') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1497 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1498 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1499 def Mess(): string |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1500 v:foldstart = 123 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1501 return 'xxx' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1502 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1503 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1504 def Test_assignment_failure() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1505 v9.CheckDefFailure(['var name=234'], 'E1004:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1506 v9.CheckDefFailure(['var name =234'], 'E1004:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1507 v9.CheckDefFailure(['var name= 234'], 'E1004:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1508 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1509 v9.CheckScriptFailure(['vim9script', 'var name=234'], 'E1004:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1510 v9.CheckScriptFailure(['vim9script', 'var name=234'], "before and after '='") |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1511 v9.CheckScriptFailure(['vim9script', 'var name =234'], 'E1004:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1512 v9.CheckScriptFailure(['vim9script', 'var name= 234'], 'E1004:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1513 v9.CheckScriptFailure(['vim9script', 'var name = 234', 'name+=234'], 'E1004:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1514 v9.CheckScriptFailure(['vim9script', 'var name = 234', 'name+=234'], "before and after '+='") |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1515 v9.CheckScriptFailure(['vim9script', 'var name = "x"', 'name..="y"'], 'E1004:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1516 v9.CheckScriptFailure(['vim9script', 'var name = "x"', 'name..="y"'], "before and after '..='") |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1517 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1518 v9.CheckDefFailure(['var true = 1'], 'E1034:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1519 v9.CheckDefFailure(['var false = 1'], 'E1034:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1520 v9.CheckDefFailure(['var null = 1'], 'E1034:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1521 v9.CheckDefFailure(['var this = 1'], 'E1034:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1522 |
27738
d754ac2f5ac5
patch 8.2.4395: some code lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27728
diff
changeset
|
1523 v9.CheckDefFailure(['[a; b; c] = g:list'], 'E1001:') |
d754ac2f5ac5
patch 8.2.4395: some code lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27728
diff
changeset
|
1524 v9.CheckDefFailure(['var [a; b; c] = g:list'], 'E1080:') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1525 v9.CheckDefExecFailure(['var a: number', |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1526 '[a] = test_null_list()'], 'E1093:') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1527 v9.CheckDefExecFailure(['var a: number', |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1528 '[a] = []'], 'E1093:') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1529 v9.CheckDefExecFailure(['var x: number', |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1530 'var y: number', |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1531 '[x, y] = [1]'], 'E1093:') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1532 v9.CheckDefExecFailure(['var x: string', |
22621
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22618
diff
changeset
|
1533 'var y: string', |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22618
diff
changeset
|
1534 '[x, y] = ["x"]'], 'E1093:') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1535 v9.CheckDefExecFailure(['var x: number', |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1536 'var y: number', |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1537 'var z: list<number>', |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1538 '[x, y; z] = [1]'], 'E1093:') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1539 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1540 v9.CheckDefFailure(['var somevar'], "E1022:") |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1541 v9.CheckDefFailure(['var &tabstop = 4'], 'E1052:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1542 v9.CheckDefFailure(['&g:option = 5'], 'E113:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1543 v9.CheckScriptFailure(['vim9script', 'var &tabstop = 4'], 'E1052:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1544 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1545 v9.CheckDefFailure(['var $VAR = 5'], 'E1016: Cannot declare an environment variable:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1546 v9.CheckScriptFailure(['vim9script', 'var $ENV = "xxx"'], 'E1016:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1547 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1548 if has('dnd') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1549 v9.CheckDefFailure(['var @~ = 5'], 'E1066:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1550 else |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1551 v9.CheckDefFailure(['var @~ = 5'], 'E354:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1552 v9.CheckDefFailure(['@~ = 5'], 'E354:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1553 endif |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1554 v9.CheckDefFailure(['var @a = 5'], 'E1066:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1555 v9.CheckDefFailure(['var @/ = "x"'], 'E1066:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1556 v9.CheckScriptFailure(['vim9script', 'var @a = "abc"'], 'E1066:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1557 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1558 v9.CheckDefFailure(['var g:var = 5'], 'E1016: Cannot declare a global variable:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1559 v9.CheckDefFailure(['var w:var = 5'], 'E1016: Cannot declare a window variable:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1560 v9.CheckDefFailure(['var b:var = 5'], 'E1016: Cannot declare a buffer variable:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1561 v9.CheckDefFailure(['var t:var = 5'], 'E1016: Cannot declare a tab variable:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1562 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1563 v9.CheckDefFailure(['var anr = 4', 'anr ..= "text"'], 'E1019:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1564 v9.CheckDefFailure(['var xnr += 4'], 'E1020:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1565 v9.CheckScriptFailure(['vim9script', 'var xnr += 4'], 'E1020:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1566 v9.CheckDefFailure(["var xnr = xnr + 1"], 'E1001:', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1567 v9.CheckScriptFailure(['vim9script', 'var xnr = xnr + 4'], 'E121:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1568 |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
1569 v9.CheckScriptFailure(['vim9script', 'def Func()', 'var dummy = notfound', 'enddef', 'defcompile'], 'E1001:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1570 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1571 v9.CheckDefFailure(['var name: list<string> = [123]'], 'expected list<string> but got list<number>') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1572 v9.CheckDefFailure(['var name: list<number> = ["xx"]'], 'expected list<number> but got list<string>') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1573 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1574 v9.CheckDefFailure(['var name: dict<string> = {key: 123}'], 'expected dict<string> but got dict<number>') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1575 v9.CheckDefFailure(['var name: dict<number> = {key: "xx"}'], 'expected dict<number> but got dict<string>') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1576 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1577 v9.CheckDefFailure(['var name = feedkeys("0")'], 'E1031:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1578 v9.CheckDefFailure(['var name: number = feedkeys("0")'], 'expected number but got void') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1579 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1580 v9.CheckDefFailure(['var name: dict <number>'], 'E1068:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1581 v9.CheckDefFailure(['var name: dict<number'], 'E1009:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1582 |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
1583 assert_fails('s/^/\=g:Mess()/n', 'E794:') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1584 v9.CheckDefFailure(['var name: dict<number'], 'E1009:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1585 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1586 v9.CheckDefFailure(['w:foo: number = 10'], |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1587 'E488: Trailing characters: : number = 1') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1588 v9.CheckDefFailure(['t:foo: bool = true'], |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1589 'E488: Trailing characters: : bool = true') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1590 v9.CheckDefFailure(['b:foo: string = "x"'], |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1591 'E488: Trailing characters: : string = "x"') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1592 v9.CheckDefFailure(['g:foo: number = 123'], |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1593 'E488: Trailing characters: : number = 123') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1594 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1595 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1596 def Test_assign_list() |
25054
64bef59f11ef
patch 8.2.3064: Vim9: in script cannot set item in uninitialized list
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
1597 var lines =<< trim END |
64bef59f11ef
patch 8.2.3064: Vim9: in script cannot set item in uninitialized list
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
1598 var l: list<string> = [] |
64bef59f11ef
patch 8.2.3064: Vim9: in script cannot set item in uninitialized list
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
1599 l[0] = 'value' |
64bef59f11ef
patch 8.2.3064: Vim9: in script cannot set item in uninitialized list
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
1600 assert_equal('value', l[0]) |
64bef59f11ef
patch 8.2.3064: Vim9: in script cannot set item in uninitialized list
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
1601 |
64bef59f11ef
patch 8.2.3064: Vim9: in script cannot set item in uninitialized list
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
1602 l[1] = 'asdf' |
64bef59f11ef
patch 8.2.3064: Vim9: in script cannot set item in uninitialized list
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
1603 assert_equal('value', l[0]) |
64bef59f11ef
patch 8.2.3064: Vim9: in script cannot set item in uninitialized list
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
1604 assert_equal('asdf', l[1]) |
64bef59f11ef
patch 8.2.3064: Vim9: in script cannot set item in uninitialized list
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
1605 assert_equal('asdf', l[-1]) |
64bef59f11ef
patch 8.2.3064: Vim9: in script cannot set item in uninitialized list
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
1606 assert_equal('value', l[-2]) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1607 |
25054
64bef59f11ef
patch 8.2.3064: Vim9: in script cannot set item in uninitialized list
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
1608 var nrl: list<number> = [] |
64bef59f11ef
patch 8.2.3064: Vim9: in script cannot set item in uninitialized list
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
1609 for i in range(5) |
64bef59f11ef
patch 8.2.3064: Vim9: in script cannot set item in uninitialized list
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
1610 nrl[i] = i |
64bef59f11ef
patch 8.2.3064: Vim9: in script cannot set item in uninitialized list
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
1611 endfor |
64bef59f11ef
patch 8.2.3064: Vim9: in script cannot set item in uninitialized list
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
1612 assert_equal([0, 1, 2, 3, 4], nrl) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1613 |
25054
64bef59f11ef
patch 8.2.3064: Vim9: in script cannot set item in uninitialized list
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
1614 var ul: list<any> |
64bef59f11ef
patch 8.2.3064: Vim9: in script cannot set item in uninitialized list
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
1615 ul[0] = 1 |
64bef59f11ef
patch 8.2.3064: Vim9: in script cannot set item in uninitialized list
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
1616 ul[1] = 2 |
64bef59f11ef
patch 8.2.3064: Vim9: in script cannot set item in uninitialized list
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
1617 ul[2] = 3 |
64bef59f11ef
patch 8.2.3064: Vim9: in script cannot set item in uninitialized list
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
1618 assert_equal([1, 2, 3], ul) |
64bef59f11ef
patch 8.2.3064: Vim9: in script cannot set item in uninitialized list
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
1619 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1620 v9.CheckDefAndScriptSuccess(lines) |
22631
59cd5f8b2ab2
patch 8.2.1864: Vim9: no error for wrong list type
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
1621 |
27918
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1622 lines =<< trim END |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1623 var l = [1, 2] |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1624 g:idx = 'x' |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1625 l[g:idx : 1] = [0] |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1626 echo l |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1627 END |
28131
d8bf200cd761
patch 8.2.4590: Vim9: range type check has wrong offset
Bram Moolenaar <Bram@vim.org>
parents:
28129
diff
changeset
|
1628 v9.CheckDefExecAndScriptFailure(lines, ['E1012: Type mismatch; expected number but got string', 'E1030: Using a String as a Number: "x"']) |
27918
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1629 |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1630 lines =<< trim END |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1631 var l = [1, 2] |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1632 g:idx = 3 |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1633 l[g:idx : 1] = [0] |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1634 echo l |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1635 END |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1636 v9.CheckDefExecAndScriptFailure(lines, 'E684: list index out of range: 3') |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1637 |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1638 lines =<< trim END |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1639 var l = [1, 2] |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1640 g:idx = 'y' |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1641 l[1 : g:idx] = [0] |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1642 echo l |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1643 END |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1644 v9.CheckDefExecAndScriptFailure(lines, ['E1012: Type mismatch; expected number but got string', 'E1030: Using a String as a Number: "y"']) |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27843
diff
changeset
|
1645 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1646 v9.CheckDefFailure(["var l: list<number> = ['', true]"], 'E1012: Type mismatch; expected list<number> but got list<any>', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1647 v9.CheckDefFailure(["var l: list<list<number>> = [['', true]]"], 'E1012: Type mismatch; expected list<list<number>> but got list<list<any>>', 1) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1648 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1649 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1650 def Test_assign_dict() |
23448
8f31b990ab1e
patch 8.2.2267: Vim9: cannot use unlet for a dict member
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
1651 var lines =<< trim END |
8f31b990ab1e
patch 8.2.2267: Vim9: cannot use unlet for a dict member
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
1652 var d: dict<string> = {} |
8f31b990ab1e
patch 8.2.2267: Vim9: cannot use unlet for a dict member
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
1653 d['key'] = 'value' |
8f31b990ab1e
patch 8.2.2267: Vim9: cannot use unlet for a dict member
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
1654 assert_equal('value', d['key']) |
8f31b990ab1e
patch 8.2.2267: Vim9: cannot use unlet for a dict member
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
1655 |
8f31b990ab1e
patch 8.2.2267: Vim9: cannot use unlet for a dict member
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
1656 d[123] = 'qwerty' |
8f31b990ab1e
patch 8.2.2267: Vim9: cannot use unlet for a dict member
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
1657 assert_equal('qwerty', d[123]) |
8f31b990ab1e
patch 8.2.2267: Vim9: cannot use unlet for a dict member
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
1658 assert_equal('qwerty', d['123']) |
8f31b990ab1e
patch 8.2.2267: Vim9: cannot use unlet for a dict member
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
1659 |
8f31b990ab1e
patch 8.2.2267: Vim9: cannot use unlet for a dict member
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
1660 var nrd: dict<number> = {} |
8f31b990ab1e
patch 8.2.2267: Vim9: cannot use unlet for a dict member
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
1661 for i in range(3) |
8f31b990ab1e
patch 8.2.2267: Vim9: cannot use unlet for a dict member
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
1662 nrd[i] = i |
8f31b990ab1e
patch 8.2.2267: Vim9: cannot use unlet for a dict member
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
1663 endfor |
8f31b990ab1e
patch 8.2.2267: Vim9: cannot use unlet for a dict member
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
1664 assert_equal({0: 0, 1: 1, 2: 2}, nrd) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1665 |
23448
8f31b990ab1e
patch 8.2.2267: Vim9: cannot use unlet for a dict member
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
1666 d.somekey = 'someval' |
8f31b990ab1e
patch 8.2.2267: Vim9: cannot use unlet for a dict member
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
1667 assert_equal({key: 'value', '123': 'qwerty', somekey: 'someval'}, d) |
25489
911fdca7f736
patch 8.2.3281: Vim9: TODO items in tests can be taken care of
Bram Moolenaar <Bram@vim.org>
parents:
25483
diff
changeset
|
1668 unlet d.somekey |
911fdca7f736
patch 8.2.3281: Vim9: TODO items in tests can be taken care of
Bram Moolenaar <Bram@vim.org>
parents:
25483
diff
changeset
|
1669 assert_equal({key: 'value', '123': 'qwerty'}, d) |
23448
8f31b990ab1e
patch 8.2.2267: Vim9: cannot use unlet for a dict member
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
1670 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1671 v9.CheckDefAndScriptSuccess(lines) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1672 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1673 v9.CheckDefFailure(["var d: dict<number> = {a: '', b: true}"], 'E1012: Type mismatch; expected dict<number> but got dict<any>', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1674 v9.CheckDefFailure(["var d: dict<dict<number>> = {x: {a: '', b: true}}"], 'E1012: Type mismatch; expected dict<dict<number>> but got dict<dict<any>>', 1) |
27716
4097434c7c67
patch 8.2.4384: Vim9: error message not tested, some code not tested
Bram Moolenaar <Bram@vim.org>
parents:
27669
diff
changeset
|
1675 v9.CheckDefFailure(["var d = {x: 1}", "d[1 : 2] = {y: 2}"], 'E1165: Cannot use a range with an assignment: d[1 : 2] =', 2) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1676 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1677 |
22363
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
1678 def Test_assign_dict_unknown_type() |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1679 var lines =<< trim END |
22363
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
1680 vim9script |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1681 var mylist = [] |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
1682 mylist += [{one: 'one'}] |
22363
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
1683 def Func() |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1684 var dd = mylist[0] |
22363
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
1685 assert_equal('one', dd.one) |
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
1686 enddef |
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
1687 Func() |
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
1688 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1689 v9.CheckScriptSuccess(lines) |
22363
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
1690 |
23039
75241f4377a4
patch 8.2.2066: Vim9: assignment with += doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23033
diff
changeset
|
1691 lines =<< trim END |
75241f4377a4
patch 8.2.2066: Vim9: assignment with += doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23033
diff
changeset
|
1692 vim9script |
75241f4377a4
patch 8.2.2066: Vim9: assignment with += doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23033
diff
changeset
|
1693 var mylist = [[]] |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23070
diff
changeset
|
1694 mylist[0] += [{one: 'one'}] |
23039
75241f4377a4
patch 8.2.2066: Vim9: assignment with += doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23033
diff
changeset
|
1695 def Func() |
75241f4377a4
patch 8.2.2066: Vim9: assignment with += doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23033
diff
changeset
|
1696 var dd = mylist[0][0] |
75241f4377a4
patch 8.2.2066: Vim9: assignment with += doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23033
diff
changeset
|
1697 assert_equal('one', dd.one) |
75241f4377a4
patch 8.2.2066: Vim9: assignment with += doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23033
diff
changeset
|
1698 enddef |
75241f4377a4
patch 8.2.2066: Vim9: assignment with += doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23033
diff
changeset
|
1699 Func() |
75241f4377a4
patch 8.2.2066: Vim9: assignment with += doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23033
diff
changeset
|
1700 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1701 v9.CheckScriptSuccess(lines) |
22363
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
1702 enddef |
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
1703 |
24047
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1704 def Test_assign_dict_with_op() |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1705 var lines =<< trim END |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1706 var ds: dict<string> = {a: 'x'} |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1707 ds['a'] ..= 'y' |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1708 ds.a ..= 'z' |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1709 assert_equal('xyz', ds.a) |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1710 |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1711 var dn: dict<number> = {a: 9} |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1712 dn['a'] += 2 |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1713 assert_equal(11, dn.a) |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1714 dn.a += 2 |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1715 assert_equal(13, dn.a) |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1716 |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1717 dn['a'] -= 3 |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1718 assert_equal(10, dn.a) |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1719 dn.a -= 2 |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1720 assert_equal(8, dn.a) |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1721 |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1722 dn['a'] *= 2 |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1723 assert_equal(16, dn.a) |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1724 dn.a *= 2 |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1725 assert_equal(32, dn.a) |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1726 |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1727 dn['a'] /= 3 |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1728 assert_equal(10, dn.a) |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1729 dn.a /= 2 |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1730 assert_equal(5, dn.a) |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1731 |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1732 dn['a'] %= 3 |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1733 assert_equal(2, dn.a) |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1734 dn.a %= 6 |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1735 assert_equal(2, dn.a) |
24363
1a145eb83a28
patch 8.2.2722: Vim9: crash when using LHS with double index
Bram Moolenaar <Bram@vim.org>
parents:
24357
diff
changeset
|
1736 |
1a145eb83a28
patch 8.2.2722: Vim9: crash when using LHS with double index
Bram Moolenaar <Bram@vim.org>
parents:
24357
diff
changeset
|
1737 var dd: dict<dict<list<any>>> |
1a145eb83a28
patch 8.2.2722: Vim9: crash when using LHS with double index
Bram Moolenaar <Bram@vim.org>
parents:
24357
diff
changeset
|
1738 dd.a = {} |
1a145eb83a28
patch 8.2.2722: Vim9: crash when using LHS with double index
Bram Moolenaar <Bram@vim.org>
parents:
24357
diff
changeset
|
1739 dd.a.b = [0] |
1a145eb83a28
patch 8.2.2722: Vim9: crash when using LHS with double index
Bram Moolenaar <Bram@vim.org>
parents:
24357
diff
changeset
|
1740 dd.a.b += [1] |
1a145eb83a28
patch 8.2.2722: Vim9: crash when using LHS with double index
Bram Moolenaar <Bram@vim.org>
parents:
24357
diff
changeset
|
1741 assert_equal({a: {b: [0, 1]}}, dd) |
24367
95b8937804d3
patch 8.2.2724: Vim9: concatenating to list in dict not tested
Bram Moolenaar <Bram@vim.org>
parents:
24363
diff
changeset
|
1742 |
95b8937804d3
patch 8.2.2724: Vim9: concatenating to list in dict not tested
Bram Moolenaar <Bram@vim.org>
parents:
24363
diff
changeset
|
1743 var dab = {a: ['b']} |
95b8937804d3
patch 8.2.2724: Vim9: concatenating to list in dict not tested
Bram Moolenaar <Bram@vim.org>
parents:
24363
diff
changeset
|
1744 dab.a[0] ..= 'c' |
95b8937804d3
patch 8.2.2724: Vim9: concatenating to list in dict not tested
Bram Moolenaar <Bram@vim.org>
parents:
24363
diff
changeset
|
1745 assert_equal({a: ['bc']}, dab) |
24047
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1746 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1747 v9.CheckDefAndScriptSuccess(lines) |
24357
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1748 enddef |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1749 |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1750 def Test_assign_list_with_op() |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1751 var lines =<< trim END |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1752 var ls: list<string> = ['x'] |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1753 ls[0] ..= 'y' |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1754 assert_equal('xy', ls[0]) |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1755 |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1756 var ln: list<number> = [9] |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1757 ln[0] += 2 |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1758 assert_equal(11, ln[0]) |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1759 |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1760 ln[0] -= 3 |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1761 assert_equal(8, ln[0]) |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1762 |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1763 ln[0] *= 2 |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1764 assert_equal(16, ln[0]) |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1765 |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1766 ln[0] /= 3 |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1767 assert_equal(5, ln[0]) |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1768 |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1769 ln[0] %= 3 |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1770 assert_equal(2, ln[0]) |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1771 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1772 v9.CheckDefAndScriptSuccess(lines) |
24357
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1773 enddef |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1774 |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1775 def Test_assign_with_op_fails() |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1776 var lines =<< trim END |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1777 var s = 'abc' |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1778 s[1] += 'x' |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1779 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1780 v9.CheckDefAndScriptFailure(lines, ['E1141:', 'E689:'], 2) |
24357
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1781 |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1782 lines =<< trim END |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1783 var s = 'abc' |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1784 s[1] ..= 'x' |
108a6e2497f6
patch 8.2.2719: Vim9: appending to dict item doesn't work in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24329
diff
changeset
|
1785 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1786 v9.CheckDefAndScriptFailure(lines, ['E1141:', 'E689:'], 2) |
24363
1a145eb83a28
patch 8.2.2722: Vim9: crash when using LHS with double index
Bram Moolenaar <Bram@vim.org>
parents:
24357
diff
changeset
|
1787 |
1a145eb83a28
patch 8.2.2722: Vim9: crash when using LHS with double index
Bram Moolenaar <Bram@vim.org>
parents:
24357
diff
changeset
|
1788 lines =<< trim END |
1a145eb83a28
patch 8.2.2722: Vim9: crash when using LHS with double index
Bram Moolenaar <Bram@vim.org>
parents:
24357
diff
changeset
|
1789 var dd: dict<dict<list<any>>> |
1a145eb83a28
patch 8.2.2722: Vim9: crash when using LHS with double index
Bram Moolenaar <Bram@vim.org>
parents:
24357
diff
changeset
|
1790 dd.a = {} |
1a145eb83a28
patch 8.2.2722: Vim9: crash when using LHS with double index
Bram Moolenaar <Bram@vim.org>
parents:
24357
diff
changeset
|
1791 dd.a.b += [1] |
1a145eb83a28
patch 8.2.2722: Vim9: crash when using LHS with double index
Bram Moolenaar <Bram@vim.org>
parents:
24357
diff
changeset
|
1792 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1793 v9.CheckDefExecAndScriptFailure(lines, 'E716:', 3) |
24047
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1794 enddef |
b535ab17d160
patch 8.2.2565: Vim9: "..=" not always recognized
Bram Moolenaar <Bram@vim.org>
parents:
23982
diff
changeset
|
1795 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1796 def Test_assign_lambda() |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1797 # check if assign a lambda to a variable which type is func or any. |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
1798 var lines =<< trim END |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1799 vim9script |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23422
diff
changeset
|
1800 var FuncRef = () => 123 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1801 assert_equal(123, FuncRef()) |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23422
diff
changeset
|
1802 var FuncRef_Func: func = () => 123 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1803 assert_equal(123, FuncRef_Func()) |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23422
diff
changeset
|
1804 var FuncRef_Any: any = () => 123 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1805 assert_equal(123, FuncRef_Any()) |
23970
ba79ceac82ec
patch 8.2.2527: Vim9: lambda return type is not determined at script level
Bram Moolenaar <Bram@vim.org>
parents:
23917
diff
changeset
|
1806 var FuncRef_Number: func(): number = () => 321 |
ba79ceac82ec
patch 8.2.2527: Vim9: lambda return type is not determined at script level
Bram Moolenaar <Bram@vim.org>
parents:
23917
diff
changeset
|
1807 assert_equal(321, FuncRef_Number()) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1808 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1809 v9.CheckScriptSuccess(lines) |
23531
f39a18a42aed
patch 8.2.2308: Vim9: no error when assigning lambda to funcref
Bram Moolenaar <Bram@vim.org>
parents:
23523
diff
changeset
|
1810 |
f39a18a42aed
patch 8.2.2308: Vim9: no error when assigning lambda to funcref
Bram Moolenaar <Bram@vim.org>
parents:
23523
diff
changeset
|
1811 lines =<< trim END |
f39a18a42aed
patch 8.2.2308: Vim9: no error when assigning lambda to funcref
Bram Moolenaar <Bram@vim.org>
parents:
23523
diff
changeset
|
1812 var Ref: func(number) |
f39a18a42aed
patch 8.2.2308: Vim9: no error when assigning lambda to funcref
Bram Moolenaar <Bram@vim.org>
parents:
23523
diff
changeset
|
1813 Ref = (j) => !j |
f39a18a42aed
patch 8.2.2308: Vim9: no error when assigning lambda to funcref
Bram Moolenaar <Bram@vim.org>
parents:
23523
diff
changeset
|
1814 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1815 v9.CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected func(number) but got func(any): bool') |
23972
a620df0ebbe5
patch 8.2.2528: Vim9: crash when compiling lambda fails
Bram Moolenaar <Bram@vim.org>
parents:
23970
diff
changeset
|
1816 |
a620df0ebbe5
patch 8.2.2528: Vim9: crash when compiling lambda fails
Bram Moolenaar <Bram@vim.org>
parents:
23970
diff
changeset
|
1817 lines =<< trim END |
a620df0ebbe5
patch 8.2.2528: Vim9: crash when compiling lambda fails
Bram Moolenaar <Bram@vim.org>
parents:
23970
diff
changeset
|
1818 echo filter([1, 2, 3], (_, v: string) => v + 1) |
a620df0ebbe5
patch 8.2.2528: Vim9: crash when compiling lambda fails
Bram Moolenaar <Bram@vim.org>
parents:
23970
diff
changeset
|
1819 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1820 v9.CheckDefAndScriptFailure(lines, 'E1051:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1821 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1822 |
22413
66d1131a7eff
patch 8.2.1755: Vim9: crash when using invalid heredoc marker
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
1823 def Test_heredoc() |
28560
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
1824 # simple heredoc |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
1825 var lines =<< trim END |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
1826 var text =<< trim TEXT # comment |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
1827 abc |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
1828 TEXT |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
1829 assert_equal(['abc'], text) |
22413
66d1131a7eff
patch 8.2.1755: Vim9: crash when using invalid heredoc marker
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
1830 END |
28560
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
1831 v9.CheckDefAndScriptSuccess(lines) |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
1832 |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
1833 # empty heredoc |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
1834 lines =<< trim END |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
1835 var text =<< trim TEXT |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
1836 TEXT |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
1837 assert_equal([], text) |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
1838 END |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
1839 v9.CheckDefAndScriptSuccess(lines) |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
1840 |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
1841 # heredoc with a single empty line |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
1842 lines =<< trim END |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
1843 var text =<< trim TEXT |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
1844 |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
1845 TEXT |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
1846 assert_equal([''], text) |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
1847 END |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
1848 v9.CheckDefAndScriptSuccess(lines) |
22413
66d1131a7eff
patch 8.2.1755: Vim9: crash when using invalid heredoc marker
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
1849 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1850 v9.CheckDefFailure(['var lines =<< trim END X', 'END'], 'E488:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1851 v9.CheckDefFailure(['var lines =<< trim END " comment', 'END'], 'E488:') |
22423
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
1852 |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
1853 lines =<< trim [END] |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
1854 def Func() |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
1855 var&lines =<< trim END |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
1856 x |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
1857 x |
23185
055fa9db6f39
patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
23138
diff
changeset
|
1858 enddef |
055fa9db6f39
patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
23138
diff
changeset
|
1859 defcompile |
055fa9db6f39
patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
23138
diff
changeset
|
1860 [END] |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1861 v9.CheckScriptFailure(lines, 'E1145: Missing heredoc end marker: END') |
23185
055fa9db6f39
patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
23138
diff
changeset
|
1862 delfunc! g:Func |
055fa9db6f39
patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
23138
diff
changeset
|
1863 |
055fa9db6f39
patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
23138
diff
changeset
|
1864 lines =<< trim [END] |
055fa9db6f39
patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
23138
diff
changeset
|
1865 def Func() |
055fa9db6f39
patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
23138
diff
changeset
|
1866 var lines =<< trim END |
055fa9db6f39
patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
23138
diff
changeset
|
1867 x |
055fa9db6f39
patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents:
23138
diff
changeset
|
1868 x |
22423
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
1869 x |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
1870 x |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
1871 x |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
1872 x |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
1873 x |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
1874 x |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
1875 enddef |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
1876 call Func() |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
1877 [END] |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1878 v9.CheckScriptFailure(lines, 'E1145: Missing heredoc end marker: END') |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
1879 delfunc! g:Func |
25405
747ebbce2421
patch 8.2.3239: Vim9: no error using heredoc for a number variable
Bram Moolenaar <Bram@vim.org>
parents:
25400
diff
changeset
|
1880 |
747ebbce2421
patch 8.2.3239: Vim9: no error using heredoc for a number variable
Bram Moolenaar <Bram@vim.org>
parents:
25400
diff
changeset
|
1881 lines =<< trim END |
747ebbce2421
patch 8.2.3239: Vim9: no error using heredoc for a number variable
Bram Moolenaar <Bram@vim.org>
parents:
25400
diff
changeset
|
1882 var lines: number =<< trim STOP |
747ebbce2421
patch 8.2.3239: Vim9: no error using heredoc for a number variable
Bram Moolenaar <Bram@vim.org>
parents:
25400
diff
changeset
|
1883 aaa |
747ebbce2421
patch 8.2.3239: Vim9: no error using heredoc for a number variable
Bram Moolenaar <Bram@vim.org>
parents:
25400
diff
changeset
|
1884 bbb |
747ebbce2421
patch 8.2.3239: Vim9: no error using heredoc for a number variable
Bram Moolenaar <Bram@vim.org>
parents:
25400
diff
changeset
|
1885 STOP |
747ebbce2421
patch 8.2.3239: Vim9: no error using heredoc for a number variable
Bram Moolenaar <Bram@vim.org>
parents:
25400
diff
changeset
|
1886 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1887 v9.CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected number but got list<string>', 1) |
22413
66d1131a7eff
patch 8.2.1755: Vim9: crash when using invalid heredoc marker
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
1888 enddef |
66d1131a7eff
patch 8.2.1755: Vim9: crash when using invalid heredoc marker
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
1889 |
23124
f8cd5a5e03c4
patch 8.2.2108: Vim9: no test to check for :let error
Bram Moolenaar <Bram@vim.org>
parents:
23122
diff
changeset
|
1890 def Test_var_func_call() |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1891 var lines =<< trim END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1892 vim9script |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1893 func GetValue() |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1894 if exists('g:count') |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1895 let g:count += 1 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1896 else |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1897 let g:count = 1 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1898 endif |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1899 return 'this' |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1900 endfunc |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1901 var val: string = GetValue() |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1902 # env var is always a string |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1903 var env = $TERM |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1904 END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1905 writefile(lines, 'Xfinished') |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1906 source Xfinished |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1907 # GetValue() is not called during discovery phase |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1908 assert_equal(1, g:count) |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1909 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1910 unlet g:count |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1911 delete('Xfinished') |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1912 enddef |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1913 |
23124
f8cd5a5e03c4
patch 8.2.2108: Vim9: no test to check for :let error
Bram Moolenaar <Bram@vim.org>
parents:
23122
diff
changeset
|
1914 def Test_var_missing_type() |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1915 var lines =<< trim END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1916 vim9script |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1917 var name = g:unknown |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1918 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1919 v9.CheckScriptFailure(lines, 'E121:') |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1920 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1921 lines =<< trim END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1922 vim9script |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1923 var nr: number = 123 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1924 var name = nr |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1925 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1926 v9.CheckScriptSuccess(lines) |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1927 enddef |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1928 |
23124
f8cd5a5e03c4
patch 8.2.2108: Vim9: no test to check for :let error
Bram Moolenaar <Bram@vim.org>
parents:
23122
diff
changeset
|
1929 def Test_var_declaration() |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1930 var lines =<< trim END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1931 vim9script |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1932 var name: string |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1933 g:var_uninit = name |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1934 name = 'text' |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1935 g:var_test = name |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
1936 # prefixing s: is not allowed |
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
1937 name = 'prefixed' |
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
1938 g:var_prefixed = name |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1939 |
23138
1a9705075244
patch 8.2.2115: Vim9: some errors not tested for; dead code
Bram Moolenaar <Bram@vim.org>
parents:
23124
diff
changeset
|
1940 const FOO: number = 123 |
1a9705075244
patch 8.2.2115: Vim9: some errors not tested for; dead code
Bram Moolenaar <Bram@vim.org>
parents:
23124
diff
changeset
|
1941 assert_equal(123, FOO) |
23297
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1942 const FOOS = 'foos' |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1943 assert_equal('foos', FOOS) |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1944 final FLIST = [1] |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1945 assert_equal([1], FLIST) |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1946 FLIST[0] = 11 |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1947 assert_equal([11], FLIST) |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1948 |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1949 const g:FOO: number = 321 |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1950 assert_equal(321, g:FOO) |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1951 const g:FOOS = 'gfoos' |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1952 assert_equal('gfoos', g:FOOS) |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1953 final g:FLIST = [2] |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1954 assert_equal([2], g:FLIST) |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1955 g:FLIST[0] = 22 |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1956 assert_equal([22], g:FLIST) |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1957 |
24293
bbf4b3185554
patch 8.2.2687: Vim9: cannot use "const" for global variable in :def function
Bram Moolenaar <Bram@vim.org>
parents:
24264
diff
changeset
|
1958 def SetGlobalConst() |
bbf4b3185554
patch 8.2.2687: Vim9: cannot use "const" for global variable in :def function
Bram Moolenaar <Bram@vim.org>
parents:
24264
diff
changeset
|
1959 const g:globConst = 123 |
bbf4b3185554
patch 8.2.2687: Vim9: cannot use "const" for global variable in :def function
Bram Moolenaar <Bram@vim.org>
parents:
24264
diff
changeset
|
1960 enddef |
bbf4b3185554
patch 8.2.2687: Vim9: cannot use "const" for global variable in :def function
Bram Moolenaar <Bram@vim.org>
parents:
24264
diff
changeset
|
1961 SetGlobalConst() |
bbf4b3185554
patch 8.2.2687: Vim9: cannot use "const" for global variable in :def function
Bram Moolenaar <Bram@vim.org>
parents:
24264
diff
changeset
|
1962 assert_equal(123, g:globConst) |
bbf4b3185554
patch 8.2.2687: Vim9: cannot use "const" for global variable in :def function
Bram Moolenaar <Bram@vim.org>
parents:
24264
diff
changeset
|
1963 assert_true(islocked('g:globConst')) |
bbf4b3185554
patch 8.2.2687: Vim9: cannot use "const" for global variable in :def function
Bram Moolenaar <Bram@vim.org>
parents:
24264
diff
changeset
|
1964 |
23297
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1965 const w:FOO: number = 46 |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1966 assert_equal(46, w:FOO) |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1967 const w:FOOS = 'wfoos' |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1968 assert_equal('wfoos', w:FOOS) |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1969 final w:FLIST = [3] |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1970 assert_equal([3], w:FLIST) |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1971 w:FLIST[0] = 33 |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
1972 assert_equal([33], w:FLIST) |
23138
1a9705075244
patch 8.2.2115: Vim9: some errors not tested for; dead code
Bram Moolenaar <Bram@vim.org>
parents:
23124
diff
changeset
|
1973 |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1974 var s:other: number |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1975 other = 1234 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1976 g:other_var = other |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1977 |
24238
e5cd25f7ffcd
patch 8.2.2660: Vim9: no error for declaration with trailing text
Bram Moolenaar <Bram@vim.org>
parents:
24154
diff
changeset
|
1978 var xyz: string # comment |
e5cd25f7ffcd
patch 8.2.2660: Vim9: no error for declaration with trailing text
Bram Moolenaar <Bram@vim.org>
parents:
24154
diff
changeset
|
1979 |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1980 # type is inferred |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
1981 var dict = {['a']: 222} |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1982 def GetDictVal(key: any) |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
1983 g:dict_val = dict[key] |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1984 enddef |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1985 GetDictVal('a') |
23578
85ce241ff9e3
patch 8.2.2331: Vim9: wrong error when modifying dict declared with :final
Bram Moolenaar <Bram@vim.org>
parents:
23549
diff
changeset
|
1986 |
85ce241ff9e3
patch 8.2.2331: Vim9: wrong error when modifying dict declared with :final
Bram Moolenaar <Bram@vim.org>
parents:
23549
diff
changeset
|
1987 final adict: dict<string> = {} |
85ce241ff9e3
patch 8.2.2331: Vim9: wrong error when modifying dict declared with :final
Bram Moolenaar <Bram@vim.org>
parents:
23549
diff
changeset
|
1988 def ChangeAdict() |
85ce241ff9e3
patch 8.2.2331: Vim9: wrong error when modifying dict declared with :final
Bram Moolenaar <Bram@vim.org>
parents:
23549
diff
changeset
|
1989 adict.foo = 'foo' |
85ce241ff9e3
patch 8.2.2331: Vim9: wrong error when modifying dict declared with :final
Bram Moolenaar <Bram@vim.org>
parents:
23549
diff
changeset
|
1990 enddef |
85ce241ff9e3
patch 8.2.2331: Vim9: wrong error when modifying dict declared with :final
Bram Moolenaar <Bram@vim.org>
parents:
23549
diff
changeset
|
1991 ChangeAdict() |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1992 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
1993 v9.CheckScriptSuccess(lines) |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1994 assert_equal('', g:var_uninit) |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1995 assert_equal('text', g:var_test) |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1996 assert_equal('prefixed', g:var_prefixed) |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1997 assert_equal(1234, g:other_var) |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1998 assert_equal(222, g:dict_val) |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
1999 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2000 unlet g:var_uninit |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2001 unlet g:var_test |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2002 unlet g:var_prefixed |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2003 unlet g:other_var |
24325
52a0e187264b
patch 8.2.2703: Vim9: memory leak when failing on locked variable
Bram Moolenaar <Bram@vim.org>
parents:
24305
diff
changeset
|
2004 unlet g:globConst |
23297
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
2005 unlet g:FOO |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
2006 unlet g:FOOS |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
2007 unlet g:FLIST |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
2008 unlet w:FOO |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
2009 unlet w:FOOS |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
2010 unlet w:FLIST |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2011 enddef |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2012 |
23124
f8cd5a5e03c4
patch 8.2.2108: Vim9: no test to check for :let error
Bram Moolenaar <Bram@vim.org>
parents:
23122
diff
changeset
|
2013 def Test_var_declaration_fails() |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2014 var lines =<< trim END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2015 vim9script |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2016 final var: string |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2017 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2018 v9.CheckScriptFailure(lines, 'E1125:') |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2019 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2020 lines =<< trim END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2021 vim9script |
23297
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
2022 const g:constvar = 'string' |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
2023 g:constvar = 'xx' |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
2024 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2025 v9.CheckScriptFailure(lines, 'E741:') |
23297
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
2026 unlet g:constvar |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
2027 |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
2028 lines =<< trim END |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
2029 vim9script |
24303
17b49af76766
patch 8.2.2692: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24293
diff
changeset
|
2030 var name = 'one' |
17b49af76766
patch 8.2.2692: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24293
diff
changeset
|
2031 lockvar name |
17b49af76766
patch 8.2.2692: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24293
diff
changeset
|
2032 def SetLocked() |
17b49af76766
patch 8.2.2692: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24293
diff
changeset
|
2033 name = 'two' |
17b49af76766
patch 8.2.2692: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24293
diff
changeset
|
2034 enddef |
17b49af76766
patch 8.2.2692: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24293
diff
changeset
|
2035 SetLocked() |
17b49af76766
patch 8.2.2692: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24293
diff
changeset
|
2036 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2037 v9.CheckScriptFailure(lines, 'E741: Value is locked: name', 1) |
24305
c88d0b5c5a42
patch 8.2.2693: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24303
diff
changeset
|
2038 |
c88d0b5c5a42
patch 8.2.2693: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24303
diff
changeset
|
2039 lines =<< trim END |
c88d0b5c5a42
patch 8.2.2693: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24303
diff
changeset
|
2040 let s:legacy = 'one' |
c88d0b5c5a42
patch 8.2.2693: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24303
diff
changeset
|
2041 lockvar s:legacy |
c88d0b5c5a42
patch 8.2.2693: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24303
diff
changeset
|
2042 def SetLocked() |
c88d0b5c5a42
patch 8.2.2693: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24303
diff
changeset
|
2043 s:legacy = 'two' |
c88d0b5c5a42
patch 8.2.2693: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24303
diff
changeset
|
2044 enddef |
c88d0b5c5a42
patch 8.2.2693: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24303
diff
changeset
|
2045 call SetLocked() |
c88d0b5c5a42
patch 8.2.2693: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24303
diff
changeset
|
2046 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2047 v9.CheckScriptFailure(lines, 'E741: Value is locked: s:legacy', 1) |
24303
17b49af76766
patch 8.2.2692: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24293
diff
changeset
|
2048 |
17b49af76766
patch 8.2.2692: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24293
diff
changeset
|
2049 lines =<< trim END |
17b49af76766
patch 8.2.2692: Vim9: locked script variable can be changed
Bram Moolenaar <Bram@vim.org>
parents:
24293
diff
changeset
|
2050 vim9script |
24293
bbf4b3185554
patch 8.2.2687: Vim9: cannot use "const" for global variable in :def function
Bram Moolenaar <Bram@vim.org>
parents:
24264
diff
changeset
|
2051 def SetGlobalConst() |
bbf4b3185554
patch 8.2.2687: Vim9: cannot use "const" for global variable in :def function
Bram Moolenaar <Bram@vim.org>
parents:
24264
diff
changeset
|
2052 const g:globConst = 123 |
bbf4b3185554
patch 8.2.2687: Vim9: cannot use "const" for global variable in :def function
Bram Moolenaar <Bram@vim.org>
parents:
24264
diff
changeset
|
2053 enddef |
bbf4b3185554
patch 8.2.2687: Vim9: cannot use "const" for global variable in :def function
Bram Moolenaar <Bram@vim.org>
parents:
24264
diff
changeset
|
2054 SetGlobalConst() |
bbf4b3185554
patch 8.2.2687: Vim9: cannot use "const" for global variable in :def function
Bram Moolenaar <Bram@vim.org>
parents:
24264
diff
changeset
|
2055 g:globConst = 234 |
bbf4b3185554
patch 8.2.2687: Vim9: cannot use "const" for global variable in :def function
Bram Moolenaar <Bram@vim.org>
parents:
24264
diff
changeset
|
2056 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2057 v9.CheckScriptFailure(lines, 'E741: Value is locked: g:globConst', 6) |
24293
bbf4b3185554
patch 8.2.2687: Vim9: cannot use "const" for global variable in :def function
Bram Moolenaar <Bram@vim.org>
parents:
24264
diff
changeset
|
2058 unlet g:globConst |
bbf4b3185554
patch 8.2.2687: Vim9: cannot use "const" for global variable in :def function
Bram Moolenaar <Bram@vim.org>
parents:
24264
diff
changeset
|
2059 |
bbf4b3185554
patch 8.2.2687: Vim9: cannot use "const" for global variable in :def function
Bram Moolenaar <Bram@vim.org>
parents:
24264
diff
changeset
|
2060 lines =<< trim END |
bbf4b3185554
patch 8.2.2687: Vim9: cannot use "const" for global variable in :def function
Bram Moolenaar <Bram@vim.org>
parents:
24264
diff
changeset
|
2061 vim9script |
23578
85ce241ff9e3
patch 8.2.2331: Vim9: wrong error when modifying dict declared with :final
Bram Moolenaar <Bram@vim.org>
parents:
23549
diff
changeset
|
2062 const cdict: dict<string> = {} |
85ce241ff9e3
patch 8.2.2331: Vim9: wrong error when modifying dict declared with :final
Bram Moolenaar <Bram@vim.org>
parents:
23549
diff
changeset
|
2063 def Change() |
85ce241ff9e3
patch 8.2.2331: Vim9: wrong error when modifying dict declared with :final
Bram Moolenaar <Bram@vim.org>
parents:
23549
diff
changeset
|
2064 cdict.foo = 'foo' |
85ce241ff9e3
patch 8.2.2331: Vim9: wrong error when modifying dict declared with :final
Bram Moolenaar <Bram@vim.org>
parents:
23549
diff
changeset
|
2065 enddef |
85ce241ff9e3
patch 8.2.2331: Vim9: wrong error when modifying dict declared with :final
Bram Moolenaar <Bram@vim.org>
parents:
23549
diff
changeset
|
2066 defcompile |
85ce241ff9e3
patch 8.2.2331: Vim9: wrong error when modifying dict declared with :final
Bram Moolenaar <Bram@vim.org>
parents:
23549
diff
changeset
|
2067 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2068 v9.CheckScriptFailure(lines, 'E46:') |
23578
85ce241ff9e3
patch 8.2.2331: Vim9: wrong error when modifying dict declared with :final
Bram Moolenaar <Bram@vim.org>
parents:
23549
diff
changeset
|
2069 |
85ce241ff9e3
patch 8.2.2331: Vim9: wrong error when modifying dict declared with :final
Bram Moolenaar <Bram@vim.org>
parents:
23549
diff
changeset
|
2070 lines =<< trim END |
85ce241ff9e3
patch 8.2.2331: Vim9: wrong error when modifying dict declared with :final
Bram Moolenaar <Bram@vim.org>
parents:
23549
diff
changeset
|
2071 vim9script |
23297
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
2072 final w:finalvar = [9] |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
2073 w:finalvar = [8] |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
2074 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2075 v9.CheckScriptFailure(lines, 'E1122:') |
23297
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
2076 unlet w:finalvar |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
2077 |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
2078 lines =<< trim END |
40f1d3f0c53e
patch 8.2.2194: Vim9: cannot use :const or :final at the script level
Bram Moolenaar <Bram@vim.org>
parents:
23266
diff
changeset
|
2079 vim9script |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2080 const var: string |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2081 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2082 v9.CheckScriptFailure(lines, 'E1021:') |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2083 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2084 lines =<< trim END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2085 vim9script |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2086 var 9var: string |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2087 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2088 v9.CheckScriptFailure(lines, 'E488:') |
23138
1a9705075244
patch 8.2.2115: Vim9: some errors not tested for; dead code
Bram Moolenaar <Bram@vim.org>
parents:
23124
diff
changeset
|
2089 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2090 v9.CheckDefFailure(['var foo.bar = 2'], 'E1087:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2091 v9.CheckDefFailure(['var foo[3] = 2'], 'E1087:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2092 v9.CheckDefFailure(['const foo: number'], 'E1021:') |
27968
40c6e5f849dc
patch 8.2.4509: Vim9: can declare a variable with ":va"
Bram Moolenaar <Bram@vim.org>
parents:
27950
diff
changeset
|
2093 |
40c6e5f849dc
patch 8.2.4509: Vim9: can declare a variable with ":va"
Bram Moolenaar <Bram@vim.org>
parents:
27950
diff
changeset
|
2094 lines =<< trim END |
40c6e5f849dc
patch 8.2.4509: Vim9: can declare a variable with ":va"
Bram Moolenaar <Bram@vim.org>
parents:
27950
diff
changeset
|
2095 va foo = 123 |
40c6e5f849dc
patch 8.2.4509: Vim9: can declare a variable with ":va"
Bram Moolenaar <Bram@vim.org>
parents:
27950
diff
changeset
|
2096 END |
40c6e5f849dc
patch 8.2.4509: Vim9: can declare a variable with ":va"
Bram Moolenaar <Bram@vim.org>
parents:
27950
diff
changeset
|
2097 v9.CheckDefAndScriptFailure(lines, 'E1065:', 1) |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2098 enddef |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2099 |
27728
fdc841530372
patch 8.2.4390: Vim9: list from declaration with inferred type not set
Bram Moolenaar <Bram@vim.org>
parents:
27716
diff
changeset
|
2100 def Test_var_declaration_inferred() |
fdc841530372
patch 8.2.4390: Vim9: list from declaration with inferred type not set
Bram Moolenaar <Bram@vim.org>
parents:
27716
diff
changeset
|
2101 # check that type is set on the list so that extend() fails |
fdc841530372
patch 8.2.4390: Vim9: list from declaration with inferred type not set
Bram Moolenaar <Bram@vim.org>
parents:
27716
diff
changeset
|
2102 var lines =<< trim END |
fdc841530372
patch 8.2.4390: Vim9: list from declaration with inferred type not set
Bram Moolenaar <Bram@vim.org>
parents:
27716
diff
changeset
|
2103 vim9script |
fdc841530372
patch 8.2.4390: Vim9: list from declaration with inferred type not set
Bram Moolenaar <Bram@vim.org>
parents:
27716
diff
changeset
|
2104 def GetList(): list<number> |
fdc841530372
patch 8.2.4390: Vim9: list from declaration with inferred type not set
Bram Moolenaar <Bram@vim.org>
parents:
27716
diff
changeset
|
2105 var l = [1, 2, 3] |
fdc841530372
patch 8.2.4390: Vim9: list from declaration with inferred type not set
Bram Moolenaar <Bram@vim.org>
parents:
27716
diff
changeset
|
2106 return l |
fdc841530372
patch 8.2.4390: Vim9: list from declaration with inferred type not set
Bram Moolenaar <Bram@vim.org>
parents:
27716
diff
changeset
|
2107 enddef |
fdc841530372
patch 8.2.4390: Vim9: list from declaration with inferred type not set
Bram Moolenaar <Bram@vim.org>
parents:
27716
diff
changeset
|
2108 echo GetList()->extend(['x']) |
fdc841530372
patch 8.2.4390: Vim9: list from declaration with inferred type not set
Bram Moolenaar <Bram@vim.org>
parents:
27716
diff
changeset
|
2109 END |
fdc841530372
patch 8.2.4390: Vim9: list from declaration with inferred type not set
Bram Moolenaar <Bram@vim.org>
parents:
27716
diff
changeset
|
2110 v9.CheckScriptFailure(lines, 'E1013:', 6) |
fdc841530372
patch 8.2.4390: Vim9: list from declaration with inferred type not set
Bram Moolenaar <Bram@vim.org>
parents:
27716
diff
changeset
|
2111 enddef |
fdc841530372
patch 8.2.4390: Vim9: list from declaration with inferred type not set
Bram Moolenaar <Bram@vim.org>
parents:
27716
diff
changeset
|
2112 |
24377
f9f8cceaece3
patch 8.2.2729: Vim9: wrong error message for referring to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
24367
diff
changeset
|
2113 def Test_script_local_in_legacy() |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
2114 # OK to define script-local later but before compiling |
24377
f9f8cceaece3
patch 8.2.2729: Vim9: wrong error message for referring to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
24367
diff
changeset
|
2115 var lines =<< trim END |
f9f8cceaece3
patch 8.2.2729: Vim9: wrong error message for referring to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
24367
diff
changeset
|
2116 def SetLater() |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
2117 legvar = 'two' |
24377
f9f8cceaece3
patch 8.2.2729: Vim9: wrong error message for referring to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
24367
diff
changeset
|
2118 enddef |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
2119 let s:legvar = 'one' |
24377
f9f8cceaece3
patch 8.2.2729: Vim9: wrong error message for referring to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
24367
diff
changeset
|
2120 defcompile |
f9f8cceaece3
patch 8.2.2729: Vim9: wrong error message for referring to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
24367
diff
changeset
|
2121 call SetLater() |
24531
3bfec39ce31c
patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24462
diff
changeset
|
2122 call assert_equal('two', s:legvar) |
24377
f9f8cceaece3
patch 8.2.2729: Vim9: wrong error message for referring to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
24367
diff
changeset
|
2123 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2124 v9.CheckScriptSuccess(lines) |
24377
f9f8cceaece3
patch 8.2.2729: Vim9: wrong error message for referring to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
24367
diff
changeset
|
2125 |
f9f8cceaece3
patch 8.2.2729: Vim9: wrong error message for referring to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
24367
diff
changeset
|
2126 # OK to leave out s: prefix when script-local already defined |
f9f8cceaece3
patch 8.2.2729: Vim9: wrong error message for referring to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
24367
diff
changeset
|
2127 lines =<< trim END |
24531
3bfec39ce31c
patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24462
diff
changeset
|
2128 let s:legvar = 'one' |
24377
f9f8cceaece3
patch 8.2.2729: Vim9: wrong error message for referring to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
24367
diff
changeset
|
2129 def SetNoPrefix() |
24531
3bfec39ce31c
patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24462
diff
changeset
|
2130 legvar = 'two' |
24377
f9f8cceaece3
patch 8.2.2729: Vim9: wrong error message for referring to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
24367
diff
changeset
|
2131 enddef |
f9f8cceaece3
patch 8.2.2729: Vim9: wrong error message for referring to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
24367
diff
changeset
|
2132 call SetNoPrefix() |
24531
3bfec39ce31c
patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24462
diff
changeset
|
2133 call assert_equal('two', s:legvar) |
24377
f9f8cceaece3
patch 8.2.2729: Vim9: wrong error message for referring to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
24367
diff
changeset
|
2134 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2135 v9.CheckScriptSuccess(lines) |
24377
f9f8cceaece3
patch 8.2.2729: Vim9: wrong error message for referring to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
24367
diff
changeset
|
2136 |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
2137 # Not OK to leave out s: prefix when script-local defined after compiling |
24377
f9f8cceaece3
patch 8.2.2729: Vim9: wrong error message for referring to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
24367
diff
changeset
|
2138 lines =<< trim END |
f9f8cceaece3
patch 8.2.2729: Vim9: wrong error message for referring to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
24367
diff
changeset
|
2139 def SetLaterNoPrefix() |
24531
3bfec39ce31c
patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24462
diff
changeset
|
2140 legvar = 'two' |
24377
f9f8cceaece3
patch 8.2.2729: Vim9: wrong error message for referring to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
24367
diff
changeset
|
2141 enddef |
f9f8cceaece3
patch 8.2.2729: Vim9: wrong error message for referring to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
24367
diff
changeset
|
2142 defcompile |
24531
3bfec39ce31c
patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24462
diff
changeset
|
2143 let s:legvar = 'one' |
24377
f9f8cceaece3
patch 8.2.2729: Vim9: wrong error message for referring to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
24367
diff
changeset
|
2144 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2145 v9.CheckScriptFailure(lines, 'E476:', 1) |
25274
84d5cda23b34
patch 8.2.3174: Vim9: "legacy undo" finds "undo" variable
Bram Moolenaar <Bram@vim.org>
parents:
25263
diff
changeset
|
2146 |
84d5cda23b34
patch 8.2.3174: Vim9: "legacy undo" finds "undo" variable
Bram Moolenaar <Bram@vim.org>
parents:
25263
diff
changeset
|
2147 edit! Xfile |
84d5cda23b34
patch 8.2.3174: Vim9: "legacy undo" finds "undo" variable
Bram Moolenaar <Bram@vim.org>
parents:
25263
diff
changeset
|
2148 lines =<< trim END |
84d5cda23b34
patch 8.2.3174: Vim9: "legacy undo" finds "undo" variable
Bram Moolenaar <Bram@vim.org>
parents:
25263
diff
changeset
|
2149 var edit: bool |
84d5cda23b34
patch 8.2.3174: Vim9: "legacy undo" finds "undo" variable
Bram Moolenaar <Bram@vim.org>
parents:
25263
diff
changeset
|
2150 legacy edit |
84d5cda23b34
patch 8.2.3174: Vim9: "legacy undo" finds "undo" variable
Bram Moolenaar <Bram@vim.org>
parents:
25263
diff
changeset
|
2151 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2152 v9.CheckDefAndScriptSuccess(lines) |
24377
f9f8cceaece3
patch 8.2.2729: Vim9: wrong error message for referring to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
24367
diff
changeset
|
2153 enddef |
f9f8cceaece3
patch 8.2.2729: Vim9: wrong error message for referring to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
24367
diff
changeset
|
2154 |
23124
f8cd5a5e03c4
patch 8.2.2108: Vim9: no test to check for :let error
Bram Moolenaar <Bram@vim.org>
parents:
23122
diff
changeset
|
2155 def Test_var_type_check() |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2156 var lines =<< trim END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2157 vim9script |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2158 var name: string |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2159 name = 1234 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2160 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2161 v9.CheckScriptFailure(lines, 'E1012:') |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2162 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2163 lines =<< trim END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2164 vim9script |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2165 var name:string |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2166 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2167 v9.CheckScriptFailure(lines, 'E1069:') |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2168 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2169 v9.CheckDefAndScriptFailure(['var n:number = 42'], 'E1069:') |
25668
ba4e6e74c89f
patch 8.2.3370: Vim9: no check for white space before type in declaration
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
2170 |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2171 lines =<< trim END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2172 vim9script |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2173 var name: asdf |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2174 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2175 v9.CheckScriptFailure(lines, 'E1010:') |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2176 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2177 lines =<< trim END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2178 vim9script |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
2179 var l: list<number> |
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
2180 l = [] |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2181 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2182 v9.CheckScriptSuccess(lines) |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2183 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2184 lines =<< trim END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2185 vim9script |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
2186 var d: dict<number> |
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
2187 d = {} |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2188 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2189 v9.CheckScriptSuccess(lines) |
25263
5861cc1f5704
patch 8.2.3168: Vim9: type error for constant of type any
Bram Moolenaar <Bram@vim.org>
parents:
25141
diff
changeset
|
2190 |
5861cc1f5704
patch 8.2.3168: Vim9: type error for constant of type any
Bram Moolenaar <Bram@vim.org>
parents:
25141
diff
changeset
|
2191 lines =<< trim END |
5861cc1f5704
patch 8.2.3168: Vim9: type error for constant of type any
Bram Moolenaar <Bram@vim.org>
parents:
25141
diff
changeset
|
2192 vim9script |
5861cc1f5704
patch 8.2.3168: Vim9: type error for constant of type any
Bram Moolenaar <Bram@vim.org>
parents:
25141
diff
changeset
|
2193 var d = {a: 1, b: [2]} |
5861cc1f5704
patch 8.2.3168: Vim9: type error for constant of type any
Bram Moolenaar <Bram@vim.org>
parents:
25141
diff
changeset
|
2194 def Func(b: bool) |
5861cc1f5704
patch 8.2.3168: Vim9: type error for constant of type any
Bram Moolenaar <Bram@vim.org>
parents:
25141
diff
changeset
|
2195 var l: list<number> = b ? d.b : [3] |
5861cc1f5704
patch 8.2.3168: Vim9: type error for constant of type any
Bram Moolenaar <Bram@vim.org>
parents:
25141
diff
changeset
|
2196 enddef |
5861cc1f5704
patch 8.2.3168: Vim9: type error for constant of type any
Bram Moolenaar <Bram@vim.org>
parents:
25141
diff
changeset
|
2197 defcompile |
5861cc1f5704
patch 8.2.3168: Vim9: type error for constant of type any
Bram Moolenaar <Bram@vim.org>
parents:
25141
diff
changeset
|
2198 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2199 v9.CheckScriptSuccess(lines) |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2200 enddef |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2201 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2202 let g:dict_number = #{one: 1, two: 2} |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2203 |
23124
f8cd5a5e03c4
patch 8.2.2108: Vim9: no test to check for :let error
Bram Moolenaar <Bram@vim.org>
parents:
23122
diff
changeset
|
2204 def Test_var_list_dict_type() |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2205 var ll: list<number> |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2206 ll = [1, 2, 2, 3, 3, 3]->uniq() |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2207 ll->assert_equal([1, 2, 3]) |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2208 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2209 var dd: dict<number> |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2210 dd = g:dict_number |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2211 dd->assert_equal(g:dict_number) |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2212 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2213 var lines =<< trim END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2214 var ll: list<number> |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2215 ll = [1, 2, 3]->map('"one"') |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2216 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2217 v9.CheckDefExecFailure(lines, 'E1012: Type mismatch; expected list<number> but got list<string>') |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2218 enddef |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2219 |
23124
f8cd5a5e03c4
patch 8.2.2108: Vim9: no test to check for :let error
Bram Moolenaar <Bram@vim.org>
parents:
23122
diff
changeset
|
2220 def Test_cannot_use_let() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2221 v9.CheckDefAndScriptFailure(['let a = 34'], 'E1126:', 1) |
23124
f8cd5a5e03c4
patch 8.2.2108: Vim9: no test to check for :let error
Bram Moolenaar <Bram@vim.org>
parents:
23122
diff
changeset
|
2222 enddef |
f8cd5a5e03c4
patch 8.2.2108: Vim9: no test to check for :let error
Bram Moolenaar <Bram@vim.org>
parents:
23122
diff
changeset
|
2223 |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2224 def Test_unlet() |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2225 g:somevar = 'yes' |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2226 assert_true(exists('g:somevar')) |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2227 unlet g:somevar |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2228 assert_false(exists('g:somevar')) |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2229 unlet! g:somevar |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2230 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2231 # also works for script-local variable in legacy Vim script |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2232 s:somevar = 'legacy' |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2233 assert_true(exists('s:somevar')) |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2234 unlet s:somevar |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2235 assert_false(exists('s:somevar')) |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2236 unlet! s:somevar |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2237 |
27539
ce4c2f4ce1f9
patch 8.2.4296: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
2238 if 0 |
ce4c2f4ce1f9
patch 8.2.4296: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
2239 unlet g:does_not_exist |
ce4c2f4ce1f9
patch 8.2.4296: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
2240 endif |
ce4c2f4ce1f9
patch 8.2.4296: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
2241 |
ce4c2f4ce1f9
patch 8.2.4296: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
2242 v9.CheckDefExecFailure(['unlet v:notfound.key'], 'E1001:') |
ce4c2f4ce1f9
patch 8.2.4296: Vim9: not all code covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
2243 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2244 v9.CheckDefExecFailure([ |
23523
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2245 'var dd = 111', |
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2246 'unlet dd', |
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2247 ], 'E1081:', 2) |
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2248 |
23517
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23509
diff
changeset
|
2249 # dict unlet |
27764
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
2250 var dd = {a: 1, b: 2, c: 3, 4: 4} |
23517
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23509
diff
changeset
|
2251 unlet dd['a'] |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23509
diff
changeset
|
2252 unlet dd.c |
27764
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
2253 unlet dd[4] |
23517
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23509
diff
changeset
|
2254 assert_equal({b: 2}, dd) |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23509
diff
changeset
|
2255 |
28152
b96409b84eaf
patch 8.2.4600: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28131
diff
changeset
|
2256 # null key works like empty string |
b96409b84eaf
patch 8.2.4600: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28131
diff
changeset
|
2257 dd = {'': 1, x: 9} |
b96409b84eaf
patch 8.2.4600: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28131
diff
changeset
|
2258 unlet dd[null_string] |
b96409b84eaf
patch 8.2.4600: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28131
diff
changeset
|
2259 assert_equal({x: 9}, dd) |
b96409b84eaf
patch 8.2.4600: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28131
diff
changeset
|
2260 |
23517
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23509
diff
changeset
|
2261 # list unlet |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23509
diff
changeset
|
2262 var ll = [1, 2, 3, 4] |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23509
diff
changeset
|
2263 unlet ll[1] |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23509
diff
changeset
|
2264 unlet ll[-1] |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23509
diff
changeset
|
2265 assert_equal([1, 3], ll) |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23509
diff
changeset
|
2266 |
23982
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2267 ll = [1, 2, 3, 4] |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2268 unlet ll[0 : 1] |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2269 assert_equal([3, 4], ll) |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2270 |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2271 ll = [1, 2, 3, 4] |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2272 unlet ll[2 : 8] |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2273 assert_equal([1, 2], ll) |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2274 |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2275 ll = [1, 2, 3, 4] |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2276 unlet ll[-2 : -1] |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2277 assert_equal([1, 2], ll) |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2278 |
27768
b081ba78675a
patch 8.2.4410: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27766
diff
changeset
|
2279 g:nrdict = {1: 1, 2: 2} |
b081ba78675a
patch 8.2.4410: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27766
diff
changeset
|
2280 g:idx = 1 |
b081ba78675a
patch 8.2.4410: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27766
diff
changeset
|
2281 unlet g:nrdict[g:idx] |
b081ba78675a
patch 8.2.4410: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27766
diff
changeset
|
2282 assert_equal({2: 2}, g:nrdict) |
b081ba78675a
patch 8.2.4410: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27766
diff
changeset
|
2283 unlet g:nrdict |
b081ba78675a
patch 8.2.4410: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27766
diff
changeset
|
2284 unlet g:idx |
b081ba78675a
patch 8.2.4410: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27766
diff
changeset
|
2285 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2286 v9.CheckDefFailure([ |
23982
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2287 'var ll = [1, 2]', |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2288 'll[1 : 2] = 7', |
25591
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25547
diff
changeset
|
2289 ], 'E1012: Type mismatch; expected list<number> but got number', 2) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2290 v9.CheckDefFailure([ |
23982
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2291 'var dd = {a: 1}', |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2292 'unlet dd["a" : "a"]', |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2293 ], 'E1166:', 2) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2294 v9.CheckDefExecFailure([ |
23982
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2295 'unlet g:adict[0 : 1]', |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2296 ], 'E1148:', 1) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2297 v9.CheckDefFailure([ |
23982
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2298 'var ll = [1, 2]', |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2299 'unlet ll[0:1]', |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2300 ], 'E1004:', 2) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2301 v9.CheckDefFailure([ |
23982
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2302 'var ll = [1, 2]', |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2303 'unlet ll[0 :1]', |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2304 ], 'E1004:', 2) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2305 v9.CheckDefFailure([ |
23982
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2306 'var ll = [1, 2]', |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2307 'unlet ll[0: 1]', |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2308 ], 'E1004:', 2) |
27762
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
2309 |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
2310 v9.CheckDefExecFailure([ |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
2311 'g:ll = [1, 2]', |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
2312 'g:idx = "x"', |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
2313 'unlet g:ll[g:idx]', |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
2314 ], 'E1029: Expected number but got string', 3) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
2315 |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
2316 v9.CheckDefExecFailure([ |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
2317 'g:ll = [1, 2, 3]', |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
2318 'g:idx = "x"', |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
2319 'unlet g:ll[g:idx : 2]', |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
2320 ], 'E1029: Expected number but got string', 3) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
2321 |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
2322 v9.CheckDefExecFailure([ |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
2323 'g:ll = [1, 2, 3]', |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
2324 'g:idx = "x"', |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
2325 'unlet g:ll[0 : g:idx]', |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
2326 ], 'E1029: Expected number but got string', 3) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
2327 |
26330
55e658312376
patch 8.2.3696: Vim9: error for invalid assignment when skipping
Bram Moolenaar <Bram@vim.org>
parents:
26302
diff
changeset
|
2328 # command recognized as assignment when skipping, should not give an error |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2329 v9.CheckScriptSuccess([ |
26330
55e658312376
patch 8.2.3696: Vim9: error for invalid assignment when skipping
Bram Moolenaar <Bram@vim.org>
parents:
26302
diff
changeset
|
2330 'vim9script', |
55e658312376
patch 8.2.3696: Vim9: error for invalid assignment when skipping
Bram Moolenaar <Bram@vim.org>
parents:
26302
diff
changeset
|
2331 'for i in []', |
55e658312376
patch 8.2.3696: Vim9: error for invalid assignment when skipping
Bram Moolenaar <Bram@vim.org>
parents:
26302
diff
changeset
|
2332 " put =''", |
55e658312376
patch 8.2.3696: Vim9: error for invalid assignment when skipping
Bram Moolenaar <Bram@vim.org>
parents:
26302
diff
changeset
|
2333 'endfor']) |
23982
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2334 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2335 v9.CheckDefFailure([ |
23982
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2336 'var ll = [1, 2]', |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2337 'unlet ll["x" : 1]', |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2338 ], 'E1012:', 2) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2339 v9.CheckDefFailure([ |
23982
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2340 'var ll = [1, 2]', |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2341 'unlet ll[0 : "x"]', |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2342 ], 'E1012:', 2) |
9fcd71d0db89
patch 8.2.2533: Vim9: cannot use a range with :unlet
Bram Moolenaar <Bram@vim.org>
parents:
23972
diff
changeset
|
2343 |
23517
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23509
diff
changeset
|
2344 # list of dict unlet |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23509
diff
changeset
|
2345 var dl = [{a: 1, b: 2}, {c: 3}] |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23509
diff
changeset
|
2346 unlet dl[0]['b'] |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23509
diff
changeset
|
2347 assert_equal([{a: 1}, {c: 3}], dl) |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23509
diff
changeset
|
2348 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2349 v9.CheckDefExecFailure([ |
23523
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2350 'var ll = test_null_list()', |
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2351 'unlet ll[0]', |
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2352 ], 'E684:', 2) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2353 v9.CheckDefExecFailure([ |
23523
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2354 'var ll = [1]', |
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2355 'unlet ll[2]', |
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2356 ], 'E684:', 2) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2357 v9.CheckDefExecFailure([ |
23523
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2358 'var ll = [1]', |
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2359 'unlet ll[g:astring]', |
23662
c761fcb89dfe
patch 8.2.2373: Vim9: list assignment only accepts a number index
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
2360 ], 'E1012:', 2) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2361 v9.CheckDefExecFailure([ |
23523
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2362 'var dd = test_null_dict()', |
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2363 'unlet dd["a"]', |
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2364 ], 'E716:', 2) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2365 v9.CheckDefExecFailure([ |
23523
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2366 'var dd = {a: 1}', |
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2367 'unlet dd["b"]', |
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2368 ], 'E716:', 2) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2369 v9.CheckDefExecFailure([ |
23523
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2370 'var dd = {a: 1}', |
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2371 'unlet dd[g:alist]', |
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2372 ], 'E1105:', 2) |
23517
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23509
diff
changeset
|
2373 |
27764
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
2374 v9.CheckDefExecFailure([ |
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
2375 'g:dd = {"a": 1, 2: 2}' |
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
2376 'unlet g:dd[0z11]', |
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
2377 ], 'E1029:', 2) |
27766
2a394907825d
patch 8.2.4409: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27764
diff
changeset
|
2378 v9.CheckDefExecFailure([ |
2a394907825d
patch 8.2.4409: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27764
diff
changeset
|
2379 'g:str = "a string"' |
2a394907825d
patch 8.2.4409: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27764
diff
changeset
|
2380 'unlet g:str[0]', |
2a394907825d
patch 8.2.4409: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27764
diff
changeset
|
2381 ], 'E1148: Cannot index a string', 2) |
27764
1662d2d2e27b
patch 8.2.4408: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
2382 |
23495
1f85acfb23cd
patch 8.2.2290: Vim9: unlet of global variable cannot be compiled
Bram Moolenaar <Bram@vim.org>
parents:
23450
diff
changeset
|
2383 # can compile unlet before variable exists |
23517
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23509
diff
changeset
|
2384 g:someDict = {key: 'val'} |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23509
diff
changeset
|
2385 var k = 'key' |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23509
diff
changeset
|
2386 unlet g:someDict[k] |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23509
diff
changeset
|
2387 assert_equal({}, g:someDict) |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23509
diff
changeset
|
2388 unlet g:someDict |
36bf9a6fbd4c
patch 8.2.2301: Vim9: cannot unlet a dict or list item
Bram Moolenaar <Bram@vim.org>
parents:
23509
diff
changeset
|
2389 assert_false(exists('g:someDict')) |
23495
1f85acfb23cd
patch 8.2.2290: Vim9: unlet of global variable cannot be compiled
Bram Moolenaar <Bram@vim.org>
parents:
23450
diff
changeset
|
2390 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2391 v9.CheckScriptFailure([ |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2392 'vim9script', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2393 'var svar = 123', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2394 'unlet svar', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2395 ], 'E1081:') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2396 v9.CheckScriptFailure([ |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2397 'vim9script', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2398 'var svar = 123', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2399 'unlet s:svar', |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
2400 ], 'E1268:') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2401 v9.CheckScriptFailure([ |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2402 'vim9script', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2403 'var svar = 123', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2404 'def Func()', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2405 ' unlet svar', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2406 'enddef', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2407 'defcompile', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2408 ], 'E1081:') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2409 v9.CheckScriptFailure([ |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2410 'vim9script', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2411 'var svar = 123', |
23223
98548b8fbc98
patch 8.2.2157: Vim9: can delete a Vim9 script variable from a function
Bram Moolenaar <Bram@vim.org>
parents:
23187
diff
changeset
|
2412 'func Func()', |
98548b8fbc98
patch 8.2.2157: Vim9: can delete a Vim9 script variable from a function
Bram Moolenaar <Bram@vim.org>
parents:
23187
diff
changeset
|
2413 ' unlet s:svar', |
98548b8fbc98
patch 8.2.2157: Vim9: can delete a Vim9 script variable from a function
Bram Moolenaar <Bram@vim.org>
parents:
23187
diff
changeset
|
2414 'endfunc', |
98548b8fbc98
patch 8.2.2157: Vim9: can delete a Vim9 script variable from a function
Bram Moolenaar <Bram@vim.org>
parents:
23187
diff
changeset
|
2415 'Func()', |
98548b8fbc98
patch 8.2.2157: Vim9: can delete a Vim9 script variable from a function
Bram Moolenaar <Bram@vim.org>
parents:
23187
diff
changeset
|
2416 ], 'E1081:') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2417 v9.CheckScriptFailure([ |
23223
98548b8fbc98
patch 8.2.2157: Vim9: can delete a Vim9 script variable from a function
Bram Moolenaar <Bram@vim.org>
parents:
23187
diff
changeset
|
2418 'vim9script', |
98548b8fbc98
patch 8.2.2157: Vim9: can delete a Vim9 script variable from a function
Bram Moolenaar <Bram@vim.org>
parents:
23187
diff
changeset
|
2419 'var svar = 123', |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2420 'def Func()', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2421 ' unlet s:svar', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2422 'enddef', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2423 'defcompile', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2424 ], 'E1081:') |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2425 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2426 v9.CheckScriptFailure([ |
26624
bdf11d8e3df3
patch 8.2.3841: Vim9: outdated TODO items, disabled tests that work
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
2427 'vim9script', |
bdf11d8e3df3
patch 8.2.3841: Vim9: outdated TODO items, disabled tests that work
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
2428 'def Delcount(dict: dict<any>)', |
bdf11d8e3df3
patch 8.2.3841: Vim9: outdated TODO items, disabled tests that work
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
2429 ' unlet dict.count', |
bdf11d8e3df3
patch 8.2.3841: Vim9: outdated TODO items, disabled tests that work
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
2430 'enddef', |
bdf11d8e3df3
patch 8.2.3841: Vim9: outdated TODO items, disabled tests that work
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
2431 'Delcount(v:)', |
bdf11d8e3df3
patch 8.2.3841: Vim9: outdated TODO items, disabled tests that work
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
2432 ], 'E742:') |
bdf11d8e3df3
patch 8.2.3841: Vim9: outdated TODO items, disabled tests that work
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
2433 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2434 v9.CheckScriptFailure([ |
26624
bdf11d8e3df3
patch 8.2.3841: Vim9: outdated TODO items, disabled tests that work
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
2435 'vim9script', |
bdf11d8e3df3
patch 8.2.3841: Vim9: outdated TODO items, disabled tests that work
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
2436 'def DelChangedtick(dict: dict<any>)', |
bdf11d8e3df3
patch 8.2.3841: Vim9: outdated TODO items, disabled tests that work
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
2437 ' unlet dict.changedtick', |
bdf11d8e3df3
patch 8.2.3841: Vim9: outdated TODO items, disabled tests that work
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
2438 'enddef', |
bdf11d8e3df3
patch 8.2.3841: Vim9: outdated TODO items, disabled tests that work
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
2439 'DelChangedtick(b:)', |
bdf11d8e3df3
patch 8.2.3841: Vim9: outdated TODO items, disabled tests that work
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
2440 ], 'E795:') |
bdf11d8e3df3
patch 8.2.3841: Vim9: outdated TODO items, disabled tests that work
Bram Moolenaar <Bram@vim.org>
parents:
26372
diff
changeset
|
2441 |
23523
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2442 writefile(['vim9script', 'export var svar = 1234'], 'XunletExport.vim') |
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2443 var lines =<< trim END |
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2444 vim9script |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26954
diff
changeset
|
2445 import './XunletExport.vim' as exp |
23523
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2446 def UnletSvar() |
26980
8796f1384750
patch 8.2.4019: Vim9: import mechanism is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26954
diff
changeset
|
2447 unlet exp.svar |
23523
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2448 enddef |
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2449 defcompile |
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2450 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2451 v9.CheckScriptFailure(lines, 'E1260:', 1) |
23523
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2452 delete('XunletExport.vim') |
b0a6e7325169
patch 8.2.2304: Vim9: no test for unletting an imported variable
Bram Moolenaar <Bram@vim.org>
parents:
23517
diff
changeset
|
2453 |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2454 $ENVVAR = 'foobar' |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2455 assert_equal('foobar', $ENVVAR) |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2456 unlet $ENVVAR |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2457 assert_equal('', $ENVVAR) |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2458 enddef |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2459 |
23679
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23662
diff
changeset
|
2460 def Test_expr_error_no_assign() |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23662
diff
changeset
|
2461 var lines =<< trim END |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23662
diff
changeset
|
2462 vim9script |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23662
diff
changeset
|
2463 var x = invalid |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23662
diff
changeset
|
2464 echo x |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23662
diff
changeset
|
2465 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2466 v9.CheckScriptFailureList(lines, ['E121:', 'E121:']) |
23679
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23662
diff
changeset
|
2467 |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23662
diff
changeset
|
2468 lines =<< trim END |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23662
diff
changeset
|
2469 vim9script |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23662
diff
changeset
|
2470 var x = 1 / 0 |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23662
diff
changeset
|
2471 echo x |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23662
diff
changeset
|
2472 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2473 v9.CheckScriptFailure(lines, 'E1154:') |
23679
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23662
diff
changeset
|
2474 |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23662
diff
changeset
|
2475 lines =<< trim END |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23662
diff
changeset
|
2476 vim9script |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23662
diff
changeset
|
2477 var x = 1 % 0 |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23662
diff
changeset
|
2478 echo x |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23662
diff
changeset
|
2479 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2480 v9.CheckScriptFailure(lines, 'E1154:') |
24238
e5cd25f7ffcd
patch 8.2.2660: Vim9: no error for declaration with trailing text
Bram Moolenaar <Bram@vim.org>
parents:
24154
diff
changeset
|
2481 |
e5cd25f7ffcd
patch 8.2.2660: Vim9: no error for declaration with trailing text
Bram Moolenaar <Bram@vim.org>
parents:
24154
diff
changeset
|
2482 lines =<< trim END |
e5cd25f7ffcd
patch 8.2.2660: Vim9: no error for declaration with trailing text
Bram Moolenaar <Bram@vim.org>
parents:
24154
diff
changeset
|
2483 var x: string 'string' |
e5cd25f7ffcd
patch 8.2.2660: Vim9: no error for declaration with trailing text
Bram Moolenaar <Bram@vim.org>
parents:
24154
diff
changeset
|
2484 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2485 v9.CheckDefAndScriptFailure(lines, 'E488:') |
23679
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23662
diff
changeset
|
2486 enddef |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23662
diff
changeset
|
2487 |
e8c379b20765
patch 8.2.2381: Vim9: divide by zero does not abort expression execution
Bram Moolenaar <Bram@vim.org>
parents:
23662
diff
changeset
|
2488 |
23537
7f0fc2ab90e3
patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents:
23531
diff
changeset
|
2489 def Test_assign_command_modifier() |
7f0fc2ab90e3
patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents:
23531
diff
changeset
|
2490 var lines =<< trim END |
23549
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2491 var verbose = 0 |
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2492 verbose = 1 |
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2493 assert_equal(1, verbose) |
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2494 silent verbose = 2 |
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2495 assert_equal(2, verbose) |
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2496 silent verbose += 2 |
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2497 assert_equal(4, verbose) |
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2498 silent verbose -= 1 |
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2499 assert_equal(3, verbose) |
23537
7f0fc2ab90e3
patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents:
23531
diff
changeset
|
2500 |
23549
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2501 var topleft = {one: 1} |
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2502 sandbox topleft.one = 3 |
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2503 assert_equal({one: 3}, topleft) |
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2504 leftabove topleft[' '] = 4 |
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2505 assert_equal({one: 3, ' ': 4}, topleft) |
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2506 |
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2507 var x: number |
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2508 var y: number |
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2509 silent [x, y] = [1, 2] |
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2510 assert_equal(1, x) |
4156f972efb1
patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
23537
diff
changeset
|
2511 assert_equal(2, y) |
23537
7f0fc2ab90e3
patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents:
23531
diff
changeset
|
2512 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2513 v9.CheckDefAndScriptSuccess(lines) |
23537
7f0fc2ab90e3
patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents:
23531
diff
changeset
|
2514 enddef |
7f0fc2ab90e3
patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents:
23531
diff
changeset
|
2515 |
24956
d0b6a8d82cef
patch 8.2.3015: Vim9: Assigning to @# requires a string
Bram Moolenaar <Bram@vim.org>
parents:
24888
diff
changeset
|
2516 def Test_assign_alt_buf_register() |
d0b6a8d82cef
patch 8.2.3015: Vim9: Assigning to @# requires a string
Bram Moolenaar <Bram@vim.org>
parents:
24888
diff
changeset
|
2517 var lines =<< trim END |
d0b6a8d82cef
patch 8.2.3015: Vim9: Assigning to @# requires a string
Bram Moolenaar <Bram@vim.org>
parents:
24888
diff
changeset
|
2518 edit 'file_b1' |
d0b6a8d82cef
patch 8.2.3015: Vim9: Assigning to @# requires a string
Bram Moolenaar <Bram@vim.org>
parents:
24888
diff
changeset
|
2519 var b1 = bufnr() |
d0b6a8d82cef
patch 8.2.3015: Vim9: Assigning to @# requires a string
Bram Moolenaar <Bram@vim.org>
parents:
24888
diff
changeset
|
2520 edit 'file_b2' |
d0b6a8d82cef
patch 8.2.3015: Vim9: Assigning to @# requires a string
Bram Moolenaar <Bram@vim.org>
parents:
24888
diff
changeset
|
2521 var b2 = bufnr() |
d0b6a8d82cef
patch 8.2.3015: Vim9: Assigning to @# requires a string
Bram Moolenaar <Bram@vim.org>
parents:
24888
diff
changeset
|
2522 assert_equal(b1, bufnr('#')) |
d0b6a8d82cef
patch 8.2.3015: Vim9: Assigning to @# requires a string
Bram Moolenaar <Bram@vim.org>
parents:
24888
diff
changeset
|
2523 @# = b2 |
d0b6a8d82cef
patch 8.2.3015: Vim9: Assigning to @# requires a string
Bram Moolenaar <Bram@vim.org>
parents:
24888
diff
changeset
|
2524 assert_equal(b2, bufnr('#')) |
d0b6a8d82cef
patch 8.2.3015: Vim9: Assigning to @# requires a string
Bram Moolenaar <Bram@vim.org>
parents:
24888
diff
changeset
|
2525 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2526 v9.CheckDefAndScriptSuccess(lines) |
24956
d0b6a8d82cef
patch 8.2.3015: Vim9: Assigning to @# requires a string
Bram Moolenaar <Bram@vim.org>
parents:
24888
diff
changeset
|
2527 enddef |
d0b6a8d82cef
patch 8.2.3015: Vim9: Assigning to @# requires a string
Bram Moolenaar <Bram@vim.org>
parents:
24888
diff
changeset
|
2528 |
24264
db5eaad456cc
patch 8.2.2673: Vim9: script-local funcref can have lower case name
Bram Moolenaar <Bram@vim.org>
parents:
24238
diff
changeset
|
2529 def Test_script_funcref_case() |
db5eaad456cc
patch 8.2.2673: Vim9: script-local funcref can have lower case name
Bram Moolenaar <Bram@vim.org>
parents:
24238
diff
changeset
|
2530 var lines =<< trim END |
db5eaad456cc
patch 8.2.2673: Vim9: script-local funcref can have lower case name
Bram Moolenaar <Bram@vim.org>
parents:
24238
diff
changeset
|
2531 var Len = (s: string): number => len(s) + 1 |
db5eaad456cc
patch 8.2.2673: Vim9: script-local funcref can have lower case name
Bram Moolenaar <Bram@vim.org>
parents:
24238
diff
changeset
|
2532 assert_equal(5, Len('asdf')) |
db5eaad456cc
patch 8.2.2673: Vim9: script-local funcref can have lower case name
Bram Moolenaar <Bram@vim.org>
parents:
24238
diff
changeset
|
2533 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2534 v9.CheckDefAndScriptSuccess(lines) |
24264
db5eaad456cc
patch 8.2.2673: Vim9: script-local funcref can have lower case name
Bram Moolenaar <Bram@vim.org>
parents:
24238
diff
changeset
|
2535 |
db5eaad456cc
patch 8.2.2673: Vim9: script-local funcref can have lower case name
Bram Moolenaar <Bram@vim.org>
parents:
24238
diff
changeset
|
2536 lines =<< trim END |
db5eaad456cc
patch 8.2.2673: Vim9: script-local funcref can have lower case name
Bram Moolenaar <Bram@vim.org>
parents:
24238
diff
changeset
|
2537 var len = (s: string): number => len(s) + 1 |
db5eaad456cc
patch 8.2.2673: Vim9: script-local funcref can have lower case name
Bram Moolenaar <Bram@vim.org>
parents:
24238
diff
changeset
|
2538 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2539 v9.CheckDefAndScriptFailure(lines, 'E704:') |
24264
db5eaad456cc
patch 8.2.2673: Vim9: script-local funcref can have lower case name
Bram Moolenaar <Bram@vim.org>
parents:
24238
diff
changeset
|
2540 |
db5eaad456cc
patch 8.2.2673: Vim9: script-local funcref can have lower case name
Bram Moolenaar <Bram@vim.org>
parents:
24238
diff
changeset
|
2541 lines =<< trim END |
db5eaad456cc
patch 8.2.2673: Vim9: script-local funcref can have lower case name
Bram Moolenaar <Bram@vim.org>
parents:
24238
diff
changeset
|
2542 vim9script |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
2543 var Len = (s: string): number => len(s) + 2 |
24264
db5eaad456cc
patch 8.2.2673: Vim9: script-local funcref can have lower case name
Bram Moolenaar <Bram@vim.org>
parents:
24238
diff
changeset
|
2544 assert_equal(6, Len('asdf')) |
db5eaad456cc
patch 8.2.2673: Vim9: script-local funcref can have lower case name
Bram Moolenaar <Bram@vim.org>
parents:
24238
diff
changeset
|
2545 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2546 v9.CheckScriptSuccess(lines) |
24264
db5eaad456cc
patch 8.2.2673: Vim9: script-local funcref can have lower case name
Bram Moolenaar <Bram@vim.org>
parents:
24238
diff
changeset
|
2547 |
db5eaad456cc
patch 8.2.2673: Vim9: script-local funcref can have lower case name
Bram Moolenaar <Bram@vim.org>
parents:
24238
diff
changeset
|
2548 lines =<< trim END |
db5eaad456cc
patch 8.2.2673: Vim9: script-local funcref can have lower case name
Bram Moolenaar <Bram@vim.org>
parents:
24238
diff
changeset
|
2549 vim9script |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27569
diff
changeset
|
2550 var len = (s: string): number => len(s) + 1 |
24264
db5eaad456cc
patch 8.2.2673: Vim9: script-local funcref can have lower case name
Bram Moolenaar <Bram@vim.org>
parents:
24238
diff
changeset
|
2551 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2552 v9.CheckScriptFailure(lines, 'E704:') |
24264
db5eaad456cc
patch 8.2.2673: Vim9: script-local funcref can have lower case name
Bram Moolenaar <Bram@vim.org>
parents:
24238
diff
changeset
|
2553 enddef |
db5eaad456cc
patch 8.2.2673: Vim9: script-local funcref can have lower case name
Bram Moolenaar <Bram@vim.org>
parents:
24238
diff
changeset
|
2554 |
26630
57bc1001160b
patch 8.2.3844: Vim9: no type error if assigning func(number) to func(string)
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
2555 def Test_script_funcref_runtime_type_check() |
57bc1001160b
patch 8.2.3844: Vim9: no type error if assigning func(number) to func(string)
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
2556 var lines =<< trim END |
57bc1001160b
patch 8.2.3844: Vim9: no type error if assigning func(number) to func(string)
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
2557 vim9script |
57bc1001160b
patch 8.2.3844: Vim9: no type error if assigning func(number) to func(string)
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
2558 def FuncWithNumberArg(n: number) |
57bc1001160b
patch 8.2.3844: Vim9: no type error if assigning func(number) to func(string)
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
2559 enddef |
57bc1001160b
patch 8.2.3844: Vim9: no type error if assigning func(number) to func(string)
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
2560 def Test() |
57bc1001160b
patch 8.2.3844: Vim9: no type error if assigning func(number) to func(string)
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
2561 var Ref: func(string) = function(FuncWithNumberArg) |
57bc1001160b
patch 8.2.3844: Vim9: no type error if assigning func(number) to func(string)
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
2562 enddef |
57bc1001160b
patch 8.2.3844: Vim9: no type error if assigning func(number) to func(string)
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
2563 defcompile |
57bc1001160b
patch 8.2.3844: Vim9: no type error if assigning func(number) to func(string)
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
2564 END |
57bc1001160b
patch 8.2.3844: Vim9: no type error if assigning func(number) to func(string)
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
2565 # OK at compile time |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2566 v9.CheckScriptSuccess(lines) |
26630
57bc1001160b
patch 8.2.3844: Vim9: no type error if assigning func(number) to func(string)
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
2567 |
57bc1001160b
patch 8.2.3844: Vim9: no type error if assigning func(number) to func(string)
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
2568 # Type check fails at runtime |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2569 v9.CheckScriptFailure(lines + ['Test()'], 'E1012: Type mismatch; expected func(string) but got func(number)') |
26630
57bc1001160b
patch 8.2.3844: Vim9: no type error if assigning func(number) to func(string)
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
2570 enddef |
57bc1001160b
patch 8.2.3844: Vim9: no type error if assigning func(number) to func(string)
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
2571 |
24533
9c404d78d767
patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
2572 def Test_inc_dec() |
9c404d78d767
patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
2573 var lines =<< trim END |
9c404d78d767
patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
2574 var nr = 7 |
9c404d78d767
patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
2575 ++nr |
24537
95bcea9faa52
patch 8.2.2808: Vim9: increment and decrement not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24533
diff
changeset
|
2576 assert_equal(8, nr) |
24533
9c404d78d767
patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
2577 --nr |
24537
95bcea9faa52
patch 8.2.2808: Vim9: increment and decrement not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24533
diff
changeset
|
2578 assert_equal(7, nr) |
25020
91f396f149d5
patch 8.2.3047: increment and decrement don't allow for next command
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
2579 ++nr | ++nr |
91f396f149d5
patch 8.2.3047: increment and decrement don't allow for next command
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
2580 assert_equal(9, nr) |
91f396f149d5
patch 8.2.3047: increment and decrement don't allow for next command
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
2581 ++nr # comment |
91f396f149d5
patch 8.2.3047: increment and decrement don't allow for next command
Bram Moolenaar <Bram@vim.org>
parents:
24984
diff
changeset
|
2582 assert_equal(10, nr) |
24533
9c404d78d767
patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
2583 |
9c404d78d767
patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
2584 var ll = [1, 2] |
9c404d78d767
patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
2585 --ll[0] |
9c404d78d767
patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
2586 ++ll[1] |
24537
95bcea9faa52
patch 8.2.2808: Vim9: increment and decrement not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24533
diff
changeset
|
2587 assert_equal([0, 3], ll) |
95bcea9faa52
patch 8.2.2808: Vim9: increment and decrement not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24533
diff
changeset
|
2588 |
95bcea9faa52
patch 8.2.2808: Vim9: increment and decrement not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24533
diff
changeset
|
2589 g:count = 1 |
95bcea9faa52
patch 8.2.2808: Vim9: increment and decrement not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24533
diff
changeset
|
2590 ++g:count |
95bcea9faa52
patch 8.2.2808: Vim9: increment and decrement not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24533
diff
changeset
|
2591 --g:count |
95bcea9faa52
patch 8.2.2808: Vim9: increment and decrement not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24533
diff
changeset
|
2592 assert_equal(1, g:count) |
95bcea9faa52
patch 8.2.2808: Vim9: increment and decrement not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24533
diff
changeset
|
2593 unlet g:count |
24533
9c404d78d767
patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
2594 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2595 v9.CheckDefAndScriptSuccess(lines) |
25022
39551b6e0112
patch 8.2.3048: strange error for white space after ++ command
Bram Moolenaar <Bram@vim.org>
parents:
25020
diff
changeset
|
2596 |
39551b6e0112
patch 8.2.3048: strange error for white space after ++ command
Bram Moolenaar <Bram@vim.org>
parents:
25020
diff
changeset
|
2597 lines =<< trim END |
39551b6e0112
patch 8.2.3048: strange error for white space after ++ command
Bram Moolenaar <Bram@vim.org>
parents:
25020
diff
changeset
|
2598 var nr = 7 |
39551b6e0112
patch 8.2.3048: strange error for white space after ++ command
Bram Moolenaar <Bram@vim.org>
parents:
25020
diff
changeset
|
2599 ++ nr |
39551b6e0112
patch 8.2.3048: strange error for white space after ++ command
Bram Moolenaar <Bram@vim.org>
parents:
25020
diff
changeset
|
2600 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27406
diff
changeset
|
2601 v9.CheckDefAndScriptFailure(lines, "E1202: No white space allowed after '++': ++ nr") |
24533
9c404d78d767
patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
2602 enddef |
9c404d78d767
patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
2603 |
25400
5c7192180b89
patch 8.2.3237: when a builtin function gives an error processing continues
Bram Moolenaar <Bram@vim.org>
parents:
25274
diff
changeset
|
2604 def Test_abort_after_error() |
5c7192180b89
patch 8.2.3237: when a builtin function gives an error processing continues
Bram Moolenaar <Bram@vim.org>
parents:
25274
diff
changeset
|
2605 # should abort after strpart() fails, not give another type error |
5c7192180b89
patch 8.2.3237: when a builtin function gives an error processing continues
Bram Moolenaar <Bram@vim.org>
parents:
25274
diff
changeset
|
2606 var lines =<< trim END |
5c7192180b89
patch 8.2.3237: when a builtin function gives an error processing continues
Bram Moolenaar <Bram@vim.org>
parents:
25274
diff
changeset
|
2607 vim9script |
5c7192180b89
patch 8.2.3237: when a builtin function gives an error processing continues
Bram Moolenaar <Bram@vim.org>
parents:
25274
diff
changeset
|
2608 var x: string |
5c7192180b89
patch 8.2.3237: when a builtin function gives an error processing continues
Bram Moolenaar <Bram@vim.org>
parents:
25274
diff
changeset
|
2609 x = strpart(1, 2) |
5c7192180b89
patch 8.2.3237: when a builtin function gives an error processing continues
Bram Moolenaar <Bram@vim.org>
parents:
25274
diff
changeset
|
2610 END |
5c7192180b89
patch 8.2.3237: when a builtin function gives an error processing continues
Bram Moolenaar <Bram@vim.org>
parents:
25274
diff
changeset
|
2611 writefile(lines, 'Xtestscript') |
5c7192180b89
patch 8.2.3237: when a builtin function gives an error processing continues
Bram Moolenaar <Bram@vim.org>
parents:
25274
diff
changeset
|
2612 var expected = 'E1174: String required for argument 1' |
5c7192180b89
patch 8.2.3237: when a builtin function gives an error processing continues
Bram Moolenaar <Bram@vim.org>
parents:
25274
diff
changeset
|
2613 assert_fails('so Xtestscript', [expected, expected], 3) |
5c7192180b89
patch 8.2.3237: when a builtin function gives an error processing continues
Bram Moolenaar <Bram@vim.org>
parents:
25274
diff
changeset
|
2614 |
5c7192180b89
patch 8.2.3237: when a builtin function gives an error processing continues
Bram Moolenaar <Bram@vim.org>
parents:
25274
diff
changeset
|
2615 delete('Xtestscript') |
5c7192180b89
patch 8.2.3237: when a builtin function gives an error processing continues
Bram Moolenaar <Bram@vim.org>
parents:
25274
diff
changeset
|
2616 enddef |
5c7192180b89
patch 8.2.3237: when a builtin function gives an error processing continues
Bram Moolenaar <Bram@vim.org>
parents:
25274
diff
changeset
|
2617 |
27843
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2618 def Test_using_s_var_in_function() |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2619 var lines =<< trim END |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2620 vim9script |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2621 var scriptlevel = 123 |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2622 def SomeFunc() |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2623 echo s:scriptlevel |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2624 enddef |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2625 SomeFunc() |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2626 END |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2627 v9.CheckScriptFailure(lines, 'E1268:') |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2628 |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2629 # OK in legacy script |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2630 lines =<< trim END |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2631 let s:scriptlevel = 123 |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2632 def s:SomeFunc() |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2633 echo s:scriptlevel |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2634 enddef |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2635 call s:SomeFunc() |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2636 END |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2637 v9.CheckScriptSuccess(lines) |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2638 |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2639 lines =<< trim END |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2640 vim9script |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2641 var scriptlevel = 123 |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2642 def SomeFunc() |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2643 s:scriptlevel = 456 |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2644 enddef |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2645 SomeFunc() |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2646 END |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2647 v9.CheckScriptFailure(lines, 'E1268:') |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2648 |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2649 # OK in legacy script |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2650 lines =<< trim END |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2651 let s:scriptlevel = 123 |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2652 def s:SomeFunc() |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2653 s:scriptlevel = 456 |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2654 enddef |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2655 call s:SomeFunc() |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2656 call assert_equal(456, s:scriptlevel) |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2657 END |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2658 v9.CheckScriptSuccess(lines) |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2659 enddef |
532a0c5de1ec
patch 8.2.4447: Vim9: can still use s:var in a compiled function
Bram Moolenaar <Bram@vim.org>
parents:
27768
diff
changeset
|
2660 |
28491
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
2661 let g:someVar = 'X' |
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
2662 |
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
2663 " Test for heredoc with Vim expressions. |
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
2664 " This messes up highlighting, keep it near the end. |
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
2665 def Test_heredoc_expr() |
28560
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2666 var lines =<< trim CODE |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2667 var s = "local" |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2668 var a1 = "1" |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2669 var a2 = "2" |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2670 var a3 = "3" |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2671 var a4 = "" |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2672 var code =<< trim eval END |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2673 var a = `=5 + 10` |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2674 var b = `=min([10, 6])` + `=max([4, 6])` |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2675 var c = "`=s`" |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2676 var d = x`=a1`x`=a2`x`=a3`x`=a4` |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2677 END |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2678 assert_equal(['var a = 15', 'var b = 6 + 6', 'var c = "local"', 'var d = x1x2x3x'], code) |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2679 CODE |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2680 v9.CheckDefAndScriptSuccess(lines) |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2681 |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2682 lines =<< trim CODE |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2683 var code =<< eval trim END |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2684 var s = "`=$SOME_ENV_VAR`" |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2685 END |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2686 assert_equal(['var s = "somemore"'], code) |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2687 CODE |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2688 v9.CheckDefAndScriptSuccess(lines) |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2689 |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2690 lines =<< trim CODE |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2691 var code =<< eval END |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2692 var s = "`=$SOME_ENV_VAR`" |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2693 END |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2694 assert_equal([' var s = "somemore"'], code) |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2695 CODE |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2696 v9.CheckDefAndScriptSuccess(lines) |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2697 |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2698 lines =<< trim CODE |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2699 var code =<< eval trim END |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2700 let a = `abc` |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2701 let b = `=g:someVar` |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2702 let c = ` |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2703 END |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2704 assert_equal(['let a = `abc`', 'let b = X', 'let c = `'], code) |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2705 CODE |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2706 v9.CheckDefAndScriptSuccess(lines) |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2707 |
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2708 lines =<< trim LINES |
28491
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
2709 var text =<< eval trim END |
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
2710 let b = `= |
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
2711 END |
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
2712 LINES |
28560
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2713 v9.CheckDefAndScriptFailure(lines, ['E1143: Empty expression: ""', 'E1083: Missing backtick']) |
28491
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
2714 |
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
2715 lines =<< trim LINES |
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
2716 var text =<< eval trim END |
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
2717 let b = `=abc |
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
2718 END |
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
2719 LINES |
28560
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2720 v9.CheckDefAndScriptFailure(lines, ['E1001: Variable not found: abc', 'E1083: Missing backtick']) |
28491
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
2721 |
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
2722 lines =<< trim LINES |
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
2723 var text =<< eval trim END |
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
2724 let b = `=` |
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
2725 END |
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
2726 LINES |
28560
060fc3b69697
patch 8.2.4804: expression in heredoc doesn't work for compiled function
Bram Moolenaar <Bram@vim.org>
parents:
28491
diff
changeset
|
2727 v9.CheckDefAndScriptFailure(lines, ['E1015: Name expected: `', 'E15: Invalid expression: "`"']) |
28491
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
2728 enddef |
769599ee9f06
patch 8.2.4770: cannot easily mix expression and heredoc
Bram Moolenaar <Bram@vim.org>
parents:
28345
diff
changeset
|
2729 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2730 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |