Mercurial > vim
annotate src/testdir/test_vim9_assign.vim @ 22764:d03221aa54f3 v8.2.1930
patch 8.2.1930: wrong input if removing shift results in special key code
Commit: https://github.com/vim/vim/commit/749bc9521d9c1b3b3250faef25a3710206cf277d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Oct 31 16:33:47 2020 +0100
patch 8.2.1930: wrong input if removing shift results in special key code
Problem: Wrong input if removing shift results in special key code.
Solution: Handle special key codes. (closes https://github.com/vim/vim/issues/7189)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 31 Oct 2020 16:45:03 +0100 |
parents | 59cd5f8b2ab2 |
children | 3e0f909ca1f2 |
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 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 source vim9.vim |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 let s:appendToMe = 'xxx' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 let s:addToMe = 111 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 let g:existing = 'yes' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 let g:inc_counter = 1 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 let $SOME_ENV_VAR = 'some' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 let g:alist = [7] |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 let g:astring = 'text' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 def Test_assignment_bool() |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
15 var bool1: bool = true |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 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
|
17 var bool2: bool = false |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 assert_equal(v:false, bool2) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
20 var bool3: bool = 0 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 assert_equal(false, bool3) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
22 var bool4: bool = 1 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 assert_equal(true, bool4) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 |
22494
4c21f7f6f9e3
patch 8.2.1795: Vim9: operators && and || have a confusing result
Bram Moolenaar <Bram@vim.org>
parents:
22458
diff
changeset
|
25 var bool5: bool = 1 && true |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 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
|
27 var bool6: bool = 0 && 1 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 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
|
29 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
|
30 assert_equal(true, bool7) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
32 var lines =<< trim END |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 vim9script |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 def GetFlag(): bool |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
35 var flag: bool = 1 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 return flag |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 enddef |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
38 var flag: bool = GetFlag() |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 assert_equal(true, flag) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 flag = 0 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 assert_equal(false, flag) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 flag = 1 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 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
|
44 flag = 1 || true |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 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
|
46 flag = 1 && false |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 assert_equal(false, flag) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 CheckScriptSuccess(lines) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
50 CheckDefAndScriptFailure(['var x: bool = 2'], 'E1012:') |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
51 CheckDefAndScriptFailure(['var x: bool = -1'], 'E1012:') |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
52 CheckDefAndScriptFailure(['var x: bool = [1]'], 'E1012:') |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
53 CheckDefAndScriptFailure(['var x: bool = {}'], 'E1012:') |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
54 CheckDefAndScriptFailure(['var x: bool = "x"'], 'E1012:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 def Test_syntax() |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
58 var name = 234 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
59 var other: list<string> = ['asdf'] |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 def Test_assignment() |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
63 CheckDefFailure(['var x:string'], 'E1069:') |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
64 CheckDefFailure(['var x:string = "x"'], 'E1069:') |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
65 CheckDefFailure(['var a:string = "x"'], 'E1069:') |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
66 CheckDefFailure(['var lambda = {-> "lambda"}'], 'E704:') |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
67 CheckScriptFailure(['var x = "x"'], 'E1124:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
69 var nr: number = 1234 |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
70 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
|
71 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
72 var a: number = 6 #comment |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
73 assert_equal(6, a) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
74 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 if has('channel') |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
76 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
|
77 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
|
78 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
79 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
|
80 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
|
81 |
22582
a3df1fb28d44
patch 8.2.1839: Vim9: memory leaks reported in assign test
Bram Moolenaar <Bram@vim.org>
parents:
22545
diff
changeset
|
82 # 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
|
83 endif |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
84 if has('float') |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
85 var float1: float = 3.4 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
86 endif |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
87 var Funky1: func |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
88 var Funky2: func = function('len') |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
89 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
|
90 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
91 g:newvar = 'new' #comment |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
92 assert_equal('new', g:newvar) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
93 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
94 assert_equal('yes', g:existing) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
95 g:existing = 'no' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
96 assert_equal('no', g:existing) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
97 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
98 v:char = 'abc' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
99 assert_equal('abc', v:char) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
100 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
101 $ENVVAR = 'foobar' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
102 assert_equal('foobar', $ENVVAR) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
103 $ENVVAR = '' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
104 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
105 var lines =<< trim END |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
106 vim9script |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
107 $ENVVAR = 'barfoo' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
108 assert_equal('barfoo', $ENVVAR) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
109 $ENVVAR = '' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
110 END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
111 CheckScriptSuccess(lines) |
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 s:appendToMe ..= 'yyy' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
114 assert_equal('xxxyyy', s:appendToMe) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
115 s:addToMe += 222 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
116 assert_equal(333, s:addToMe) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
117 s:newVar = 'new' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
118 assert_equal('new', s:newVar) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
119 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
120 set ts=7 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
121 &ts += 1 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
122 assert_equal(8, &ts) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
123 &ts -= 3 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
124 assert_equal(5, &ts) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
125 &ts *= 2 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
126 assert_equal(10, &ts) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
127 &ts /= 3 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
128 assert_equal(3, &ts) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
129 set ts=10 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
130 &ts %= 4 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
131 assert_equal(2, &ts) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
132 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
133 if has('float') |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
134 var f100: float = 100.0 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
135 f100 /= 5 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
136 assert_equal(20.0, f100) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
137 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
138 var f200: float = 200.0 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
139 f200 /= 5.0 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
140 assert_equal(40.0, f200) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
141 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
142 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
|
143 endif |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
144 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
145 lines =<< trim END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
146 &ts = 6 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
147 &ts += 3 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
148 assert_equal(9, &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 &l:ts = 6 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
151 assert_equal(6, &ts) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
152 &l:ts += 2 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
153 assert_equal(8, &ts) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
154 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
155 &g:ts = 6 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
156 assert_equal(6, &g:ts) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
157 &g:ts += 2 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
158 assert_equal(8, &g:ts) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
159 END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
160 CheckDefAndScriptSuccess(lines) |
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 CheckDefFailure(['¬ex += 3'], 'E113:') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
163 CheckDefFailure(['&ts ..= "xxx"'], 'E1019:') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
164 CheckDefFailure(['&ts = [7]'], 'E1012:') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
165 CheckDefExecFailure(['&ts = g:alist'], 'E1012: Type mismatch; expected number but got list<number>') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
166 CheckDefFailure(['&ts = "xx"'], 'E1012:') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
167 CheckDefExecFailure(['&ts = g:astring'], 'E1012: Type mismatch; expected number but got string') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
168 CheckDefFailure(['&path += 3'], 'E1012:') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
169 CheckDefExecFailure(['&bs = "asdf"'], 'E474:') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
170 # test freeing ISN_STOREOPT |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
171 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
|
172 &ts = 8 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
173 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
174 lines =<< trim END |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
175 var save_TI = &t_TI |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
176 &t_TI = '' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
177 assert_equal('', &t_TI) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
178 &t_TI = 'xxx' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
179 assert_equal('xxx', &t_TI) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
180 &t_TI = save_TI |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
181 END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
182 CheckDefAndScriptSuccess(lines) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
183 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
184 CheckDefFailure(['&t_TI = 123'], 'E1012:') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
185 CheckScriptFailure(['vim9script', '&t_TI = 123'], 'E928:') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
186 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
187 CheckDefFailure(['var s:var = 123'], 'E1101:') |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
188 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
|
189 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
190 lines =<< trim END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
191 vim9script |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
192 def SomeFunc() |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
193 s:var = 123 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
194 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
195 defcompile |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
196 END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
197 CheckScriptFailure(lines, 'E1089:') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
198 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
199 g:inc_counter += 1 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
200 assert_equal(2, g:inc_counter) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
201 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
202 $SOME_ENV_VAR ..= 'more' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
203 assert_equal('somemore', $SOME_ENV_VAR) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
204 CheckDefFailure(['$SOME_ENV_VAR += "more"'], 'E1051:') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
205 CheckDefFailure(['$SOME_ENV_VAR += 123'], 'E1012:') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
206 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
207 lines =<< trim END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
208 @c = 'areg' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
209 @c ..= 'add' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
210 assert_equal('aregadd', @c) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
211 END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
212 CheckDefAndScriptSuccess(lines) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
213 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
214 CheckDefFailure(['@a += "more"'], 'E1051:') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
215 CheckDefFailure(['@a += 123'], 'E1012:') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
216 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
217 v:errmsg = 'none' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
218 v:errmsg ..= 'again' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
219 assert_equal('noneagain', v:errmsg) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
220 CheckDefFailure(['v:errmsg += "more"'], 'E1051:') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
221 CheckDefFailure(['v:errmsg += 123'], 'E1012:') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
222 |
22582
a3df1fb28d44
patch 8.2.1839: Vim9: memory leaks reported in assign test
Bram Moolenaar <Bram@vim.org>
parents:
22545
diff
changeset
|
223 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
|
224 some text |
a3df1fb28d44
patch 8.2.1839: Vim9: memory leaks reported in assign test
Bram Moolenaar <Bram@vim.org>
parents:
22545
diff
changeset
|
225 END |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
226 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
227 |
22365
a4866826cebc
patch 8.2.1731: Vim9: cannot use += to append to empty NULL list
Bram Moolenaar <Bram@vim.org>
parents:
22363
diff
changeset
|
228 def Test_extend_list() |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
229 var lines =<< trim END |
22365
a4866826cebc
patch 8.2.1731: Vim9: cannot use += to append to empty NULL list
Bram Moolenaar <Bram@vim.org>
parents:
22363
diff
changeset
|
230 vim9script |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
231 var l: list<number> |
22365
a4866826cebc
patch 8.2.1731: Vim9: cannot use += to append to empty NULL list
Bram Moolenaar <Bram@vim.org>
parents:
22363
diff
changeset
|
232 l += [123] |
a4866826cebc
patch 8.2.1731: Vim9: cannot use += to append to empty NULL list
Bram Moolenaar <Bram@vim.org>
parents:
22363
diff
changeset
|
233 assert_equal([123], l) |
a4866826cebc
patch 8.2.1731: Vim9: cannot use += to append to empty NULL list
Bram Moolenaar <Bram@vim.org>
parents:
22363
diff
changeset
|
234 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
235 var d: dict<number> |
22365
a4866826cebc
patch 8.2.1731: Vim9: cannot use += to append to empty NULL list
Bram Moolenaar <Bram@vim.org>
parents:
22363
diff
changeset
|
236 d['one'] = 1 |
a4866826cebc
patch 8.2.1731: Vim9: cannot use += to append to empty NULL list
Bram Moolenaar <Bram@vim.org>
parents:
22363
diff
changeset
|
237 assert_equal(#{one: 1}, d) |
a4866826cebc
patch 8.2.1731: Vim9: cannot use += to append to empty NULL list
Bram Moolenaar <Bram@vim.org>
parents:
22363
diff
changeset
|
238 END |
a4866826cebc
patch 8.2.1731: Vim9: cannot use += to append to empty NULL list
Bram Moolenaar <Bram@vim.org>
parents:
22363
diff
changeset
|
239 CheckScriptSuccess(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
|
240 |
47596deedfb5
patch 8.2.1821: Vim9: concatenating to a NULL list doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
241 # appending to NULL list from a function |
47596deedfb5
patch 8.2.1821: Vim9: concatenating to a NULL list doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
242 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
|
243 vim9script |
47596deedfb5
patch 8.2.1821: Vim9: concatenating to a NULL list doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
244 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
|
245 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
|
246 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
|
247 enddef |
47596deedfb5
patch 8.2.1821: Vim9: concatenating to a NULL list doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
248 Func() |
47596deedfb5
patch 8.2.1821: Vim9: concatenating to a NULL list doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
249 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
|
250 END |
47596deedfb5
patch 8.2.1821: Vim9: concatenating to a NULL list doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
22494
diff
changeset
|
251 CheckScriptSuccess(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
|
252 enddef |
a4866826cebc
patch 8.2.1731: Vim9: cannot use += to append to empty NULL list
Bram Moolenaar <Bram@vim.org>
parents:
22363
diff
changeset
|
253 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
254 def Test_single_letter_vars() |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
255 # single letter variables |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
256 var a: number = 123 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
257 a = 123 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
258 assert_equal(123, a) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
259 var b: number |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
260 b = 123 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
261 assert_equal(123, b) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
262 var g: number |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
263 g = 123 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
264 assert_equal(123, g) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
265 var s: number |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
266 s = 123 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
267 assert_equal(123, s) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
268 var t: number |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
269 t = 123 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
270 assert_equal(123, t) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
271 var v: number |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
272 v = 123 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
273 assert_equal(123, v) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
274 var w: number |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
275 w = 123 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
276 assert_equal(123, w) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
277 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
278 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
279 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
|
280 var lines =<< trim END |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
281 vim9script |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
282 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
283 # 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
|
284 var a: string |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
285 var b: number |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
286 var l: list<any> |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
287 var s: string |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
288 var t: number |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
289 var v: number |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
290 var w: number |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
291 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
292 # 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
|
293 a = 'script-a' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
294 b = 111 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
295 l = [1, 2, 3] |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
296 s = 'script-s' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
297 t = 222 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
298 v = 333 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
299 w = 444 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
300 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
301 assert_equal('script-a', a) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
302 assert_equal(111, b) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
303 assert_equal([1, 2, 3], l) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
304 assert_equal('script-s', s) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
305 assert_equal(222, t) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
306 assert_equal(333, v) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
307 assert_equal(444, w) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
308 END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
309 writefile(lines, 'Xsinglechar') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
310 source Xsinglechar |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
311 delete('Xsinglechar') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
312 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
313 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
314 def Test_assignment_list() |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
315 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
|
316 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
|
317 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
|
318 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
|
319 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
|
320 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
321 var listS: list<string> = [] |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
322 var listN: list<number> = [] |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
323 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
324 assert_equal([1, 2, 3], list2) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
325 list2[-1] = 99 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
326 assert_equal([1, 2, 99], list2) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
327 list2[-2] = 88 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
328 assert_equal([1, 88, 99], list2) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
329 list2[-3] = 77 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
330 assert_equal([77, 88, 99], list2) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
331 list2 += [100] |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
332 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
|
333 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
334 list3 += ['end'] |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
335 assert_equal(['sdf', 'asdf', 'end'], list3) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
336 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
337 CheckDefExecFailure(['var ll = [1, 2, 3]', 'll[-4] = 6'], 'E684:') |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
338 CheckDefExecFailure(['var [v1, v2] = [1, 2]'], 'E1092:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
339 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
340 # type becomes list<any> |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
341 var somelist = rand() > 0 ? [1, 2, 3] : ['a', 'b', 'c'] |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
342 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
343 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
344 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
|
345 var lines =<< trim END |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
346 vim9script |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
347 var v1: number |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
348 var v2: number |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
349 var v3: number |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
350 [v1, v2, v3] = [1, 2, 3] |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
351 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
|
352 END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
353 CheckScriptSuccess(lines) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
354 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
355 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
356 def Test_assignment_dict() |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
357 var dict1: dict<bool> = #{one: false, two: true} |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
358 var dict2: dict<number> = #{one: 1, two: 2} |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
359 var dict3: dict<string> = #{key: 'value'} |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
360 var dict4: dict<any> = #{one: 1, two: '2'} |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
361 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
|
362 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
363 # overwrite |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
364 dict3['key'] = 'another' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
365 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
366 # 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
|
367 var dd = {} |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
368 dd[""] = 6 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
369 assert_equal({'': 6}, dd) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
370 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
371 # type becomes dict<any> |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
372 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
|
373 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
374 # assignment to script-local dict |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
375 var lines =<< trim END |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
376 vim9script |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
377 var test: dict<any> = {} |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
378 def FillDict(): dict<any> |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
379 test['a'] = 43 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
380 return test |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
381 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
382 assert_equal(#{a: 43}, FillDict()) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
383 END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
384 CheckScriptSuccess(lines) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
385 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
386 lines =<< trim END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
387 vim9script |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
388 var test: dict<any> |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
389 def FillDict(): dict<any> |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
390 test['a'] = 43 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
391 return test |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
392 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
393 FillDict() |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
394 END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
395 CheckScriptFailure(lines, 'E1103:') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
396 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
397 # assignment to global dict |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
398 lines =<< trim END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
399 vim9script |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
400 g:test = {} |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
401 def FillDict(): dict<any> |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
402 g:test['a'] = 43 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
403 return g:test |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
404 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
405 assert_equal(#{a: 43}, FillDict()) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
406 END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
407 CheckScriptSuccess(lines) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
408 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
409 # assignment to buffer dict |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
410 lines =<< trim END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
411 vim9script |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
412 b:test = {} |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
413 def FillDict(): dict<any> |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
414 b:test['a'] = 43 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
415 return b:test |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
416 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
417 assert_equal(#{a: 43}, FillDict()) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
418 END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
419 CheckScriptSuccess(lines) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
420 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
421 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
422 def Test_assignment_local() |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
423 # 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
|
424 # changed. |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
425 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
|
426 let b:existing = 'yes' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
427 let w:existing = 'yes' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
428 let t:existing = 'yes' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
429 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
430 def Test_assignment_local_internal() |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
431 b:newvar = 'new' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
432 assert_equal('new', b:newvar) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
433 assert_equal('yes', b:existing) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
434 b:existing = 'no' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
435 assert_equal('no', b:existing) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
436 b:existing ..= 'NO' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
437 assert_equal('noNO', b:existing) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
438 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
439 w:newvar = 'new' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
440 assert_equal('new', w:newvar) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
441 assert_equal('yes', w:existing) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
442 w:existing = 'no' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
443 assert_equal('no', w:existing) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
444 w:existing ..= 'NO' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
445 assert_equal('noNO', w:existing) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
446 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
447 t:newvar = 'new' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
448 assert_equal('new', t:newvar) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
449 assert_equal('yes', t:existing) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
450 t:existing = 'no' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
451 assert_equal('no', t:existing) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
452 t:existing ..= 'NO' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
453 assert_equal('noNO', t:existing) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
454 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
455 call Test_assignment_local_internal() |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
456 END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
457 CheckScriptSuccess(script_lines) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
458 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
459 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
460 def Test_assignment_default() |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
461 # Test default values. |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
462 var thebool: bool |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
463 assert_equal(v:false, thebool) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
464 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
465 var thenumber: number |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
466 assert_equal(0, thenumber) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
467 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
468 if has('float') |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
469 var thefloat: float |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
470 assert_equal(0.0, thefloat) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
471 endif |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
472 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
473 var thestring: string |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
474 assert_equal('', thestring) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
475 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
476 var theblob: blob |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
477 assert_equal(0z, theblob) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
478 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
479 var Thefunc: func |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
480 assert_equal(test_null_function(), Thefunc) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
481 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
482 var thelist: list<any> |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
483 assert_equal([], thelist) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
484 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
485 var thedict: dict<any> |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
486 assert_equal({}, thedict) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
487 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
488 if has('channel') |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
489 var thejob: job |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
490 assert_equal(test_null_job(), thejob) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
491 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
492 var thechannel: channel |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
493 assert_equal(test_null_channel(), thechannel) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
494 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
495 if has('unix') && executable('cat') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
496 # check with non-null job and channel, types must match |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
497 thejob = job_start("cat ", #{}) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
498 thechannel = job_getchannel(thejob) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
499 job_stop(thejob, 'kill') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
500 endif |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
501 endif |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
502 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
503 var nr = 1234 | nr = 5678 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
504 assert_equal(5678, nr) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
505 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
506 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
507 def Test_assignment_var_list() |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
508 var v1: string |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
509 var v2: string |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
510 var vrem: list<string> |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
511 [v1] = ['aaa'] |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
512 assert_equal('aaa', v1) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
513 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
514 [v1, v2] = ['one', 'two'] |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
515 assert_equal('one', v1) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
516 assert_equal('two', v2) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
517 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
518 [v1, v2; vrem] = ['one', 'two'] |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
519 assert_equal('one', v1) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
520 assert_equal('two', v2) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
521 assert_equal([], vrem) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
522 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
523 [v1, v2; vrem] = ['one', 'two', 'three'] |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
524 assert_equal('one', v1) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
525 assert_equal('two', v2) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
526 assert_equal(['three'], vrem) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
527 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
528 [&ts, &sw] = [3, 4] |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
529 assert_equal(3, &ts) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
530 assert_equal(4, &sw) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
531 set ts=8 sw=4 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
532 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
533 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
534 def Test_assignment_vim9script() |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
535 var lines =<< trim END |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
536 vim9script |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
537 def Func(): list<number> |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
538 return [1, 2] |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
539 enddef |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
540 var name1: number |
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
541 var name2: number |
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
542 [name1, name2] = |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
543 Func() |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
544 assert_equal(1, name1) |
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
545 assert_equal(2, name2) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
546 var ll = |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
547 Func() |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
548 assert_equal([1, 2], ll) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
549 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
550 @/ = 'text' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
551 assert_equal('text', @/) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
552 @0 = 'zero' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
553 assert_equal('zero', @0) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
554 @1 = 'one' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
555 assert_equal('one', @1) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
556 @9 = 'nine' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
557 assert_equal('nine', @9) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
558 @- = 'minus' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
559 assert_equal('minus', @-) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
560 if has('clipboard_working') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
561 @* = 'star' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
562 assert_equal('star', @*) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
563 @+ = 'plus' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
564 assert_equal('plus', @+) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
565 endif |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
566 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
567 var a: number = 123 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
568 assert_equal(123, a) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
569 var s: string = 'yes' |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
570 assert_equal('yes', s) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
571 var b: number = 42 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
572 assert_equal(42, b) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
573 var w: number = 43 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
574 assert_equal(43, w) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
575 var t: number = 44 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
576 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
|
577 |
08e2363fd0de
patch 8.2.1853: "to_f" is recognized at "topleft" modifier
Bram Moolenaar <Bram@vim.org>
parents:
22582
diff
changeset
|
578 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
|
579 to_var = 3 |
08e2363fd0de
patch 8.2.1853: "to_f" is recognized at "topleft" modifier
Bram Moolenaar <Bram@vim.org>
parents:
22582
diff
changeset
|
580 assert_equal(3, to_var) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
581 END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
582 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
|
583 |
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
|
584 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
|
585 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
|
586 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
|
587 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
|
588 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
|
589 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
|
590 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
|
591 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
|
592 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
|
593 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
594 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
595 def Mess(): string |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
596 v:foldstart = 123 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
597 return 'xxx' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
598 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
599 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
600 def Test_assignment_failure() |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
601 CheckDefFailure(['var name=234'], 'E1004:') |
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
602 CheckDefFailure(['var name =234'], 'E1004:') |
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
603 CheckDefFailure(['var name= 234'], 'E1004:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
604 |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
605 CheckScriptFailure(['vim9script', 'var name=234'], 'E1004:') |
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
606 CheckScriptFailure(['vim9script', 'var name=234'], "before and after '='") |
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
607 CheckScriptFailure(['vim9script', 'var name =234'], 'E1004:') |
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
608 CheckScriptFailure(['vim9script', 'var name= 234'], 'E1004:') |
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
609 CheckScriptFailure(['vim9script', 'var name = 234', 'name+=234'], 'E1004:') |
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
610 CheckScriptFailure(['vim9script', 'var name = 234', 'name+=234'], "before and after '+='") |
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
611 CheckScriptFailure(['vim9script', 'var name = "x"', 'name..="y"'], 'E1004:') |
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
612 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
|
613 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
614 CheckDefFailure(['var true = 1'], 'E1034:') |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
615 CheckDefFailure(['var false = 1'], 'E1034:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
616 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
617 CheckDefFailure(['[a; b; c] = g:list'], 'E452:') |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
618 CheckDefExecFailure(['var a: number', |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
619 '[a] = test_null_list()'], 'E1093:') |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
620 CheckDefExecFailure(['var a: number', |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
621 '[a] = []'], 'E1093:') |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
622 CheckDefExecFailure(['var x: number', |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
623 'var y: number', |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
624 '[x, y] = [1]'], 'E1093:') |
22621
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22618
diff
changeset
|
625 CheckDefExecFailure(['var x: string', |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22618
diff
changeset
|
626 'var y: string', |
576a69fc0066
patch 8.2.1859: Vim9: crash in unpack assignment
Bram Moolenaar <Bram@vim.org>
parents:
22618
diff
changeset
|
627 '[x, y] = ["x"]'], 'E1093:') |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
628 CheckDefExecFailure(['var x: number', |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
629 'var y: number', |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
630 'var z: list<number>', |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
631 '[x, y; z] = [1]'], 'E1093:') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
632 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
633 CheckDefFailure(['var somevar'], "E1022:") |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
634 CheckDefFailure(['var &tabstop = 4'], 'E1052:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
635 CheckDefFailure(['&g:option = 5'], 'E113:') |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
636 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
|
637 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
638 CheckDefFailure(['var $VAR = 5'], 'E1016: Cannot declare an environment variable:') |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
639 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
|
640 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
641 if has('dnd') |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
642 CheckDefFailure(['var @~ = 5'], 'E1066:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
643 else |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
644 CheckDefFailure(['var @~ = 5'], 'E354:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
645 CheckDefFailure(['@~ = 5'], 'E354:') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
646 endif |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
647 CheckDefFailure(['var @a = 5'], 'E1066:') |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
648 CheckDefFailure(['var @/ = "x"'], 'E1066:') |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
649 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
|
650 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
651 CheckDefFailure(['var g:var = 5'], 'E1016: Cannot declare a global variable:') |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
652 CheckDefFailure(['var w:var = 5'], 'E1016: Cannot declare a window variable:') |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
653 CheckDefFailure(['var b:var = 5'], 'E1016: Cannot declare a buffer variable:') |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
654 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
|
655 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
656 CheckDefFailure(['var anr = 4', 'anr ..= "text"'], 'E1019:') |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
657 CheckDefFailure(['var xnr += 4'], 'E1020:', 1) |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
658 CheckScriptFailure(['vim9script', 'var xnr += 4'], 'E1020:') |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
659 CheckDefFailure(["var xnr = xnr + 1"], 'E1001:', 1) |
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
660 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
|
661 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
662 CheckScriptFailure(['vim9script', 'def Func()', 'var dummy = s:notfound', 'enddef', 'defcompile'], 'E1108:') |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
663 |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
664 CheckDefFailure(['var name: list<string> = [123]'], 'expected list<string> but got list<number>') |
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
665 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
|
666 |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
667 CheckDefFailure(['var name: dict<string> = #{key: 123}'], 'expected dict<string> but got dict<number>') |
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
668 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
|
669 |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
670 CheckDefFailure(['var name = feedkeys("0")'], 'E1031:') |
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
671 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
|
672 |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
673 CheckDefFailure(['var name: dict <number>'], 'E1068:') |
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
674 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
|
675 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
676 assert_fails('s/^/\=Mess()/n', 'E794:') |
22433
8b5e2f9580db
patch 8.2.1765: Vim9: some tests use "var var"
Bram Moolenaar <Bram@vim.org>
parents:
22431
diff
changeset
|
677 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
|
678 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
679 CheckDefFailure(['w:foo: number = 10'], |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
680 'E488: Trailing characters: : number = 1') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
681 CheckDefFailure(['t:foo: bool = true'], |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
682 'E488: Trailing characters: : bool = true') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
683 CheckDefFailure(['b:foo: string = "x"'], |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
684 'E488: Trailing characters: : string = "x"') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
685 CheckDefFailure(['g:foo: number = 123'], |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
686 'E488: Trailing characters: : number = 123') |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
687 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
688 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
689 def Test_assign_list() |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
690 var l: list<string> = [] |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
691 l[0] = 'value' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
692 assert_equal('value', l[0]) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
693 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
694 l[1] = 'asdf' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
695 assert_equal('value', l[0]) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
696 assert_equal('asdf', l[1]) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
697 assert_equal('asdf', l[-1]) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
698 assert_equal('value', l[-2]) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
699 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
700 var nrl: list<number> = [] |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
701 for i in range(5) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
702 nrl[i] = i |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
703 endfor |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
704 assert_equal([0, 1, 2, 3, 4], nrl) |
22631
59cd5f8b2ab2
patch 8.2.1864: Vim9: no error for wrong list type
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
705 |
59cd5f8b2ab2
patch 8.2.1864: Vim9: no error for wrong list type
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
706 CheckDefFailure(["var l: list<number> = ['', true]"], 'E1012: Type mismatch; expected list<number> but got list<any>', 1) |
59cd5f8b2ab2
patch 8.2.1864: Vim9: no error for wrong list type
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
707 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
|
708 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
709 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
710 def Test_assign_dict() |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
711 var d: dict<string> = {} |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
712 d['key'] = 'value' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
713 assert_equal('value', d['key']) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
714 |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
715 d[123] = 'qwerty' |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
716 assert_equal('qwerty', d[123]) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
717 assert_equal('qwerty', d['123']) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
718 |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
719 var nrd: dict<number> = {} |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
720 for i in range(3) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
721 nrd[i] = i |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
722 endfor |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
723 assert_equal({'0': 0, '1': 1, '2': 2}, nrd) |
22631
59cd5f8b2ab2
patch 8.2.1864: Vim9: no error for wrong list type
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
724 |
59cd5f8b2ab2
patch 8.2.1864: Vim9: no error for wrong list type
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
725 CheckDefFailure(["var d: dict<number> = #{a: '', b: true}"], 'E1012: Type mismatch; expected dict<number> but got dict<any>', 1) |
59cd5f8b2ab2
patch 8.2.1864: Vim9: no error for wrong list type
Bram Moolenaar <Bram@vim.org>
parents:
22621
diff
changeset
|
726 CheckDefFailure(["var d: dict<dict<number>> = #{x: #{a: '', b: true}}"], 'E1012: Type mismatch; expected dict<dict<number>> but got dict<dict<any>>', 1) |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
727 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
728 |
22363
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
729 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
|
730 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
|
731 vim9script |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
732 var mylist = [] |
22363
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
733 mylist += [#{one: 'one'}] |
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
734 def Func() |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
735 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
|
736 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
|
737 enddef |
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
738 Func() |
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
739 END |
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
740 CheckScriptSuccess(lines) |
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
741 |
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
742 # doesn't work yet |
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
743 #lines =<< trim END |
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
744 # vim9script |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
745 # var mylist = [[]] |
22363
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
746 # mylist[0] += [#{one: 'one'}] |
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
747 # def Func() |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
748 # var dd = mylist[0][0] |
22363
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
749 # 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
|
750 # enddef |
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
751 # Func() |
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
752 #END |
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
753 #CheckScriptSuccess(lines) |
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
754 enddef |
6c3d15011081
patch 8.2.1730: Vim9: cannot use member of unknown type
Bram Moolenaar <Bram@vim.org>
parents:
22351
diff
changeset
|
755 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
756 def Test_assign_lambda() |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
757 # 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
|
758 var lines =<< trim END |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
759 vim9script |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
760 var FuncRef = {->123} |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
761 assert_equal(123, FuncRef()) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
762 var FuncRef_Func: func = {->123} |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
763 assert_equal(123, FuncRef_Func()) |
22391
a9fb7efa31d6
patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents:
22365
diff
changeset
|
764 var FuncRef_Any: any = {->123} |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
765 assert_equal(123, FuncRef_Any()) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
766 END |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
767 CheckScriptSuccess(lines) |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
768 enddef |
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
769 |
22413
66d1131a7eff
patch 8.2.1755: Vim9: crash when using invalid heredoc marker
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
770 def Test_heredoc() |
66d1131a7eff
patch 8.2.1755: Vim9: crash when using invalid heredoc marker
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
771 var lines =<< trim END # comment |
66d1131a7eff
patch 8.2.1755: Vim9: crash when using invalid heredoc marker
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
772 text |
66d1131a7eff
patch 8.2.1755: Vim9: crash when using invalid heredoc marker
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
773 END |
66d1131a7eff
patch 8.2.1755: Vim9: crash when using invalid heredoc marker
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
774 assert_equal(['text'], lines) |
66d1131a7eff
patch 8.2.1755: Vim9: crash when using invalid heredoc marker
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
775 |
66d1131a7eff
patch 8.2.1755: Vim9: crash when using invalid heredoc marker
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
776 CheckDefFailure(['var lines =<< trim END X', 'END'], 'E488:') |
66d1131a7eff
patch 8.2.1755: Vim9: crash when using invalid heredoc marker
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
777 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
|
778 |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
779 lines =<< trim [END] |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
780 def Func() |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
781 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
|
782 x |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
783 x |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
784 x |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
785 x |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
786 x |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
787 x |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
788 x |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
789 x |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
790 enddef |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
791 call Func() |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
792 [END] |
5b35b477eff0
patch 8.2.1760: Vim9: crash when end marker is missing
Bram Moolenaar <Bram@vim.org>
parents:
22413
diff
changeset
|
793 CheckScriptFailure(lines, 'E990:') |
22413
66d1131a7eff
patch 8.2.1755: Vim9: crash when using invalid heredoc marker
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
794 enddef |
66d1131a7eff
patch 8.2.1755: Vim9: crash when using invalid heredoc marker
Bram Moolenaar <Bram@vim.org>
parents:
22391
diff
changeset
|
795 |
22458
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
796 def Test_let_func_call() |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
797 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
|
798 vim9script |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
799 func GetValue() |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
800 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
|
801 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
|
802 else |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
803 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
|
804 endif |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
805 return 'this' |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
806 endfunc |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
807 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
|
808 # 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
|
809 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
|
810 END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
811 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
|
812 source Xfinished |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
813 # 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
|
814 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
|
815 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
816 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
|
817 delete('Xfinished') |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
818 enddef |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
819 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
820 def Test_let_missing_type() |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
821 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
|
822 vim9script |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
823 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
|
824 END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
825 CheckScriptFailure(lines, 'E121:') |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
826 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
827 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
|
828 vim9script |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
829 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
|
830 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
|
831 END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
832 CheckScriptSuccess(lines) |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
833 enddef |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
834 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
835 def Test_let_declaration() |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
836 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
|
837 vim9script |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
838 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
|
839 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
|
840 name = 'text' |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
841 g:var_test = name |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
842 # prefixing s: is optional |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
843 s:name = 'prefixed' |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
844 g:var_prefixed = s:name |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
845 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
846 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
|
847 other = 1234 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
848 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
|
849 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
850 # type is inferred |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
851 s:dict = {'a': 222} |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
852 def GetDictVal(key: any) |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
853 g:dict_val = s:dict[key] |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
854 enddef |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
855 GetDictVal('a') |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
856 END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
857 CheckScriptSuccess(lines) |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
858 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
|
859 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
|
860 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
|
861 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
|
862 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
|
863 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
864 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
|
865 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
|
866 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
|
867 unlet 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
|
868 enddef |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
869 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
870 def Test_let_declaration_fails() |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
871 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
|
872 vim9script |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
873 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
|
874 END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
875 CheckScriptFailure(lines, 'E1125:') |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
876 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
877 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
|
878 vim9script |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
879 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
|
880 END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
881 CheckScriptFailure(lines, 'E1021:') |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
882 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
883 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
|
884 vim9script |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
885 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
|
886 END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
887 CheckScriptFailure(lines, 'E475:') |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
888 enddef |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
889 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
890 def Test_let_type_check() |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
891 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
|
892 vim9script |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
893 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
|
894 name = 1234 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
895 END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
896 CheckScriptFailure(lines, 'E1012:') |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
897 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
898 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
|
899 vim9script |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
900 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
|
901 END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
902 CheckScriptFailure(lines, 'E1069:') |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
903 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
904 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
|
905 vim9script |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
906 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
|
907 END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
908 CheckScriptFailure(lines, 'E1010:') |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
909 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
910 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
|
911 vim9script |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
912 var s:l: list<number> |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
913 s:l = [] |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
914 END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
915 CheckScriptSuccess(lines) |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
916 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
917 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
|
918 vim9script |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
919 var s:d: dict<number> |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
920 s:d = {} |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
921 END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
922 CheckScriptSuccess(lines) |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
923 enddef |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
924 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
925 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
|
926 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
927 def Test_let_list_dict_type() |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
928 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
|
929 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
|
930 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
|
931 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
932 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
|
933 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
|
934 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
|
935 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
936 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
|
937 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
|
938 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
|
939 END |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
940 CheckDefExecFailure(lines, 'E1012: Type mismatch; expected list<number> but got list<string>') |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
941 enddef |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
942 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
943 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
|
944 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
|
945 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
|
946 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
|
947 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
|
948 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
|
949 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
950 # 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
|
951 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
|
952 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
|
953 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
|
954 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
|
955 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
|
956 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
957 CheckScriptFailure([ |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
958 'vim9script', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
959 '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
|
960 'unlet svar', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
961 ], 'E1081:') |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
962 CheckScriptFailure([ |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
963 'vim9script', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
964 '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
|
965 '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
|
966 ], 'E1081:') |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
967 CheckScriptFailure([ |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
968 'vim9script', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
969 '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
|
970 'def Func()', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
971 ' unlet svar', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
972 'enddef', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
973 'defcompile', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
974 ], 'E1081:') |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
975 CheckScriptFailure([ |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
976 'vim9script', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
977 '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
|
978 'def Func()', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
979 ' 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
|
980 'enddef', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
981 'defcompile', |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
982 ], 'E1081:') |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
983 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
984 $ENVVAR = 'foobar' |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
985 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
|
986 unlet $ENVVAR |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
987 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
|
988 enddef |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
989 |
f5731190bc66
patch 8.2.1777: Vim9: some assignment tests in the wrong file
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
990 |
22351
4c488004edbc
patch 8.2.1724: Vim9: assignment tests spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
991 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |